From 454860abf8dd3e6b2c407e5d7963f882f06be28c Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Tue, 2 Feb 2021 13:18:57 +0100 Subject: [PATCH] Add //rust/private/BUILD (therefore create a package there) --- bindgen/bindgen.bzl | 1 + cargo/cargo_build_script.bzl | 3 +++ rust/BUILD | 1 - rust/private/rustdoc.bzl | 2 ++ rust/private/rustdoc_test.bzl | 2 ++ rust/rust_common.bzl | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 rust/rust_common.bzl diff --git a/bindgen/bindgen.bzl b/bindgen/bindgen.bzl index 7644f78bb8..fb674b6ec6 100644 --- a/bindgen/bindgen.bzl +++ b/bindgen/bindgen.bzl @@ -14,6 +14,7 @@ # buildifier: disable=module-docstring load("//rust:rust.bzl", "rust_library") +load("//rust/private:utils.bzl", "find_toolchain", "get_libs_for_static_executable") # buildifier: disable=bzl-visibility load("//rust/private:utils.bzl", "find_toolchain", "get_libs_for_static_executable") diff --git a/cargo/cargo_build_script.bzl b/cargo/cargo_build_script.bzl index 099785c280..ac5919fc02 100644 --- a/cargo/cargo_build_script.bzl +++ b/cargo/cargo_build_script.bzl @@ -2,6 +2,9 @@ load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "C_COMPILE_ACTION_NAME") load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") load("//rust:rust.bzl", "rust_binary") +load("//rust/private:rust.bzl", "name_to_crate_name") +load("//rust/private:rustc.bzl", "BuildInfo", "DepInfo", "get_cc_toolchain", "get_compilation_mode_opts", "get_linker_and_args") +load("//rust/private:utils.bzl", "expand_locations", "find_toolchain") # buildifier: disable=bzl-visibility load("//rust/private:rust.bzl", "name_to_crate_name") diff --git a/rust/BUILD b/rust/BUILD index d38e41a8ca..c2c48d59ea 100644 --- a/rust/BUILD +++ b/rust/BUILD @@ -15,7 +15,6 @@ toolchain_type( bzl_library( name = "rules", - srcs = glob(["**/*.bzl"]), deps = [ "//rust/platform:rules", "//rust/private:rules", diff --git a/rust/private/rustdoc.bzl b/rust/private/rustdoc.bzl index 7792d638d9..715a9de807 100644 --- a/rust/private/rustdoc.bzl +++ b/rust/private/rustdoc.bzl @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("//rust:rust_common.bzl", "CrateInfo") + # buildifier: disable=module-docstring load("//rust/private:common.bzl", "rust_common") load("//rust/private:rustc.bzl", "DepInfo", "add_crate_link_flags", "add_edition_flags") diff --git a/rust/private/rustdoc_test.bzl b/rust/private/rustdoc_test.bzl index fbaf7d5825..e45ea6cee5 100644 --- a/rust/private/rustdoc_test.bzl +++ b/rust/private/rustdoc_test.bzl @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("//rust:rust_common.bzl", "CrateInfo") + # buildifier: disable=module-docstring load("//rust/private:common.bzl", "rust_common") load("//rust/private:rustc.bzl", "DepInfo") diff --git a/rust/rust_common.bzl b/rust/rust_common.bzl new file mode 100644 index 0000000000..d23e51356f --- /dev/null +++ b/rust/rust_common.bzl @@ -0,0 +1,32 @@ +# Copyright 2015 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Module with Rust definitions required to write custom Rust rules.""" + +CrateInfo = provider( + doc = "A provider containing general Crate information.", + fields = { + "aliases": "Dict[Label, String]: Renamed and aliased crates", + "deps": "List[Provider]: This crate's (rust or cc) dependencies' providers.", + "edition": "str: The edition of this crate.", + "is_test": "bool: If the crate is being compiled in a test context", + "name": "str: The name of this crate.", + "output": "File: The output File that will be produced, depends on crate type.", + "proc_macro_deps": "List[CrateInfo]: This crate's rust proc_macro dependencies' providers.", + "root": "File: The source File entrypoint to this crate, eg. lib.rs", + "rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.", + "srcs": "List[File]: All source Files that are part of the crate.", + "type": "str: The type of this crate. eg. lib or bin", + }, +)