Skip to content

how to use wasmer as a third party library using bazel? #259

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

Closed
joehattori opened this issue Apr 12, 2021 · 6 comments
Closed

how to use wasmer as a third party library using bazel? #259

joehattori opened this issue Apr 12, 2021 · 6 comments
Labels
❓ question Further information is requested

Comments

@joehattori
Copy link

joehattori commented Apr 12, 2021

Summary

I failed to integrate wasmer-go to other project using bazel, both from remote and local.
Could anyone solve this?

Additional details

I am trying to use wasmer-go as a third party library but have a problem with bazel build.
The project (let me call it project X) I am trying to integrate wasmer-go to uses bazel. I added following lines to WORKSPACE of project X

go_repository(
  name = "com_github_wasmer_go",
  importpath = "github.com/wasmerio/wasmer-go",
  commit = "..."
)

and I added the following line to deps in corresponding BUILD file where a Go file importing wasmer-go exists

"@com_github_wasmer_go//wasmer:go_default_library"

but still get this error

ERROR: .... no such package '@com_github_wasmer_go//wasmer': BUILD file not found in directory 'wasmer' of external repository @com_github_wasmer_go. Add a BUILD file to a directory to mark it as a package. and referenced by ....

I see wasmer/ directory doesn't have BUILD file as this error says. Could you tell me how to fix this error?

P.S.
I cloned wasmer-go to local and I changed the BUILD file of wasmer-go to

load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/wasmerio/wasmer-go
gazelle(name = "gazelle")

package(default_visibility = ["//visibility:public"])

and ran bazel run gazelle, and then modified the WORKSPACE and BUILD file of the project X to use the local wasmer-go. Now I get this strange error when I compile with bazel build <target>

Use --sandbox_debug to see verbose messages from the sandbox
<file>: undefined: wasmer.Instance
<file>: undefined: wasmer.NewEngine
...
compilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/compile: exit status 2
@joehattori joehattori added the ❓ question Further information is requested label Apr 12, 2021
@joehattori
Copy link
Author

Even when I forked this repository and deleted BUILD and WORKSPACE file (here) and treat it as a non-Bazel repository, I still get this error

Use --sandbox_debug to see verbose messages from the sandbox
<file>.go: undefined: wasmer.Instance
<file>.go: undefined: wasmer.NewEngine
<file>.go: undefined: wasmer.NewStore

@joehattori
Copy link
Author

solved with bazel-contrib/rules_go#2861

@Hywan
Copy link
Contributor

Hywan commented Apr 19, 2021

Hello @joehattori,

Do we need to do something on our side to fix Bazel?

@joehattori
Copy link
Author

joehattori commented Apr 20, 2021

@Hywan Currently this repository has BUILD file and WORKSPACE file, but it is not sufficient to build wasmer-go with bazel.
I think it is good to fix bazel support or remove BUILD and WORKSPACE.
If needed, I would submit a PR for it!

@Hywan
Copy link
Contributor

Hywan commented Apr 20, 2021

Bazel support has been introduced in #106 and #108 by a contributor, but I'm not familiar with Bazel at all. If you're willing to submit a PR, I would gladly accept it!

@joehattori
Copy link
Author

@Hywan I'm looking into it, but maybe it takes some time. I'll submit a PR when I'm done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants