Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for producing distribution archives #1194

Merged
merged 6 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ alias(
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
13 changes: 13 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@ 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()
10 changes: 10 additions & 0 deletions bindgen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ alias(
deprecation = "Please use the `@rules_rust//bindgen:bzl_lib` target instead",
)

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

rust_bindgen_toolchain(
name = "default_bindgen_toolchain_impl",
bindgen = "//bindgen/raze:cargo_bin_bindgen",
Expand Down
11 changes: 11 additions & 0 deletions cargo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ alias(
actual = ":bzl_lib",
deprecation = "Please use the `@rules_rust//cargo:bzl_lib` target instead",
)

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

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
"bootstrap_installer.rs",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions cargo/cargo_build_script_runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ rust_test(
crate = ":cargo_build_script_runner",
deps = [":cargo_build_script_runner"],
)

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

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
33 changes: 33 additions & 0 deletions distro/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@rules_pkg//:pkg.bzl", "pkg_tar")

pkg_tar(
name = "rules_rust",
srcs = ["//:distro"],
extension = "tar.gz",
mode = "0444",
# Make it owned by root so it does not have the uid of the CI robot.
owner = "0.0",
package_dir = ".",
strip_prefix = ".",
visibility = ["//:__subpackages__"],
)

# This filegroup allows the tar file to appear in runfiles
# https://github.com/bazelbuild/bazel/issues/12348
filegroup(
name = "distro",
srcs = [":rules_rust"],
visibility = ["//:__subpackages__"],
)

sh_binary(
name = "publish",
srcs = ["publisher.sh"],
data = [":distro"],
env = {"ARCHIVE": "$(rootpath :distro)"},
target_compatible_with = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
)
10 changes: 10 additions & 0 deletions distro/publisher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

ABS_ARCHIVE="$(pwd)/${ARCHIVE}"
cd "${BUILD_WORKING_DIRECTORY}"
mkdir -p "$@"

set -x
cp -fp "${ABS_ARCHIVE}" "$@"/"$(basename "${ARCHIVE}")"
14 changes: 14 additions & 0 deletions proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ alias(
actual = "//proto/raze:cargo_bin_protoc_gen_rust_grpc",
)

filegroup(
name = "distro",
srcs = glob([
"*.bzl",
"*.rs",
]) + [
"//proto/raze:srcs",
"//proto/raze/remote:srcs",
"//proto/patches:distro",
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)

toolchain_type(name = "toolchain")

rust_binary(
Expand Down
9 changes: 9 additions & 0 deletions proto/patches/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ package(default_visibility = ["//visibility:public"])
exports_files([
"com_google_protobuf-v3.10.0-bzl_visibility.patch",
])

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
"com_google_protobuf-v3.10.0-bzl_visibility.patch",
],
visibility = ["//:__subpackages__"],
)
12 changes: 12 additions & 0 deletions rust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,15 @@ alias(
actual = ":bzl_lib",
deprecation = "Please use the `@rules_rust//rust:bzl_lib` target instead",
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"//rust/platform:distro",
"//rust/private:distro",
"//rust/settings:distro",
"//rust/toolchain:distro",
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
11 changes: 11 additions & 0 deletions rust/platform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ alias(
deprecation = "Please use the `@rules_rust//platform:bzl_lib` target instead",
visibility = ["//rust:__subpackages__"],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"//rust/platform/channel:distro",
"//rust/platform/cpu:distro",
"//rust/platform/os:distro",
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions rust/platform/channel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ constraint_value(
name = "stable",
constraint_setting = ":channel",
)

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions rust/platform/cpu/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ constraint_value(
constraint_setting = "@platforms//cpu",
visibility = ["//visibility:public"],
)

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions rust/platform/os/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ constraint_value(
constraint_setting = "@platforms//os",
visibility = ["//visibility:public"],
)

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
9 changes: 9 additions & 0 deletions rust/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ alias(
visibility = ["//rust:__subpackages__"],
)

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

stamp_build_setting(name = "stamp")

rust_analyzer_detect_sysroot(
Expand Down
8 changes: 8 additions & 0 deletions rust/private/dummy_cc_toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ toolchain(
toolchain = ":dummy_cc_wasm32",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions rust/settings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ alias(
deprecation = "Please use the `@rules_rust//settings:bzl_lib` target instead",
visibility = ["//rust:__subpackages__"],
)

filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions rust/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ toolchain_files(
name = "current_exec_rust_stdlib_files",
tool = "rust_stdlib",
)

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
12 changes: 12 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
filegroup(
name = "distro",
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
"//tools/allowlists/function_transition_allowlist:distro",
"//tools/clippy:distro",
"//tools/runfiles:distro",
"//tools/rustdoc:distro",
"//tools/rustfmt:distro",
],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions tools/allowlists/function_transition_allowlist/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ package_group(
name = "function_transition_allowlist",
packages = ["//..."],
)

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
9 changes: 9 additions & 0 deletions tools/clippy/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
exports_files(["clippy.toml"])

filegroup(
name = "distro",
srcs = [
"BUILD.bazel",
"clippy.toml",
],
visibility = ["//:__subpackages__"],
)
11 changes: 11 additions & 0 deletions tools/runfiles/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ rust_doc_test(
name = "runfiles_doc_test",
crate = ":runfiles",
)

filegroup(
name = "distro",
srcs = glob([
"data/**",
"**/*.rs",
]) + [
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
13 changes: 13 additions & 0 deletions tools/rust_analyzer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@ rust_clippy(
":gen_rust_project",
],
)

filegroup(
name = "distro",
srcs = glob([
"*.bzl",
"**/*.rs",
]) + [
"//tools/rust_analyzer/raze:srcs",
"//tools/rust_analyzer/raze/remote:srcs",
"BUILD.bazel",
],
visibility = ["//:__subpackages__"],
)
10 changes: 10 additions & 0 deletions tools/rustdoc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ rust_binary(
"//tools/runfiles",
],
)

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