fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
d9e6084a
main
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 ( "//3rdparty/crates:defs.bzl" , "crate_repositories" ) 20 21WASM_BINDGEN_VERSION = "0.2.92" 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 29Returns: 30list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories 31defined by this macro. 32""" 33 34direct_deps = [ 35struct ( repo = "rules_rust_wasm_bindgen_cli" , is_dev_dep = False ), 36] 37maybe ( 38http_archive , 39name = "rules_rust_wasm_bindgen_cli" , 40sha256 = "08f61e21873f51e3059a8c7c3eef81ede7513d161cfc60751c7b2ffa6ed28270" , 41urls = [ "https://static.crates.io/crates/wasm-bindgen-cli/wasm-bindgen-cli-{}.crate" . format ( WASM_BINDGEN_VERSION )], 42type = "tar.gz" , 43strip_prefix = "wasm-bindgen-cli-{}" . format ( WASM_BINDGEN_VERSION ), 44build_file = Label ( "//3rdparty:BUILD.wasm-bindgen-cli.bazel" ), 45patch_args = [ "-p1" ], 46patches = [ Label ( "//3rdparty/patches:resolver.patch" )], 47) 48 49direct_deps . extend ( crate_repositories ()) 50return direct_deps 51 52# buildifier: disable=unnamed-macro 53def rust_wasm_bindgen_register_toolchains ( register_toolchains = True ): 54"""Registers the default toolchains for the `rules_rust` [wasm-bindgen][wb] rules. 55 56[wb]: https://github.com/rustwasm/wasm-bindgen 57 58Args: 59register_toolchains (bool, optional): Whether or not to register toolchains. 60""" 61 62if register_toolchains : 63native . register_toolchains ( str ( Label ( "//:default_wasm_bindgen_toolchain" ))) 64 65# buildifier: disable=unnamed-macro 66def rust_wasm_bindgen_repositories ( register_default_toolchain = True ): 67"""Declare dependencies needed for [rust_wasm_bindgen](#rust_wasm_bindgen). 68 69**Deprecated**: Use [rust_wasm_bindgen_dependencies](#rust_wasm_bindgen_depednencies) and [rust_wasm_bindgen_register_toolchains](#rust_wasm_bindgen_register_toolchains). 70 71Args: 72register_default_toolchain (bool, optional): If True, the default [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) 73(`@rules_rust//:default_wasm_bindgen_toolchain`) is registered. This toolchain requires a set of dependencies 74that were generated using [crate_universe](https://github.com/bazelbuild/rules_rust/tree/main/crate_universe). These will also be loaded. 75""" 76 77rust_wasm_bindgen_dependencies () 78 79rust_wasm_bindgen_register_toolchains ( register_toolchains = register_default_toolchain )