-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] Support bzlmod for building and installing
See https://bazel.build/external/migration for background. Note that this commit does not pass all tests when bzlmod is enabled; doing so requires enhancements to our runfiles handling, so for now bzlmod is still disabled by default (except for CMake installs). Details: - Add MODULE.bazel and WORKSPACE.bzlmod for bzlmod use. - Note that WORKSPACE.bzlmod is a copy of WORKSPACE with a tweaked overview comment and a single functional change to our bzlmod flag. - Fix latent bug in repository_excludes for rules_python. - Adjust install rule so installed paths are "drake" not "_main". - Disable drake_py add_test_rule pyc files (for newer rules_python). - Tweak local_config_cc spelling again for bzlmod. - Add linter for module<->workspace syncing. - Turn on bzlmod for CMake to achieve test coverage in CI.
- Loading branch information
1 parent
804b2c6
commit c8456ce
Showing
22 changed files
with
343 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This file marks a workspace root for the Bazel build system. | ||
# See `https://bazel.build/`. | ||
|
||
# This file lists Drake's external dependencies as known to bzlmod. | ||
# | ||
# When bzlmod is disabled, this file is NOT used. Instead, only WORKSPACE is | ||
# used. | ||
# | ||
# When bzlmod is enabled, this file + WORKSPACE.bzlmod are both used, and | ||
# WORKSPACE is ignored. | ||
|
||
module(name = "drake") | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
bazel_dep(name = "rules_cc", version = "0.0.17") | ||
bazel_dep(name = "rules_java", version = "8.6.1") | ||
bazel_dep(name = "rules_license", version = "1.0.0") | ||
bazel_dep(name = "rules_python", version = "0.40.0") | ||
|
||
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension") | ||
use_repo(cc_configure, "local_config_cc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- bazel -*- | ||
# | ||
# This file lists Drake's external dependencies as known to bzlmod. | ||
# | ||
# When bzlmod is disabled, this file is NOT used. Instead, only WORKSPACE is | ||
# used. | ||
# | ||
# When bzlmod is enabled, this file + MODULE.bazel are both used, and WORKSPACE | ||
# is ignored. | ||
|
||
workspace(name = "drake") | ||
|
||
load("//tools/workspace:default.bzl", "add_default_workspace") | ||
|
||
add_default_workspace(bzlmod = True) | ||
|
||
load("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure") | ||
|
||
apple_cc_configure() | ||
|
||
# Add some special heuristic logic for using CLion with Drake. | ||
load("//tools/clion:repository.bzl", "drake_clion_environment") | ||
|
||
drake_clion_environment() | ||
|
||
load("@bazel_skylib//lib:versions.bzl", "versions") | ||
|
||
# This needs to be in WORKSPACE or a repository rule for native.bazel_version | ||
# to actually be defined. The minimum_bazel_version value should match the | ||
# version passed to the find_package(Bazel) call in the root CMakeLists.txt. | ||
versions.check(minimum_bazel_version = "7.1") | ||
|
||
# The cargo_universe programs are only used by Drake's new_release tooling, not | ||
# by any compilation rules. As such, we can put it directly into the WORKSPACE | ||
# instead of into our `//tools/workspace:default.bzl` repositories. | ||
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") # noqa | ||
|
||
crate_universe_dependencies(bootstrap = True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# This file exists to make our directory into a Bazel package, so that our | ||
# neighboring *.bzl file can be loaded elsewhere. | ||
|
||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
|
||
# Required for workspace_bzlmod_sync_test.py. | ||
exports_files( | ||
["repository.bzl"], | ||
visibility = ["//tools/workspace:__pkg__"], | ||
) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
|
||
# Required for workspace_bzlmod_sync_test.py. | ||
exports_files( | ||
["repository.bzl"], | ||
visibility = ["//tools/workspace:__pkg__"], | ||
) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
load("//tools/lint:lint.bzl", "add_lint_tests") | ||
|
||
# Required for workspace_bzlmod_sync_test.py. | ||
exports_files( | ||
["repository.bzl"], | ||
visibility = ["//tools/workspace:__pkg__"], | ||
) | ||
|
||
add_lint_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.