Skip to content

Commit

Permalink
Merge remote-tracking branch 'roman/roman-src-path-prefix' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Jude Taylor committed Aug 24, 2022
2 parents 547345a + dab2520 commit 7d5eba0
Show file tree
Hide file tree
Showing 508 changed files with 20,977 additions and 13,007 deletions.
14 changes: 13 additions & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ default_windows_targets: &default_windows_targets
- "//..."
- "-//bindgen/..."
- "-//test/proto/..."
- "-//tools/rust_analyzer/..."
- "-//test/unit/pipelined_compilation/..."
crate_universe_vendor_example_targets: &crate_universe_vendor_example_targets
- "//vendor_external:crates_vendor"
- "//vendor_local_manifests:crates_vendor"
Expand Down Expand Up @@ -333,6 +333,18 @@ tasks:
- "//..."
test_targets:
- "//..."
cc_common_link_ubuntu2004:
name: Build via cc_common.link
platform: ubuntu2004
working_directory: test/cc_common_link
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--@rules_rust//rust/settings:experimental_use_cc_common_link=True"


buildifier:
version: latest
warnings: "all"
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docs
examples
crate_universe/private/bootstrap
test/cc_common_link
5 changes: 3 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ jobs:
run: |
# Update urls and sha256 values
bazel ${BAZEL_STARTUP_FLAGS[@]} run //crate_universe/tools/urls_generator -- --artifacts-dir="${ARTIFACTS_DIR}" --url-prefix="${URL_PREFIX}"
# Publish to a known location
bazel ${BAZEL_STARTUP_FLAGS[@]} run //distro:publish -- ${{ github.workspace }}/.github
bazel clean
# Build an archive of the repo contents
tar -czf ${{ github.workspace }}/.github/rules_rust.tar.gz --exclude=".git" --exclude=".github" --exclude="examples" -C ${{ github.workspace }} .
# Save the sha256 checksum of the distro archive to the environment
sha256="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_rust.tar.gz | awk '{ print $1 }')"
echo "ARCHIVE_SHA256=${sha256}" >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/examples/cargo_manifest_dir/external_crate/bazel-*
/examples/crate_universe/bazel-*
/examples/crate_universe/*/bazel-*
/test/cc_common_link/bazel-*
/docs/bazel-*
user.bazelrc

Expand Down
30 changes: 10 additions & 20 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//rust:defs.bzl", "capture_clippy_output", "clippy_flags", "error_format", "extra_exec_rustc_flag", "extra_exec_rustc_flags", "extra_rustc_flag", "extra_rustc_flags", "is_proc_macro_dep", "is_proc_macro_dep_enabled")
load("//rust:defs.bzl", "capture_clippy_output", "clippy_flags", "error_format", "extra_exec_rustc_flag", "extra_exec_rustc_flags", "extra_rustc_flag", "extra_rustc_flags", "is_proc_macro_dep", "is_proc_macro_dep_enabled", "source_path_prefix")

exports_files(["LICENSE"])

Expand All @@ -11,25 +11,6 @@ bzl_library(
visibility = ["//visibility:public"],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"//bindgen:distro",
"//cargo:distro",
"//crate_universe:distro",
"//proto:distro",
"//rust:distro",
"//tools:distro",
"//util:distro",
"//wasm_bindgen:distro",
"BUILD.bazel",
"README.md",
"LICENSE.txt",
"WORKSPACE.bazel",
],
visibility = ["//:__subpackages__"],
)

# This setting may be changed from the command line to generate machine readable errors.
error_format(
name = "error_format",
Expand Down Expand Up @@ -95,6 +76,15 @@ extra_exec_rustc_flag(
visibility = ["//visibility:public"],
)

# This setting may be used to override the prefix for source paths rustc embeds into build artifacts.
# Setting this setting to a fixed value (e.g., "/source/") can help achieve reproducible builds and
# improve cache utilization.
source_path_prefix(
name = "source_path_prefix",
build_setting_default = ".",
visibility = ["//visibility:public"],
)

# This setting is used by the clippy rules. See https://bazelbuild.github.io/rules_rust/rust_clippy.html
label_flag(
name = "clippy.toml",
Expand Down
13 changes: 0 additions & 13 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,3 @@ http_archive(
#
# load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
# rbe_preconfig(name = "buildkite_config", toolchain = "ubuntu1604-bazel-java8")

http_archive(
name = "rules_pkg",
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
],
)

load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")

rules_pkg_dependencies()
12 changes: 0 additions & 12 deletions bindgen/3rdparty/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,3 @@ bzl_library(
],
visibility = ["//bindgen:__pkg__"],
)

filegroup(
name = "distro",
srcs = glob([
"*.bzl",
"*.bazel",
]) + [
"//bindgen/3rdparty/crates:srcs",
"Cargo.Bazel.lock",
],
visibility = ["//bindgen:__pkg__"],
)
22 changes: 11 additions & 11 deletions bindgen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ load("//bindgen:bindgen.bzl", "rust_bindgen_toolchain")

package(default_visibility = ["//visibility:public"])

toolchain_type(name = "bindgen_toolchain")
toolchain_type(
name = "toolchain_type",
)

alias(
name = "bindgen_toolchain",
actual = "toolchain_type",
deprecation = "instead use `@rules_rust//bindgen:toolchain_type`",
tags = ["manual"],
)

bzl_library(
name = "bzl_lib",
Expand All @@ -14,15 +23,6 @@ bzl_library(
],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"//bindgen/3rdparty:distro",
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)

rust_bindgen_toolchain(
name = "default_bindgen_toolchain_impl",
bindgen = "//bindgen/3rdparty:bindgen",
Expand All @@ -43,5 +43,5 @@ rust_bindgen_toolchain(
toolchain(
name = "default_bindgen_toolchain",
toolchain = "default_bindgen_toolchain_impl",
toolchain_type = "//bindgen:bindgen_toolchain",
toolchain_type = "//bindgen:toolchain_type",
)
8 changes: 4 additions & 4 deletions bindgen/bindgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _rust_bindgen_impl(ctx):
if header not in cc_header_list:
fail("Header {} is not in {}'s transitive headers.".format(ctx.attr.header, cc_lib), "header")

toolchain = ctx.toolchains[Label("//bindgen:bindgen_toolchain")]
toolchain = ctx.toolchains[Label("//bindgen:toolchain_type")]
bindgen_bin = toolchain.bindgen
rustfmt_bin = toolchain.rustfmt or rust_toolchain.rustfmt
clang_bin = toolchain.clang
Expand Down Expand Up @@ -214,8 +214,8 @@ rust_bindgen = rule(
outputs = {"out": "%{name}.rs"},
fragments = ["cpp"],
toolchains = [
str(Label("//bindgen:bindgen_toolchain")),
str(Label("//rust:toolchain")),
str(Label("//bindgen:toolchain_type")),
str(Label("//rust:toolchain_type")),
"@bazel_tools//tools/cpp:toolchain_type",
],
incompatible_use_toolchain_transition = True,
Expand Down Expand Up @@ -253,7 +253,7 @@ rust_bindgen_toolchain(
toolchain(
name = "bindgen_toolchain",
toolchain = "bindgen_toolchain_impl",
toolchain_type = "@rules_rust//bindgen:bindgen_toolchain",
toolchain_type = "@rules_rust//bindgen:toolchain_type",
)
```
Expand Down
11 changes: 0 additions & 11 deletions cargo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,3 @@ bzl_library(
srcs = glob(["**/*.bzl"]),
deps = ["//cargo/private:bzl_lib"],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"//cargo/bootstrap:distro",
"//cargo/cargo_build_script_runner:distro",
"//cargo/private:distro",
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
9 changes: 0 additions & 9 deletions cargo/bootstrap/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,3 @@ rust_binary(
"RULES_RUST_CARGO_BOOTSTRAP_BINARY": "$(rootpath bootstrap_installer.rs)",
},
)

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
"bootstrap_installer.rs",
],
visibility = ["//:__subpackages__"],
)
2 changes: 1 addition & 1 deletion cargo/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ _build_script_run = rule(
},
fragments = ["cpp"],
toolchains = [
str(Label("//rust:toolchain")),
str(Label("//rust:toolchain_type")),
"@bazel_tools//tools/cpp:toolchain_type",
],
incompatible_use_toolchain_transition = True,
Expand Down
8 changes: 0 additions & 8 deletions cargo/cargo_build_script_runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,3 @@ rust_test(
edition = "2018",
deps = [":cargo_build_script_runner"],
)

filegroup(
name = "distro",
srcs = glob(["*.rs"]) + [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
8 changes: 0 additions & 8 deletions cargo/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,3 @@ bzl_library(
srcs = glob(["**/*.bzl"]),
visibility = ["//:__subpackages__"],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
12 changes: 0 additions & 12 deletions crate_universe/3rdparty/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ crates_vendor(
vendor_path = "crates",
)

filegroup(
name = "distro",
srcs = glob([
"*.bzl",
"*.bazel",
]) + [
"Cargo.Bazel.lock",
"cargo-bazel-lock.json",
"//crate_universe/3rdparty/crates:srcs",
],
)

filegroup(
name = "bzl_srcs",
srcs = glob(["*.bzl"]) + [
Expand Down
22 changes: 0 additions & 22 deletions crate_universe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@ exports_files(
visibility = ["//visibility:public"],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
":rust_srcs",
"//crate_universe/3rdparty:distro",
"//crate_universe/private:distro",
"//crate_universe/tools:distro",
"BUILD.bazel",
"Cargo.lock",
"Cargo.toml",
"README.md",
],
visibility = ["//:__subpackages__"],
)

filegroup(
name = "bzl_srcs",
srcs = glob(["*.bzl"]) + [
Expand Down Expand Up @@ -124,11 +109,4 @@ rust_doc(
rust_doc_test(
name = "rustdoc_test",
crate = ":cargo_bazel",
# TODO: This target fails on some platforms with the error tracked in:
# https://github.com/bazelbuild/rules_rust/issues/1233
target_compatible_with = select({
"@platforms//os:macos": ["@platforms//:incompatible"],
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)
4 changes: 0 additions & 4 deletions crate_universe/docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Crate Universe is a set of Bazel rule for generating Rust targets using Cargo.
## Experimental
`crate_universe` is experimental, and may have breaking API changes at any time. These instructions may also change without notice.
## Setup
After loading `rules_rust` in your workspace, set the following to begin using `crate_universe`:
Expand Down
8 changes: 0 additions & 8 deletions crate_universe/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,3 @@ filegroup(
name = "bzl_srcs",
srcs = glob(["*.bzl"]),
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
"//crate_universe/private/vendor:distro",
],
)
2 changes: 1 addition & 1 deletion crate_universe/private/crates_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate")
crates_repository(
name = "crate_index",
annotations = annotations = {
annotations = {
"rand": [crate.annotation(
default_features = False,
features = ["small_rng"],
Expand Down
6 changes: 3 additions & 3 deletions crate_universe/private/crates_vendor.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _runfiles_path(path, is_windows):
return "{}/{}".format(runtime_pwd_var, path)

def _is_windows(ctx):
toolchain = ctx.toolchains[Label("@rules_rust//rust:toolchain")]
toolchain = ctx.toolchains[Label("@rules_rust//rust:toolchain_type")]
return "windows" in toolchain.target_triple

def _get_output_package(ctx):
Expand Down Expand Up @@ -175,7 +175,7 @@ def _write_config_file(ctx):
return args, runfiles

def _crates_vendor_impl(ctx):
toolchain = ctx.toolchains[Label("@rules_rust//rust:toolchain")]
toolchain = ctx.toolchains[Label("@rules_rust//rust:toolchain_type")]
is_windows = _is_windows(ctx)

environ = {
Expand Down Expand Up @@ -400,7 +400,7 @@ call against the generated workspace. The following table describes how to contr
),
},
executable = True,
toolchains = ["@rules_rust//rust:toolchain"],
toolchains = ["@rules_rust//rust:toolchain_type"],
)

def _crates_vendor_remote_repository_impl(repository_ctx):
Expand Down
8 changes: 0 additions & 8 deletions crate_universe/private/vendor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
load("//crate_universe/private:vendor_utils.bzl", "crates_vendor_deps_targets")

crates_vendor_deps_targets()

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
],
visibility = ["//crate_universe/private:__subpackages__"],
)
Loading

0 comments on commit 7d5eba0

Please sign in to comment.