fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
120f911d
0.7.0
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 ( "//bindgen/raze:crates.bzl" , "rules_rust_bindgen_fetch_remote_crates" ) 19 20# buildifier: disable=unnamed-macro 21def rust_bindgen_dependencies (): 22"""Declare dependencies needed for bindgen.""" 23 24# nb. The bindgen rule itself should work on any platform. 25_bindgen_clang_repositories () 26 27rules_rust_bindgen_fetch_remote_crates () 28 29# buildifier: disable=unnamed-macro 30def rust_bindgen_register_toolchains ( register_toolchains = True ): 31"""Registers the default toolchains for the `rules_rust` [bindgen][bg] rules. 32 33[bg]: https://rust-lang.github.io/rust-bindgen/ 34 35Args: 36register_toolchains (bool, optional): Whether or not to register toolchains. 37""" 38if register_toolchains : 39native . register_toolchains ( str ( Label ( "//bindgen:default_bindgen_toolchain" ))) 40 41# buildifier: disable=unnamed-macro 42def rust_bindgen_repositories (): 43"""**Deprecated**: Instead use [rust_bindgen_dependencies](#rust_bindgen_dependencies) and [rust_bindgen_register_toolchains](#rust_bindgen_register_toolchains)""" 44 45rust_bindgen_dependencies () 46rust_bindgen_register_toolchains () 47 48_COMMON_WORKSPACE = """\ 49workspace(name = "{}") 50 51load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 52 53http_archive( 54name = "rules_cc", 55urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.1/rules_cc-0.0.1.tar.gz"], 56sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241", 57) 58""" 59 60_CLANG_BUILD_FILE = """\ 61load("@rules_cc//cc:defs.bzl", "cc_import") 62 63package(default_visibility = ["//visibility:public"]) 64 65sh_binary( 66name = "clang", 67srcs = ["bin/clang"], 68) 69 70cc_import( 71name = "libclang", 72shared_library = "lib/libclang.{suffix}", 73) 74 75alias( 76name = "libclang.so", 77actual = ":libclang", 78deprecation = "Use :libclang instead", 79) 80 81cc_import( 82name = "libc++", 83shared_library = "lib/libc++.{suffix}" 84) 85""" 86 87def _bindgen_clang_repositories (): 88# Releases @ http://releases.llvm.org/download.html 89maybe ( 90http_archive , 91name = "bindgen_clang_linux" , 92urls = [ "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz" ], 93strip_prefix = "clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04" , 94sha256 = "b25f592a0c00686f03e3b7db68ca6dc87418f681f4ead4df4745a01d9be63843" , 95build_file_content = _CLANG_BUILD_FILE . format ( suffix = "so" ), 96workspace_file_content = _COMMON_WORKSPACE . format ( "bindgen_clang_linux" ), 97) 98 99maybe ( 100http_archive , 101name = "bindgen_clang_osx" , 102urls = [ "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz" ], 103strip_prefix = "clang+llvm-10.0.0-x86_64-apple-darwin" , 104sha256 = "633a833396bf2276094c126b072d52b59aca6249e7ce8eae14c728016edb5e61" , 105build_file_content = _CLANG_BUILD_FILE . format ( suffix = "dylib" ), 106workspace_file_content = _COMMON_WORKSPACE . format ( "bindgen_clang_osx" ), 107)