fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreUpdate wasm_bindgen to use crate universe. (#1398)97264b79

0.7.0
3.2 KiB75 linesraw
1# Copyright 2019 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# buildifier: disable=module-docstring
16load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
17load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
18load("//wasm_bindgen/3rdparty/crates:defs.bzl", "crate_repositories")
19
20WASM_BINDGEN_VERSION = "0.2.78"
21
22# buildifier: disable=unnamed-macro
23def rust_wasm_bindgen_dependencies():
24    """Declare dependencies needed for the `rules_rust` [wasm-bindgen][wb] rules.
25
26    [wb]: https://github.com/rustwasm/wasm-bindgen
27    """
28
29    maybe(
30        http_archive,
31        name = "rules_rust_wasm_bindgen_cli",
32        sha256 = "262a79690c18f5160ca109e839814783e29b71f1fd28448f80838145f93c08b6",
33        urls = ["https://crates.io/api/v1/crates/wasm-bindgen-cli/{}/download".format(WASM_BINDGEN_VERSION)],
34        type = "tar.gz",
35        strip_prefix = "wasm-bindgen-cli-{}".format(WASM_BINDGEN_VERSION),
36        build_file = Label("//wasm_bindgen/3rdparty:BUILD.wasm-bindgen-cli.bazel"),
37    )
38
39    maybe(
40        http_archive,
41        name = "rules_nodejs",
42        sha256 = "26766278d815a6e2c43d2f6c9c72fde3fec8729e84138ffa4dabee47edc7702a",
43        urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.2/rules_nodejs-core-5.4.2.tar.gz"],
44    )
45
46    crate_repositories()
47
48# buildifier: disable=unnamed-macro
49def rust_wasm_bindgen_register_toolchains(register_toolchains = True):
50    """Registers the default toolchains for the `rules_rust` [wasm-bindgen][wb] rules.
51
52    [wb]: https://github.com/rustwasm/wasm-bindgen
53
54    Args:
55        register_toolchains (bool, optional): Whether or not to register toolchains.
56    """
57
58    if register_toolchains:
59        native.register_toolchains(str(Label("//wasm_bindgen:default_wasm_bindgen_toolchain")))
60
61# buildifier: disable=unnamed-macro
62def rust_wasm_bindgen_repositories(register_default_toolchain = True):
63    """Declare dependencies needed for [rust_wasm_bindgen](#rust_wasm_bindgen).
64
65    **Deprecated**: Use [rust_wasm_bindgen_dependencies](#rust_wasm_bindgen_depednencies) and [rust_wasm_bindgen_register_toolchains](#rust_wasm_bindgen_register_toolchains).
66
67    Args:
68        register_default_toolchain (bool, optional): If True, the default [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain)
69            (`@rules_rust//wasm_bindgen:default_wasm_bindgen_toolchain`) is registered. This toolchain requires a set of dependencies
70            that were generated using [cargo raze](https://github.com/google/cargo-raze). These will also be loaded.
71    """
72
73    rust_wasm_bindgen_dependencies()
74
75    rust_wasm_bindgen_register_toolchains(register_toolchains = register_default_toolchain)