Skip to content

Commit

Permalink
Fix build with GOOS=js GOARCH=wasm
Browse files Browse the repository at this point in the history
GOOS=js GOARCH=wasm gb ./...

Previously failed with errors importing x/sys/unix.

Fixed by adding the appropriate build tags.

Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin authored and mangalaman93 committed Aug 4, 2024
1 parent c783199 commit 0c1ba00
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
40 changes: 40 additions & 0 deletions z/mmap_js.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//go:build js

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package z

import (
"os"
"syscall"
)

func mmap(fd *os.File, writeable bool, size int64) ([]byte, error) {
return nil, syscall.ENOSYS
}

func munmap(b []byte) error {
return syscall.ENOSYS
}

func madvise(b []byte, readahead bool) error {
return syscall.ENOSYS
}

func msync(b []byte) error {
return syscall.ENOSYS
}
3 changes: 3 additions & 0 deletions z/mmap_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !js
// +build !js

/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
Expand Down
4 changes: 2 additions & 2 deletions z/mmap_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !windows && !darwin && !plan9 && !linux && !wasip1
// +build !windows,!darwin,!plan9,!linux,!wasip1
//go:build !windows && !darwin && !plan9 && !linux && !wasip1 && !js
// +build !windows,!darwin,!plan9,!linux,!wasip1,!js

/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
Expand Down
3 changes: 2 additions & 1 deletion z/mremap_nosize.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build (arm64 || arm) && linux
//go:build (arm64 || arm) && linux && !js
// +build arm64 arm
// +build linux
// +build !js

/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
Expand Down
4 changes: 2 additions & 2 deletions z/mremap_size.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build linux && !arm64 && !arm
// +build linux,!arm64,!arm
//go:build linux && !arm64 && !arm && !js
// +build linux,!arm64,!arm,!js

/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
Expand Down

0 comments on commit 0c1ba00

Please sign in to comment.