rules_haskell
rules_haskell copied to clipboard
Asterius Hello World Example Docs
Is your feature request related to a problem? Please describe. I noticed that there was experimental support for compiling using Asterius, but there really isnt anything on how to use it.
Describe the solution you'd like A Simple hello world example of how to use Asterius to compile to webassembly.
Describe alternatives you've considered Currently just plan on using Dockerfile with build stages.
In #1817 I made an example of using Asterius to build an "Hello world!" (not the simplest one) and generate a .wasm
file.
@GuillaumeGen I am able to build the binary, but when I try to build the bundle I get this error. I just cloned your branch down and ran nix-shell then bazel build //:asterius_bundle
bazel build //:asterius_bundle
INFO: Repository npm_rules_haskell instantiated at:
/home/loki/Code/sandbox/rules_haskell/examples/asterius/WORKSPACE:25:30: in <toplevel>
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/rules_haskell/haskell/asterius/repositories.bzl:337:35: in asterius_dependencies_bindist
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/rules_haskell/haskell/asterius/asterius_dependencies.bzl:61:10: in asterius_dependencies_bindist
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/rules_haskell/haskell/asterius/asterius_dependencies.bzl:42:10: in _yarn
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/bazel_tools/tools/build_defs/repo/utils.bzl:201:18: in maybe
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/build_bazel_rules_nodejs/index.bzl:83:18: in yarn_install
Repository rule yarn_install defined at:
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:917:31: in <toplevel>
ERROR: An error occurred during the fetch of repository 'npm_rules_haskell':
Traceback (most recent call last):
File "/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 894, column 13, in _yarn_install_impl
fail("pre_process_package_json.js failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr))
Error in fail: pre_process_package_json.js failed:
STDOUT:
STDERR:
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/nodejs_linux_amd64/bin/node: line 19: /home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/nodejs_linux_amd64/bin/nodejs/bin/node: No such file or directory
ERROR: Error fetching repository: Traceback (most recent call last):
File "/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 894, column 13, in _yarn_install_impl
fail("pre_process_package_json.js failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr))
Error in fail: pre_process_package_json.js failed:
STDOUT:
STDERR:
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/nodejs_linux_amd64/bin/node: line 19: /home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/nodejs_linux_amd64/bin/nodejs/bin/node: No such file or directory
ERROR: /home/loki/Code/sandbox/rules_haskell/examples/asterius/BUILD.bazel:40:17: //:asterius_bundle depends on @rules_haskell_asterius_webpack//:webpack in repository @rules_haskell_asterius_webpack which failed to fetch. no such package '@npm_rules_haskell//webpack-cli': pre_process_package_json.js failed:
STDOUT:
STDERR:
/home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/nodejs_linux_amd64/bin/node: line 19: /home/loki/.cache/bazel/_bazel_loki/8d41f3a74e34877ad70fe7a5c657135b/external/nodejs_linux_amd64/bin/nodejs/bin/node: No such file or directory
ERROR: Analysis of target '//:asterius_bundle' failed; build aborted: Analysis failed
INFO: Elapsed time: 6.107s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (29 packages loaded, 53 targets configured)
currently loading: @rules_haskell_asterius_webpack//
got it to work with nix by adding the following
asterius_dependencies_nix(
nix_repository = "@nixpkgs",
nixpkgs_package_rule = nixpkgs_package,
nixpkgs_nodejs = "nodejs-16_x",
)
@GuillaumeGen thank you for the example!!