Skip to content

Commit 4d02da4

Browse files
committed
Overhauling from other repos
1 parent c964fb4 commit 4d02da4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1426
-622
lines changed

.bazelrc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
# Bazel settings that apply to this repository.
2-
# Take care to document any settings that you expect users to apply.
3-
# Settings that apply only to CI are in .github/workflows/ci.bazelrc
1+
import %workspace%/bazel/defaults.bazelrc
42

53
test --test_output=errors
6-
7-
# TODO(alex): enable
8-
common --noenable_bzlmod
4+
common --enable_bzlmod
95

106
# Define value used by tests
117
build --define=SOME_VAR=SOME_VALUE
@@ -15,16 +11,22 @@ common --incompatible_enable_cc_toolchain_resolution
1511
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
1612
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
1713

18-
# Use local rules_python
19-
# Enable with --config=dev
20-
common:dev --override_repository=rules_python=~/workspace/rules_python
21-
# No external runfiles
22-
common --nolegacy_external_runfiles
14+
# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains.
15+
common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
16+
common --incompatible_enable_cc_toolchain_resolution
17+
18+
# Don't link against libunwind on macos as it causes linking failures (https://github.com/bazel-contrib/toolchains_llvm/pull/346)
19+
common:macos --@toolchains_llvm//toolchain/config:libunwind=False
20+
21+
common:ci --toolchain_resolution_debug='@@bazel_tools//tools/cpp:toolchain_type'
22+
23+
common:release --stamp
24+
common:release --compilation_mode=opt
25+
common:release --@rules_rust//rust/settings:lto=fat
2326

24-
# Don’t want to push a rules author to update their deps if not needed.
25-
# https://bazel.build/reference/command-line-reference#flag--check_direct_dependencies
26-
# https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0
27-
common --check_direct_dependencies=off
27+
# Speed up local development by using the non-hermetic CPP toolchain.
28+
common:nollvm --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
29+
common:nollvm --noincompatible_enable_cc_toolchain_resolution
2830

2931
# Load any settings specific to the current user.
3032
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members

MODULE.bazel

Lines changed: 11 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,19 @@ module(
1111
# py_image_layer requires 2.x for the `tar` rule.
1212
# py_image_layer needs compute_unused_inputs attribute
1313
# py_image_layer needs repo_mapping fix.
14-
bazel_dep(name = "aspect_bazel_lib", version = "2.16.0")
15-
bazel_dep(name = "aspect_tools_telemetry", version = "0.2.6")
1614
bazel_dep(name = "bazel_skylib", version = "1.4.2")
17-
bazel_dep(name = "rules_python", version = "0.29.0")
1815
bazel_dep(name = "platforms", version = "0.0.7")
19-
20-
bazel_lib = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
21-
bazel_lib.expand_template()
22-
23-
tel = use_extension("@aspect_tools_telemetry//:extension.bzl", "telemetry")
24-
use_repo(tel, "aspect_tools_telemetry_report")
25-
26-
# Custom python version for testing only
27-
python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
28-
python.toolchain(
29-
is_default = False,
30-
python_version = "3.9",
31-
)
16+
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
17+
bazel_dep(name = "bazelrc-preset.bzl", version = "1.2.0")
18+
19+
include("//bazel/include:bazel-lib.MODULE.bazel")
20+
include("//bazel/include:llvm.MODULE.bazel")
21+
include("//bazel/include:musl.MODULE.bazel")
22+
include("//bazel/include:oci.MODULE.bazel")
23+
include("//bazel/include:rust.MODULE.bazel")
24+
include("//bazel/include:telemetry.MODULE.bazel")
25+
include("//bazel/include:rules-python.MODULE.bazel")
26+
include("//bazel/include:release.MODULE.bazel")
3227

3328
tools = use_extension("//py:extensions.bzl", "py_tools")
3429
tools.rules_py_tools()
@@ -44,72 +39,3 @@ register_toolchains(
4439
"@aspect_rules_py//py/private/toolchain/unpack/...",
4540
"@aspect_rules_py//py/private/toolchain/shim/...",
4641
)
47-
48-
# To allow Rust binaries in /py/tools to be built from source
49-
# NOTE: when publishing to BCR, we patch these to be dev_dependency, as we publish pre-built binaries
50-
# along with our releases.
51-
52-
bazel_dep(
53-
name = "rules_rust",
54-
version = "0.53.0",
55-
# In released versions: dev_dependency = True
56-
)
57-
58-
rust = use_extension(
59-
"@rules_rust//rust:extensions.bzl",
60-
"rust",
61-
# In released versions: dev_dependency = True
62-
)
63-
rust.toolchain(
64-
edition = "2021",
65-
versions = ["1.81.0"],
66-
)
67-
use_repo(rust, "rust_toolchains")
68-
69-
register_toolchains(
70-
"@rust_toolchains//:all",
71-
# In released versions: dev_dependency = True
72-
)
73-
74-
crate = use_extension(
75-
"@rules_rust//crate_universe:extension.bzl",
76-
"crate",
77-
# In released versions: dev_dependency = True
78-
)
79-
crate.from_cargo(
80-
name = "crate_index",
81-
cargo_lockfile = "//:Cargo.lock",
82-
# Apparently not needed under bzlmod?
83-
# lockfile = "//:Cargo.Bazel.lock",
84-
manifests = [
85-
"//:Cargo.toml",
86-
"//py/tools/py:Cargo.toml",
87-
"//py/tools/unpack_bin:Cargo.toml",
88-
"//py/tools/venv_bin:Cargo.toml",
89-
"//py/tools/venv_shim:Cargo.toml",
90-
],
91-
)
92-
use_repo(crate, "crate_index")
93-
94-
# For building test images with py_image_layer
95-
bazel_dep(name = "container_structure_test", version = "1.19.3", dev_dependency = True)
96-
git_override(
97-
module_name = "container_structure_test",
98-
commit = "56c7201716d770c0f820a9c19207ba2ea77c34f8",
99-
remote = "https://github.com/GoogleContainerTools/container-structure-test.git",
100-
)
101-
102-
bazel_dep(name = "rules_oci", version = "2.0.1", dev_dependency = True)
103-
104-
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci", dev_dependency = True)
105-
oci.pull(
106-
name = "ubuntu",
107-
digest = "sha256:80dd3c3b9c6cecb9f1667e9290b3bc61b78c2678c02cbdae5f0fea92cc6734ab",
108-
image = "ubuntu",
109-
platforms = [
110-
"linux/arm64/v8",
111-
"linux/amd64",
112-
],
113-
tag = "latest",
114-
)
115-
use_repo(oci, "ubuntu", "ubuntu_linux_amd64", "ubuntu_linux_arm64_v8")

0 commit comments

Comments
 (0)