fork/rules_rust

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

UebelAndreVarious cleanups (#1828)9adfdca9

rust-analyzer
3.2 KiB76 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"""Dependency definitions for wasm-bindgen rules"""
16
17load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
19load("//wasm_bindgen/3rdparty/crates:defs.bzl", "crate_repositories")
20
21WASM_BINDGEN_VERSION = "0.2.83"
22
23# buildifier: disable=unnamed-macro
24def rust_wasm_bindgen_dependencies():
25    """Declare dependencies needed for the `rules_rust` [wasm-bindgen][wb] rules.
26
27    [wb]: https://github.com/rustwasm/wasm-bindgen
28    """
29
30    maybe(
31        http_archive,
32        name = "rules_rust_wasm_bindgen_cli",
33        sha256 = "5a0e951a61574d4ba2d9d2705cc6b7cd8d67aefeb982bf2a60a9c7b05bef5682",
34        urls = ["https://crates.io/api/v1/crates/wasm-bindgen-cli/{}/download".format(WASM_BINDGEN_VERSION)],
35        type = "tar.gz",
36        strip_prefix = "wasm-bindgen-cli-{}".format(WASM_BINDGEN_VERSION),
37        build_file = Label("//wasm_bindgen/3rdparty:BUILD.wasm-bindgen-cli.bazel"),
38    )
39
40    maybe(
41        http_archive,
42        name = "rules_nodejs",
43        sha256 = "017e2348bb8431156d5cf89b6f502c2e7fcffc568729f74f89e4a12bd8279e90",
44        urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.2/rules_nodejs-core-5.5.2.tar.gz"],
45    )
46
47    crate_repositories()
48
49# buildifier: disable=unnamed-macro
50def rust_wasm_bindgen_register_toolchains(register_toolchains = True):
51    """Registers the default toolchains for the `rules_rust` [wasm-bindgen][wb] rules.
52
53    [wb]: https://github.com/rustwasm/wasm-bindgen
54
55    Args:
56        register_toolchains (bool, optional): Whether or not to register toolchains.
57    """
58
59    if register_toolchains:
60        native.register_toolchains(str(Label("//wasm_bindgen:default_wasm_bindgen_toolchain")))
61
62# buildifier: disable=unnamed-macro
63def rust_wasm_bindgen_repositories(register_default_toolchain = True):
64    """Declare dependencies needed for [rust_wasm_bindgen](#rust_wasm_bindgen).
65
66    **Deprecated**: Use [rust_wasm_bindgen_dependencies](#rust_wasm_bindgen_depednencies) and [rust_wasm_bindgen_register_toolchains](#rust_wasm_bindgen_register_toolchains).
67
68    Args:
69        register_default_toolchain (bool, optional): If True, the default [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain)
70            (`@rules_rust//wasm_bindgen:default_wasm_bindgen_toolchain`) is registered. This toolchain requires a set of dependencies
71            that were generated using [cargo raze](https://github.com/google/cargo-raze). These will also be loaded.
72    """
73
74    rust_wasm_bindgen_dependencies()
75
76    rust_wasm_bindgen_register_toolchains(register_toolchains = register_default_toolchain)