• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("@aspect_rules_js//js:defs.bzl", "js_library", "js_test")
2load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
3load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library")
4load("@rules_rust//wasm_bindgen/rules_js:defs.bzl", "js_rust_wasm_bindgen")
5
6package(default_visibility = ["//visibility:public"])
7
8copy_file(
9    name = "hello_world_wasm_test.src",
10    src = "//wasm_bindgen:hello_world_wasm_test.js",
11    out = "hello_world_wasm_test.js",
12)
13
14rust_binary(
15    name = "hello_world_bin_wasm",
16    srcs = ["//wasm_bindgen:main.rs"],
17    edition = "2018",
18    deps = [
19        "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen",
20    ],
21)
22
23rust_shared_library(
24    name = "hello_world_lib_wasm",
25    srcs = ["//wasm_bindgen:main.rs"],
26    edition = "2018",
27    deps = [
28        "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen",
29    ],
30)
31
32js_rust_wasm_bindgen(
33    name = "hello_world_bundler_wasm_bindgen",
34    wasm_file = ":hello_world_bin_wasm",
35)
36
37js_rust_wasm_bindgen(
38    name = "hello_world_web_wasm_bindgen",
39    target = "web",
40    wasm_file = ":hello_world_lib_wasm",
41)
42
43js_rust_wasm_bindgen(
44    name = "hello_world_deno_wasm_bindgen",
45    target = "deno",
46    wasm_file = ":hello_world_lib_wasm",
47)
48
49js_rust_wasm_bindgen(
50    name = "hello_world_nomodules_wasm_bindgen",
51    target = "no-modules",
52    wasm_file = ":hello_world_lib_wasm",
53)
54
55js_rust_wasm_bindgen(
56    name = "hello_world_nodejs_wasm_bindgen",
57    target = "nodejs",
58    wasm_file = ":hello_world_lib_wasm",
59)
60
61_WASM_DATA = [
62    ":hello_world_bundler_wasm_bindgen",
63    ":hello_world_deno_wasm_bindgen",
64    ":hello_world_nodejs_wasm_bindgen",
65    ":hello_world_nomodules_wasm_bindgen",
66    ":hello_world_web_wasm_bindgen",
67]
68
69js_test(
70    name = "hello_world_wasm_direct_test",
71    data = _WASM_DATA,
72    entry_point = ":hello_world_wasm_test.js",
73)
74
75js_library(
76    name = "hello_world_wasm_lib",
77    srcs = [
78        ":hello_world_wasm_test.js",
79    ],
80    data = _WASM_DATA,
81    deps = [],
82)
83
84js_test(
85    name = "hello_world_wasm_lib_test",
86    data = [
87        ":hello_world_wasm_lib",
88    ],
89    entry_point = ":hello_world_wasm_lib",
90)
91