Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bazel files #108

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ jobs:
run: |
export PATH="$HOME/.cargo/bin:$PATH"
just test
- name: Test bazel build
shell: bash
run: |
export GOOS=$(go env GOHOSTOS)
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.2.1/bazelisk-${GOOS}-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv "bazelisk-${GOOS}-amd64" "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
"${GITHUB_WORKSPACE}/bin/bazel" build //...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/wasmer/_obj
/wasmer/pkg
/wasmer/pkg
/bazel-*
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package(default_visibility = ["//visibility:public"])

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ $ just build
$ go install github.com/wasmerio/go-ext-wasm/wasmer
```

If you are a bazel user, add following to your WORKSPACE file

```
git_repository(
name = "com_github_wasmerio_go_ext_wasm",
remote = "https://github.com/wasmerio/go-ext-wasm",
commit = "",
)
```

# Documentation

[The documentation can be read online on godoc.org][documentation]. It
Expand Down
69 changes: 69 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
workspace(
name = "go_ext_wasm",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
name = "io_bazel_rules_go",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with Babel. What that does?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel is a build tool, I think from Google

urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.19.4/rules_go-0.19.4.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/0.19.4/rules_go-0.19.4.tar.gz",
],
sha256 = "ae8c36ff6e565f674c7a3692d6a9ea1096e4c1ade497272c2108a810fb39acd2",
)

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")

go_rules_dependencies()

go_register_toolchains()

http_archive(
name = "bazel_gazelle",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above: What is it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems is autogenerated from bazel rules-go:

https://github.com/bazelbuild/rules_go

urls = [
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz",
],
sha256 = "7fc87f4170011201b1690326e8c16c5d802836e3a0d617d8f75c3af2b23180c4",
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

go_repository(
name = "com_github_davecgh_go_spew",
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
importpath = "github.com/davecgh/go-spew",
sum = "h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=",
version = "v1.1.0",
)

go_repository(
name = "com_github_pmezard_go_difflib",
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
importpath = "github.com/pmezard/go-difflib",
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
version = "v1.0.0",
)

go_repository(
name = "com_github_stretchr_objx",
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
importpath = "github.com/stretchr/objx",
sum = "h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=",
version = "v0.1.0",
)

go_repository(
name = "com_github_stretchr_testify",
importpath = "github.com/stretchr/testify",
sum = "h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=",
version = "v1.3.0",
)

go_repository(
name = "com_github_urfave_cli",
importpath = "github.com/urfave/cli",
sum = "h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=",
version = "v1.20.0",
)
18 changes: 18 additions & 0 deletions go-wasmer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/wasmerio/go-ext-wasm/go-wasmer",
visibility = ["//visibility:private"],
deps = [
"//wasmer:go_default_library",
"@com_github_urfave_cli//:go_default_library",
],
)

go_binary(
name = "go-wasmer",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
36 changes: 36 additions & 0 deletions wasmer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "wasm",
srcs = glob(["*.h"]) + select({
"@io_bazel_rules_go//go/platform:darwin": ["libwasmer_runtime_c_api.dylib"],
"@io_bazel_rules_go//go/platform:linux_amd64": ["libwasmer_runtime_c_api.so"],
"@io_bazel_rules_go//go/platform:windows_amd64": ["lwasmer_runtime_c_api.dll"],
}),
hdrs = glob(["*.h"]),
visibility = ["//visibility:public"],
includes = ["."],
)

go_library(
name = "go_default_library",
srcs = [
"bridge.go",
"error.go",
"import.go",
"instance.go",
"memory.go",
"module.go",
"value.go",
"wasi.go",
"wasmer.go",
"wasmer.h",
],
cgo = True,
clinkopts = ["-Wl,-rpath,wasmer -Lwasmer/wasmer -lwasmer_runtime_c_api"],
importpath = "github.com/wasmerio/go-ext-wasm/wasmer",
visibility = ["//visibility:public"],
cdeps = [":wasm"],
)