Skip to content

Commit cd44b36

Browse files
authored
Added support for producing distribution archives (#1194)
1 parent a665447 commit cd44b36

File tree

33 files changed

+364
-0
lines changed

33 files changed

+364
-0
lines changed

BUILD.bazel

+19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ alias(
1818
visibility = ["//visibility:public"],
1919
)
2020

21+
filegroup(
22+
name = "distro",
23+
srcs = glob(["*.bzl"]) + [
24+
"//bindgen:distro",
25+
"//cargo:distro",
26+
"//crate_universe:distro",
27+
"//proto:distro",
28+
"//rust:distro",
29+
"//tools:distro",
30+
"//util:distro",
31+
"//wasm_bindgen:distro",
32+
"BUILD.bazel",
33+
"README.md",
34+
"LICENSE.txt",
35+
"WORKSPACE.bazel",
36+
],
37+
visibility = ["//:__subpackages__"],
38+
)
39+
2140
# This setting may be changed from the command line to generate machine readable errors.
2241
error_format(
2342
name = "error_format",

WORKSPACE.bazel

+13
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,16 @@ http_archive(
5757
#
5858
# load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
5959
# rbe_preconfig(name = "buildkite_config", toolchain = "ubuntu1604-bazel-java8")
60+
61+
http_archive(
62+
name = "rules_pkg",
63+
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
64+
urls = [
65+
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
66+
"https://github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
67+
],
68+
)
69+
70+
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
71+
72+
rules_pkg_dependencies()

bindgen/BUILD.bazel

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ alias(
1717
deprecation = "Please use the `@rules_rust//bindgen:bzl_lib` target instead",
1818
)
1919

20+
filegroup(
21+
name = "distro",
22+
srcs = glob(["*.bzl"]) + [
23+
"//bindgen/raze:srcs",
24+
"//bindgen/raze/remote:srcs",
25+
"BUILD.bazel",
26+
],
27+
visibility = ["//:__subpackages__"],
28+
)
29+
2030
rust_bindgen_toolchain(
2131
name = "default_bindgen_toolchain_impl",
2232
bindgen = "//bindgen/raze:cargo_bin_bindgen",

cargo/BUILD.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,14 @@ alias(
1313
actual = ":bzl_lib",
1414
deprecation = "Please use the `@rules_rust//cargo:bzl_lib` target instead",
1515
)
16+
17+
filegroup(
18+
name = "distro",
19+
srcs = glob(["*.bzl"]) + [
20+
"//cargo/bootstrap:distro",
21+
"//cargo/cargo_build_script_runner:distro",
22+
"//cargo/private:distro",
23+
"BUILD.bazel",
24+
],
25+
visibility = ["//:__subpackages__"],
26+
)

cargo/bootstrap/BUILD.bazel

+9
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ rust_binary(
1818
"RULES_RUST_CARGO_BOOTSTRAP_BINARY": "$(rootpath bootstrap_installer.rs)",
1919
},
2020
)
21+
22+
filegroup(
23+
name = "distro",
24+
srcs = [
25+
"BUILD.bazel",
26+
"bootstrap_installer.rs",
27+
],
28+
visibility = ["//:__subpackages__"],
29+
)

cargo/cargo_build_script_runner/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ rust_test(
2222
crate = ":cargo_build_script_runner",
2323
deps = [":cargo_build_script_runner"],
2424
)
25+
26+
filegroup(
27+
name = "distro",
28+
srcs = glob(["*.rs"]) + [
29+
"BUILD.bazel",
30+
],
31+
visibility = ["//:__subpackages__"],
32+
)

cargo/private/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ bzl_library(
55
srcs = glob(["**/*.bzl"]),
66
visibility = ["//:__subpackages__"],
77
)
8+
9+
filegroup(
10+
name = "distro",
11+
srcs = glob(["*.bzl"]) + [
12+
"BUILD.bazel",
13+
],
14+
visibility = ["//:__subpackages__"],
15+
)

distro/BUILD.bazel

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
load("@rules_pkg//:pkg.bzl", "pkg_tar")
2+
3+
pkg_tar(
4+
name = "rules_rust",
5+
srcs = ["//:distro"],
6+
extension = "tar.gz",
7+
mode = "0444",
8+
# Make it owned by root so it does not have the uid of the CI robot.
9+
owner = "0.0",
10+
package_dir = ".",
11+
strip_prefix = ".",
12+
visibility = ["//:__subpackages__"],
13+
)
14+
15+
# This filegroup allows the tar file to appear in runfiles
16+
# https://github.com/bazelbuild/bazel/issues/12348
17+
filegroup(
18+
name = "distro",
19+
srcs = [":rules_rust"],
20+
visibility = ["//:__subpackages__"],
21+
)
22+
23+
sh_binary(
24+
name = "publish",
25+
srcs = ["publisher.sh"],
26+
data = [":distro"],
27+
env = {"ARCHIVE": "$(rootpath :distro)"},
28+
target_compatible_with = select({
29+
"@platforms//os:linux": [],
30+
"@platforms//os:macos": [],
31+
"//conditions:default": ["@platforms//:incompatible"],
32+
}),
33+
)

distro/publisher.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
ABS_ARCHIVE="$(pwd)/${ARCHIVE}"
6+
cd "${BUILD_WORKING_DIRECTORY}"
7+
mkdir -p "$@"
8+
9+
set -x
10+
cp -fp "${ABS_ARCHIVE}" "$@"/"$(basename "${ARCHIVE}")"

proto/BUILD.bazel

+14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ alias(
1414
actual = "//proto/raze:cargo_bin_protoc_gen_rust_grpc",
1515
)
1616

17+
filegroup(
18+
name = "distro",
19+
srcs = glob([
20+
"*.bzl",
21+
"*.rs",
22+
]) + [
23+
"//proto/raze:srcs",
24+
"//proto/raze/remote:srcs",
25+
"//proto/patches:distro",
26+
"BUILD.bazel",
27+
],
28+
visibility = ["//:__subpackages__"],
29+
)
30+
1731
toolchain_type(name = "toolchain")
1832

1933
rust_binary(

proto/patches/BUILD.bazel

+9
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@ package(default_visibility = ["//visibility:public"])
33
exports_files([
44
"com_google_protobuf-v3.10.0-bzl_visibility.patch",
55
])
6+
7+
filegroup(
8+
name = "distro",
9+
srcs = [
10+
"BUILD.bazel",
11+
"com_google_protobuf-v3.10.0-bzl_visibility.patch",
12+
],
13+
visibility = ["//:__subpackages__"],
14+
)

rust/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ alias(
2828
actual = ":bzl_lib",
2929
deprecation = "Please use the `@rules_rust//rust:bzl_lib` target instead",
3030
)
31+
32+
filegroup(
33+
name = "distro",
34+
srcs = glob(["*.bzl"]) + [
35+
"//rust/platform:distro",
36+
"//rust/private:distro",
37+
"//rust/settings:distro",
38+
"//rust/toolchain:distro",
39+
"BUILD.bazel",
40+
],
41+
visibility = ["//:__subpackages__"],
42+
)

rust/platform/BUILD.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ alias(
2424
deprecation = "Please use the `@rules_rust//platform:bzl_lib` target instead",
2525
visibility = ["//rust:__subpackages__"],
2626
)
27+
28+
filegroup(
29+
name = "distro",
30+
srcs = glob(["*.bzl"]) + [
31+
"//rust/platform/channel:distro",
32+
"//rust/platform/cpu:distro",
33+
"//rust/platform/os:distro",
34+
"BUILD.bazel",
35+
],
36+
visibility = ["//:__subpackages__"],
37+
)

rust/platform/channel/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ constraint_value(
2020
name = "stable",
2121
constraint_setting = ":channel",
2222
)
23+
24+
filegroup(
25+
name = "distro",
26+
srcs = [
27+
"BUILD.bazel",
28+
],
29+
visibility = ["//:__subpackages__"],
30+
)

rust/platform/cpu/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ constraint_value(
33
constraint_setting = "@platforms//cpu",
44
visibility = ["//visibility:public"],
55
)
6+
7+
filegroup(
8+
name = "distro",
9+
srcs = [
10+
"BUILD.bazel",
11+
],
12+
visibility = ["//:__subpackages__"],
13+
)

rust/platform/os/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ constraint_value(
99
constraint_setting = "@platforms//os",
1010
visibility = ["//visibility:public"],
1111
)
12+
13+
filegroup(
14+
name = "distro",
15+
srcs = [
16+
"BUILD.bazel",
17+
],
18+
visibility = ["//:__subpackages__"],
19+
)

rust/private/BUILD.bazel

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ alias(
1616
visibility = ["//rust:__subpackages__"],
1717
)
1818

19+
filegroup(
20+
name = "distro",
21+
srcs = glob(["*.bzl"]) + [
22+
"//rust/private/dummy_cc_toolchain:distro",
23+
"BUILD.bazel",
24+
],
25+
visibility = ["//:__subpackages__"],
26+
)
27+
1928
stamp_build_setting(name = "stamp")
2029

2130
rust_analyzer_detect_sysroot(

rust/private/dummy_cc_toolchain/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ toolchain(
1111
toolchain = ":dummy_cc_wasm32",
1212
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
1313
)
14+
15+
filegroup(
16+
name = "distro",
17+
srcs = glob(["*.bzl"]) + [
18+
"BUILD.bazel",
19+
],
20+
visibility = ["//:__subpackages__"],
21+
)

rust/settings/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ alias(
4040
deprecation = "Please use the `@rules_rust//settings:bzl_lib` target instead",
4141
visibility = ["//rust:__subpackages__"],
4242
)
43+
44+
filegroup(
45+
name = "distro",
46+
srcs = glob(["*.bzl"]) + [
47+
"BUILD.bazel",
48+
],
49+
visibility = ["//:__subpackages__"],
50+
)

rust/toolchain/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ toolchain_files(
4141
name = "current_exec_rust_stdlib_files",
4242
tool = "rust_stdlib",
4343
)
44+
45+
filegroup(
46+
name = "distro",
47+
srcs = [
48+
"BUILD.bazel",
49+
],
50+
visibility = ["//:__subpackages__"],
51+
)

tools/BUILD.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
filegroup(
2+
name = "distro",
3+
srcs = glob(["*.bzl"]) + [
4+
"BUILD.bazel",
5+
"//tools/allowlists/function_transition_allowlist:distro",
6+
"//tools/clippy:distro",
7+
"//tools/runfiles:distro",
8+
"//tools/rustdoc:distro",
9+
"//tools/rustfmt:distro",
10+
],
11+
visibility = ["//:__subpackages__"],
12+
)

tools/allowlists/function_transition_allowlist/BUILD.bazel

+8
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@ package_group(
22
name = "function_transition_allowlist",
33
packages = ["//..."],
44
)
5+
6+
filegroup(
7+
name = "distro",
8+
srcs = [
9+
"BUILD.bazel",
10+
],
11+
visibility = ["//:__subpackages__"],
12+
)

tools/clippy/BUILD.bazel

+9
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
exports_files(["clippy.toml"])
2+
3+
filegroup(
4+
name = "distro",
5+
srcs = [
6+
"BUILD.bazel",
7+
"clippy.toml",
8+
],
9+
visibility = ["//:__subpackages__"],
10+
)

tools/runfiles/BUILD.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ rust_doc_test(
2121
name = "runfiles_doc_test",
2222
crate = ":runfiles",
2323
)
24+
25+
filegroup(
26+
name = "distro",
27+
srcs = glob([
28+
"data/**",
29+
"**/*.rs",
30+
]) + [
31+
"BUILD.bazel",
32+
],
33+
visibility = ["//:__subpackages__"],
34+
)

tools/rust_analyzer/BUILD.bazel

+13
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,16 @@ rust_clippy(
5454
":gen_rust_project",
5555
],
5656
)
57+
58+
filegroup(
59+
name = "distro",
60+
srcs = glob([
61+
"*.bzl",
62+
"**/*.rs",
63+
]) + [
64+
"//tools/rust_analyzer/raze:srcs",
65+
"//tools/rust_analyzer/raze/remote:srcs",
66+
"BUILD.bazel",
67+
],
68+
visibility = ["//:__subpackages__"],
69+
)

tools/rustdoc/BUILD.bazel

+10
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ rust_binary(
1010
"//tools/runfiles",
1111
],
1212
)
13+
14+
filegroup(
15+
name = "distro",
16+
srcs = glob([
17+
"**/*.rs",
18+
]) + [
19+
"BUILD.bazel",
20+
],
21+
visibility = ["//:__subpackages__"],
22+
)

0 commit comments

Comments
 (0)