-
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 MODULE.bazel for all dependencies
The WORKSPACE.bzlmod is no longer load-bearing, so as of this commit it should be possible to consume Drake as a module external of other downstream projects (instead of as a repository external). Notable changes: Document our stability promises for our module extension. Adjust CMake logic to use its own MODULE.bazel.in that consumes Drake as a module external, and to override choices for other dependencies using conventional Bazel command-line flags instead of editing the WORKSPACE file. Adjust the pkg_config repository rule to handle the new distinction between canonical vs apparent repository names. Ditto for the java maven repositories (only relevant on macOS). Adjust our lcm native code loader to accommodate the new runfiles layout. Add test coverage for EventLog (which uses a distinctive spelling of its import paths in upstream code). Adjust labels used by our (non-symbolic) pybind11 macro to only ever refer to the drake label, not the external label. Textual macros resolve labels in the workspace context of the code calling them, not Drake. Therefore they must only ever refer to Drake, since Drake's externals are now invisible (by default) with bzlmod. We introduce Drake aliases for the externals so that we can use a safe labels in our macros. (This fix is only necessary for macros which we expect downstream code to call, i.e., macros without a "drake_..." prefix in their name. We still have plenty of other drake-specific macros that refer to non-drake labels, but that's not a problem.) The longer term fix for this will probably be switching from textual macros to symbolic macros, but we don't attempt that here. Adjust some of our hard-coded runfiles paths (header_lint test, wheel build snopt, drake_models parse_test) to align with the new canonical repository names.
- Loading branch information
1 parent
c13c2cc
commit d029d23
Showing
24 changed files
with
518 additions
and
202 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,22 +1,13 @@ | ||
# -*- bazel -*- | ||
# | ||
# This file lists Drake's workspace-style external dependencies. It is used in | ||
# concert with MODULE.bazel (which has the module-style externals). | ||
# This file is only ever used by drake/tools/clion/bazel_wrapper (for Drake | ||
# Developers who develop using CLion; see https://drake.mit.edu/clion.html). | ||
# | ||
# Do not add any other new dependencies into this file. | ||
|
||
workspace(name = "drake") | ||
|
||
load("//tools/workspace:default.bzl", "add_default_workspace") | ||
|
||
add_default_workspace(bzlmod = True) | ||
|
||
# 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.4") |
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,25 @@ | ||
module(name = "drake_cmake") | ||
|
||
bazel_dep(name = "rules_python", version = "0.40.0") | ||
|
||
bazel_dep(name = "drake") | ||
local_path_override( | ||
module_name = "drake", | ||
path = "@PROJECT_SOURCE_DIR@", | ||
) | ||
|
||
python_repository = use_repo_rule( | ||
"@drake//tools/workspace/python:repository.bzl", | ||
"python_repository", | ||
) | ||
|
||
# Use Drake's python repository rule to interrogate the interpreter chosen by | ||
# the CMake find_program stanza, in support of compiling our C++ bindings. | ||
python_repository( | ||
name = "python", | ||
linux_interpreter_path = "@Python_EXECUTABLE@", | ||
macos_interpreter_path = "@Python_EXECUTABLE@", | ||
requirements_flavor = "build", | ||
) | ||
|
||
register_toolchains("@python//:all") |
This file was deleted.
Oops, something went wrong.
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.