xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/wasm_bindgen/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan# Copyright 2020 The Bazel Authors. All rights reserved.
2*d4726bddSHONG Yifan#
3*d4726bddSHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License");
4*d4726bddSHONG Yifan# you may not use this file except in compliance with the License.
5*d4726bddSHONG Yifan# You may obtain a copy of the License at
6*d4726bddSHONG Yifan#
7*d4726bddSHONG Yifan#    http://www.apache.org/licenses/LICENSE-2.0
8*d4726bddSHONG Yifan#
9*d4726bddSHONG Yifan# Unless required by applicable law or agreed to in writing, software
10*d4726bddSHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS,
11*d4726bddSHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*d4726bddSHONG Yifan# See the License for the specific language governing permissions and
13*d4726bddSHONG Yifan# limitations under the License.
14*d4726bddSHONG Yifan
15*d4726bddSHONG Yifanload("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library")
16*d4726bddSHONG Yifanload("@rules_rust//wasm_bindgen:defs.bzl", "rust_wasm_bindgen")
17*d4726bddSHONG Yifan
18*d4726bddSHONG Yifanpackage(default_visibility = ["//wasm_bindgen:__subpackages__"])
19*d4726bddSHONG Yifan
20*d4726bddSHONG Yifanexports_files([
21*d4726bddSHONG Yifan    "hello_world_wasm_test.js",
22*d4726bddSHONG Yifan    "main.rs",
23*d4726bddSHONG Yifan])
24*d4726bddSHONG Yifan
25*d4726bddSHONG Yifanrust_binary(
26*d4726bddSHONG Yifan    name = "hello_world_bin_wasm",
27*d4726bddSHONG Yifan    srcs = ["main.rs"],
28*d4726bddSHONG Yifan    edition = "2018",
29*d4726bddSHONG Yifan    deps = [
30*d4726bddSHONG Yifan        "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen",
31*d4726bddSHONG Yifan    ],
32*d4726bddSHONG Yifan)
33*d4726bddSHONG Yifan
34*d4726bddSHONG Yifanrust_shared_library(
35*d4726bddSHONG Yifan    name = "hello_world_lib_wasm",
36*d4726bddSHONG Yifan    srcs = ["main.rs"],
37*d4726bddSHONG Yifan    edition = "2018",
38*d4726bddSHONG Yifan    deps = [
39*d4726bddSHONG Yifan        "@rules_rust//wasm_bindgen/3rdparty:wasm_bindgen",
40*d4726bddSHONG Yifan    ],
41*d4726bddSHONG Yifan)
42*d4726bddSHONG Yifan
43*d4726bddSHONG Yifanrust_wasm_bindgen(
44*d4726bddSHONG Yifan    name = "hello_world_bundler_wasm_bindgen",
45*d4726bddSHONG Yifan    wasm_file = ":hello_world_bin_wasm",
46*d4726bddSHONG Yifan)
47*d4726bddSHONG Yifan
48*d4726bddSHONG Yifanrust_wasm_bindgen(
49*d4726bddSHONG Yifan    name = "hello_world_web_wasm_bindgen",
50*d4726bddSHONG Yifan    target = "web",
51*d4726bddSHONG Yifan    wasm_file = ":hello_world_lib_wasm",
52*d4726bddSHONG Yifan)
53*d4726bddSHONG Yifan
54*d4726bddSHONG Yifanrust_wasm_bindgen(
55*d4726bddSHONG Yifan    name = "hello_world_deno_wasm_bindgen",
56*d4726bddSHONG Yifan    target = "deno",
57*d4726bddSHONG Yifan    wasm_file = ":hello_world_lib_wasm",
58*d4726bddSHONG Yifan)
59*d4726bddSHONG Yifan
60*d4726bddSHONG Yifanrust_wasm_bindgen(
61*d4726bddSHONG Yifan    name = "hello_world_nomodules_wasm_bindgen",
62*d4726bddSHONG Yifan    target = "no-modules",
63*d4726bddSHONG Yifan    wasm_file = ":hello_world_lib_wasm",
64*d4726bddSHONG Yifan)
65*d4726bddSHONG Yifan
66*d4726bddSHONG Yifanrust_wasm_bindgen(
67*d4726bddSHONG Yifan    name = "hello_world_nodejs_wasm_bindgen",
68*d4726bddSHONG Yifan    target = "nodejs",
69*d4726bddSHONG Yifan    wasm_file = ":hello_world_lib_wasm",
70*d4726bddSHONG Yifan)
71