-
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] Use bzlmod for development and testing
In other words, Drake Developers will now be using bzlmod by default. (CMake installs were already using it.) Users who consume Drake as a bazel external must still use workspace mode (no bzlmod). Even though Drake now uses bzlmod for developers, it is not yet possible for downstream projects to consume Drake as a bzlmod module; that remains future work. The main change required for bzlmod here is that our module name in runfiles is "_main" now instead of "drake", which mostly affects some linters and tests that were hard-coded. More generally, there is now a concept of "repo mapping" where module names in a MODULE.bazel file are projected to unique names in runfiles, to allow for multiple copies of modules to co-exist. This means that a runfiles lookup must not only specify the path it's looking for, but from _whose point of view_ that path is coming from. * common: Adjust FindRunfile to know about source_repository. When none is given and we're seeking a drake runfile, supply the right "point of view" string automatically. * resource_tool_test: Loosen test condition to be only the file basename. * unittest_main: Adjust our source file scan to allow for either the bzlmod or workspace spelling of the test program. (The old workspace spelling would only be used by downstream projects.) * tools: Adjust find_all_sources scan for .bazelproject to check against the realpath instead of the runfiles path.
- Loading branch information
1 parent
dac7c79
commit a5e94c2
Showing
14 changed files
with
101 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,9 @@ | ||
# This file marks a workspace root for the Bazel build system. | ||
# See `https://bazel.build/`. | ||
# | ||
# When bzlmod is disabled, only this file is used. The related files | ||
# MODULE.bazel and WORKSPACE.bzlmod are NOT used. | ||
# | ||
# When bzlmod is enabled, this file is ignored. | ||
|
||
workspace(name = "drake") | ||
|
||
load("//tools/workspace:default.bzl", "add_default_workspace") | ||
|
||
add_default_workspace(bzlmod = False) | ||
|
||
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 | ||
# Building Drake directly (i.e., not as a dependency of a larger project) | ||
# with bzlmod disabled is no longer supported | ||
# | ||
# Consuming Drake as a WORKSPACE dependency is still supported: | ||
# https://github.com/RobotLocomotion/drake-external-examples/tree/main/drake_bazel_external_legacy | ||
|
||
crate_universe_dependencies(bootstrap = True) | ||
fail("First-party Drake builds require that bzlmod is enabled.") |
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
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