xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/wasm_bindgen/rules_nodejs/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test")
2load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library")
3load("@rules_rust//wasm_bindgen/rules_nodejs:defs.bzl", "nodejs_rust_wasm_bindgen")
4
5package(default_visibility = ["//visibility:public"])
6
7rust_binary(
8    name = "hello_world_bin_wasm",
9    srcs = ["//wasm_bindgen:main.rs"],
10    edition = "2018",
11    deps = [
12        "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen",
13    ],
14)
15
16rust_shared_library(
17    name = "hello_world_lib_wasm",
18    srcs = ["//wasm_bindgen:main.rs"],
19    edition = "2018",
20    deps = [
21        "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen",
22    ],
23)
24
25nodejs_rust_wasm_bindgen(
26    name = "hello_world_bundler_wasm_bindgen",
27    wasm_file = ":hello_world_bin_wasm",
28)
29
30nodejs_rust_wasm_bindgen(
31    name = "hello_world_web_wasm_bindgen",
32    target = "web",
33    wasm_file = ":hello_world_lib_wasm",
34)
35
36nodejs_rust_wasm_bindgen(
37    name = "hello_world_deno_wasm_bindgen",
38    target = "deno",
39    wasm_file = ":hello_world_lib_wasm",
40)
41
42nodejs_rust_wasm_bindgen(
43    name = "hello_world_nomodules_wasm_bindgen",
44    target = "no-modules",
45    wasm_file = ":hello_world_lib_wasm",
46)
47
48nodejs_rust_wasm_bindgen(
49    name = "hello_world_nodejs_wasm_bindgen",
50    target = "nodejs",
51    wasm_file = ":hello_world_lib_wasm",
52)
53
54nodejs_test(
55    name = "hello_world_wasm_test",
56    args = ["rules_nodejs"],
57    data = [
58        ":hello_world_bundler_wasm_bindgen",
59        ":hello_world_deno_wasm_bindgen",
60        ":hello_world_nodejs_wasm_bindgen",
61        ":hello_world_nomodules_wasm_bindgen",
62        ":hello_world_web_wasm_bindgen",
63    ],
64    entry_point = "//wasm_bindgen:hello_world_wasm_test.js",
65)
66