Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[drake_bazel_external] Port to use MODULE.bazel #348

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions drake_bazel_external/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# SPDX-License-Identifier: MIT-0

# Don't use bzlmod yet.
common --enable_workspace=true
common --enable_bzlmod=false

# Default to an optimized build.
build --compilation_mode=opt

Expand Down
1 change: 1 addition & 0 deletions drake_bazel_external/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

/bazel-*
/user.bazelrc
/MODULE.bazel.lock
42 changes: 42 additions & 0 deletions drake_bazel_external/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-License-Identifier: MIT-0

module(name = "drake_external_examples")

# Add the Bazel rules we need.
bazel_dep(name = "rules_cc", version = "0.0.17")
bazel_dep(name = "rules_python", version = "0.40.0")

# Use the host system python.
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")

# Here we introduce Drake as a module dependency, but note that Drake is not
# published to any Bazel registry. Below, we'll override it with a github
# source archive.
bazel_dep(name = "drake")

# By default, this example always uses the latest Drake master branch.
DRAKE_COMMIT = "bzlmod-extension"
DRAKE_CHECKSUM = ""

# You can choose a specific revision of Drake to use, e.g.:
# DRAKE_COMMIT = "be4f658487f739ba04ec079de46f9459b719636d"
# DRAKE_CHECKSUM = "31ec8f87df3ceb6516de3c33a14c5d59ac5c003b4faf93ac526877d2e150b394"
#
# You can also use DRAKE_COMMIT to choose a Drake release; e.g.:
# DRAKE_COMMIT = "v0.15.0"
# DRAKE_CHECKSUM = "... TBD ..."
#
# Before changing the COMMIT, temporarily uncomment the next line so that Bazel
# displays the suggested new value for the CHECKSUM.
# DRAKE_CHECKSUM = "0" * 64

# This declares the `@drake` module as a source code archive from github.
# See README.md for instructions to use a local path, instead.
archive_override(
module_name = "drake",
urls = [x.format(DRAKE_COMMIT) for x in [
"https://github.com/jwnimmer-tri/drake/archive/{}.tar.gz",
]],
sha256 = DRAKE_CHECKSUM,
strip_prefix = "drake-{}".format(DRAKE_COMMIT.lstrip("v")),
)
9 changes: 9 additions & 0 deletions drake_bazel_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ cause differences. This is important when using tools like
`drake::FindResource` / `pydrake.common.FindResource`.
You may generally want to stick to using `bazel run` when able.

### Using a local checkout of Drake

To use Drake sources on disk instead of downloaded from github, pass the flag
``--override_module=drake=/home/user/stuff/drake`` to bazel on the command line
or add a line such as the following to ``user.bazelrc`` in the current directory:
```
build --override_module=drake=/home/user/stuff/drake
```

## Python Versions

By default, Python 3 is the Python interpreter that Drake will use when built
Expand Down
55 changes: 0 additions & 55 deletions drake_bazel_external/WORKSPACE

This file was deleted.

5 changes: 4 additions & 1 deletion drake_bazel_external/apps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: MIT-0

load("@drake//tools/skylark:py.bzl", "py_binary", "py_test")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@drake//tools/skylark:pybind.bzl", "pybind_py_library")

# Compile a sample application.
Expand Down Expand Up @@ -79,6 +80,7 @@ cc_test(

pybind_py_library(
name = "simple_adder_py",
cc_binary_rule = cc_binary,
cc_so_name = "simple_adder",
cc_srcs = ["simple_adder_py.cc"],
cc_deps = [
Expand All @@ -88,6 +90,7 @@ pybind_py_library(
],
py_deps = ["@drake//bindings/pydrake"],
py_imports = ["."],
py_library_rule = py_library,
)

# Mimic the C++ test in Python to show the bindings.
Expand Down
45 changes: 0 additions & 45 deletions drake_bazel_external/environ.bzl

This file was deleted.

5 changes: 0 additions & 5 deletions private/test/file_sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,13 @@
for path in [
".bazelignore",
".bazelproject",
".bazelrc",
".clang-format",
".github/ci_build_test",
".github/setup",
".github/ubuntu_setup",
".gitignore",
"BUILD.bazel",
"CPPLINT.cfg",
"LICENSE",
"WORKSPACE",
"apps/BUILD.bazel",
"apps/exec.sh",
"apps/find_resource_test.py",
"apps/import_all_test.py",
Expand All @@ -95,7 +91,6 @@
"apps/simple_adder_test.cc",
"apps/simple_continuous_time_system.cc",
"apps/simple_logging_example.py",
"environ.bzl",
"setup/install_prereqs",
]
])
Expand Down
Loading