From c09f5d61e15ef1ad9880072d2300f5c52c22d9db Mon Sep 17 00:00:00 2001 From: tyler-yankee Date: Mon, 24 Feb 2025 14:57:12 -0500 Subject: [PATCH 1/5] [drake_cmake_external] experimental package parameters --- drake_cmake_external/.github/ci_build_test | 39 ++++++++++++++++++++-- drake_cmake_external/.github/setup | 2 +- drake_cmake_external/CMakeLists.txt | 17 +++++++--- drake_cmake_external/README.md | 12 ++++++- drake_cmake_external/setup/install_prereqs | 27 ++++++++++++--- 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/drake_cmake_external/.github/ci_build_test b/drake_cmake_external/.github/ci_build_test index 11f4da75..dd633d5f 100755 --- a/drake_cmake_external/.github/ci_build_test +++ b/drake_cmake_external/.github/ci_build_test @@ -3,6 +3,34 @@ set -euxo pipefail +drake_commit_hash= +drake_commit_sha256= + +while [ "${1:-}" != "" ]; do + case "$1" in + --drake-commit-hash) + shift + if [[ $# -eq 0 ]]; then + echo 'No argument specified for --drake-commit-hash' >&2 + exit 1 + fi + drake_commit_hash="$1" + ;; + --drake-commit-sha256) + shift + if [[ $# -eq 0 ]]; then + echo 'No argument specified for --drake-commit-sha256' >&2 + exit 1 + fi + drake_commit_sha256="$1" + ;; + *) + echo 'Invalid command line argument' >&2 + exit 1 + esac + shift +done + cmake --version mkdir build @@ -10,7 +38,15 @@ pushd build export LD_LIBRARY_PATH="${PWD}/install/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" -cmake .. +cmake_args=() +if [[ ! -z "${drake_commit_hash}" ]]; then + # Use a specific commit of Drake source, + # rather than the latest from master. + cmake_args+=("-DDRAKE_COMMIT_HASH=${drake_commit_hash}") + cmake_args+=("-DDRAKE_COMMIT_SHA256=${drake_commit_sha256}") +fi + +cmake .. "${cmake_args[@]}" cmake --build . cd drake_external_examples @@ -20,4 +56,3 @@ popd chmod -R a+w build || true rm -rf build - diff --git a/drake_cmake_external/.github/setup b/drake_cmake_external/.github/setup index 02e00587..909ba3ae 100755 --- a/drake_cmake_external/.github/setup +++ b/drake_cmake_external/.github/setup @@ -7,7 +7,7 @@ set -euxo pipefail sudo .github/ubuntu_setup # drake source setup -setup/install_prereqs +setup/install_prereqs "$@" # Provide regression coverage for the WITH_USER_...=ON options by un-installing # packages that should not be necessary in this particular build flavor. This diff --git a/drake_cmake_external/CMakeLists.txt b/drake_cmake_external/CMakeLists.txt index ccbbe301..3fdb1a8e 100644 --- a/drake_cmake_external/CMakeLists.txt +++ b/drake_cmake_external/CMakeLists.txt @@ -93,13 +93,20 @@ ExternalProject_Add(spdlog # also pass this explicitly to ExternalProject_Add. set(DRAKE_PREFIX "${PROJECT_BINARY_DIR}/drake-prefix") +# Options to override Drake's latest source on master with a specific commit. +# Download https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz +# and use "shasum -a 256 'xxx.tar.gz'" on it to get the DRAKE_COMMIT_SHA256. +set(DRAKE_COMMIT_HASH "master" CACHE STRING "Commit hash for Drake") +set(DRAKE_COMMIT_SHA256 CACHE STRING "SHA256 hash value for Drake commit archive") + +if (NOT "${DRAKE_COMMIT_SHA256}" STREQUAL "") + string(PREPEND DRAKE_COMMIT_SHA256 "SHA256=") +endif() + ExternalProject_Add(drake DEPENDS eigen fmt spdlog - URL https://github.com/RobotLocomotion/drake/archive/master.tar.gz - # Or from a commit (download and use "shasum -a 256 'xxx.tar.gz'" on it to - # get the URL_HASH. - # URL https://github.com/RobotLocomotion/drake/archive/65c4366ea2b63278a286b1e22b8d464d50fbe365.tar.gz - # URL_HASH SHA256=899d98485522a7cd5251e50a7a6b8a64e40aff2a3af4951a3f0857fd938cafca + URL https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz + URL_HASH ${DRAKE_COMMIT_SHA256} TLS_VERIFY ON CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} diff --git a/drake_cmake_external/README.md b/drake_cmake_external/README.md index ad0aedd9..9cfe9cac 100644 --- a/drake_cmake_external/README.md +++ b/drake_cmake_external/README.md @@ -5,7 +5,7 @@ This pulls in Drake using the CMake `ExternalProject_Add(drake)` mechanism. ## Instructions First, run the `install_prereqs` script to download the -Drake source to `drake-master/` (from the current directory). +Drake source to `drake/` (from the current directory). This also runs Drake's setup script to install the required Ubuntu packages: ```bash @@ -29,3 +29,13 @@ cmake --build . cd drake_external_examples ctest -V . ``` + +### Using a specific commit of Drake + +To use Drake sources from a specific commit, pass two cache variables to +CMake (from either the CLI or the GUI): + +* `DRAKE_COMMIT_HASH`: the commit hash +* `DRAKE_COMMIT_SHA256`: the checksum of the archive downloaded from GitHub +(download https://github.com/RobotLocomotion/drake/archive/.tar.gz +and use `shasum -a 256 'xxx.tar.gz'`) diff --git a/drake_cmake_external/setup/install_prereqs b/drake_cmake_external/setup/install_prereqs index 05796b00..dfd0f6f1 100755 --- a/drake_cmake_external/setup/install_prereqs +++ b/drake_cmake_external/setup/install_prereqs @@ -4,6 +4,25 @@ set -euxo pipefail +drake_commit_hash='master' + +while [ "${1:-}" != "" ]; do + case "$1" in + --drake-commit-hash) + shift + if [[ $# -eq 0 ]]; then + echo 'No argument specified for --drake-commit-hash' >&2 + exit 1 + fi + drake_commit_hash="$1" + ;; + *) + echo 'Invalid command line argument' >&2 + exit 1 + esac + shift +done + maybe_sudo= if [[ "${EUID}" -ne 0 ]]; then maybe_sudo=sudo @@ -16,11 +35,9 @@ EOF # Download the drake source wget -O drake.tar.gz \ - https://github.com/RobotLocomotion/drake/archive/master.tar.gz + https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz trap 'rm -f drake.tar.gz' EXIT - -# Setup script -tar -xf drake.tar.gz +mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1 # Install the source prereqs -drake-master/setup/install_prereqs +drake/setup/install_prereqs From 7b00f0e9a3e5c31247403bc73f797e1a54565a8b Mon Sep 17 00:00:00 2001 From: tyler-yankee Date: Mon, 24 Feb 2025 14:57:44 -0500 Subject: [PATCH 2/5] [drake_bazel_external] experimental package parameters --- drake_bazel_external/.bazelignore | 2 +- drake_bazel_external/.github/ci_build_test | 7 +++++- drake_bazel_external/.github/setup | 2 +- drake_bazel_external/README.md | 2 +- drake_bazel_external/setup/install_prereqs | 27 ++++++++++++++++++---- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/drake_bazel_external/.bazelignore b/drake_bazel_external/.bazelignore index 889b4e07..a9d8bda6 100644 --- a/drake_bazel_external/.bazelignore +++ b/drake_bazel_external/.bazelignore @@ -1,2 +1,2 @@ # Used for setup, do not build -drake-master +drake diff --git a/drake_bazel_external/.github/ci_build_test b/drake_bazel_external/.github/ci_build_test index 672ca65e..e4011152 100755 --- a/drake_bazel_external/.github/ci_build_test +++ b/drake_bazel_external/.github/ci_build_test @@ -3,5 +3,10 @@ set -euxo pipefail +# Use what we downloaded to drake_bazel_external/drake, +# rather than the URL to the latest Drake master branch +# found in drake_bazel_external/MODULE.bazel. +override_module_flag="--override_module=drake=drake" + bazel version -bazel test //... +bazel test "${override_module_flag}" //... diff --git a/drake_bazel_external/.github/setup b/drake_bazel_external/.github/setup index daf45d54..d0530eef 100755 --- a/drake_bazel_external/.github/setup +++ b/drake_bazel_external/.github/setup @@ -7,4 +7,4 @@ set -euxo pipefail sudo .github/ubuntu_setup # drake source setup -setup/install_prereqs +setup/install_prereqs "$@" diff --git a/drake_bazel_external/README.md b/drake_bazel_external/README.md index d471eb59..7eed419c 100644 --- a/drake_bazel_external/README.md +++ b/drake_bazel_external/README.md @@ -8,7 +8,7 @@ For an introduction to Bazel, refer to ## Instructions First, run the `install_prereqs` script to download -the Drake source to `drake-master/` (from the current directory). +the Drake source to `drake/` (from the current directory). This also runs Drake's setup script to install the required Ubuntu packages: ```bash diff --git a/drake_bazel_external/setup/install_prereqs b/drake_bazel_external/setup/install_prereqs index 51ced2f9..50ee7471 100755 --- a/drake_bazel_external/setup/install_prereqs +++ b/drake_bazel_external/setup/install_prereqs @@ -4,6 +4,25 @@ set -euxo pipefail +drake_commit_hash='master' + +while [ "${1:-}" != "" ]; do + case "$1" in + --drake-commit-hash) + shift + if [[ $# -eq 0 ]]; then + echo 'No argument specified for --drake-commit-hash' >&2 + exit 1 + fi + drake_commit_hash="$1" + ;; + *) + echo 'Invalid command line argument' >&2 + exit 1 + esac + shift +done + maybe_sudo= if [[ "${EUID}" -ne 0 ]]; then maybe_sudo=sudo @@ -16,11 +35,9 @@ EOF # Download the drake source wget -O drake.tar.gz \ - https://github.com/RobotLocomotion/drake/archive/master.tar.gz + https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz trap 'rm -f drake.tar.gz' EXIT - -# Setup script -tar -xf drake.tar.gz +mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1 # Install the source prereqs -drake-master/setup/install_prereqs --with-bazel +drake/setup/install_prereqs --with-bazel From a0f4b6be770b1627ede7cc3f1b1ccb43045186d6 Mon Sep 17 00:00:00 2001 From: tyler-yankee Date: Mon, 24 Feb 2025 14:57:59 -0500 Subject: [PATCH 3/5] [drake_bazel_external_legacy] experimental_package_parameters --- drake_bazel_external_legacy/.bazelignore | 2 +- .../.github/ci_build_test | 6 +++++ drake_bazel_external_legacy/.github/setup | 2 +- drake_bazel_external_legacy/README.md | 2 +- .../setup/install_prereqs | 27 +++++++++++++++---- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drake_bazel_external_legacy/.bazelignore b/drake_bazel_external_legacy/.bazelignore index 889b4e07..a9d8bda6 100644 --- a/drake_bazel_external_legacy/.bazelignore +++ b/drake_bazel_external_legacy/.bazelignore @@ -1,2 +1,2 @@ # Used for setup, do not build -drake-master +drake diff --git a/drake_bazel_external_legacy/.github/ci_build_test b/drake_bazel_external_legacy/.github/ci_build_test index 672ca65e..ad48d47a 100755 --- a/drake_bazel_external_legacy/.github/ci_build_test +++ b/drake_bazel_external_legacy/.github/ci_build_test @@ -3,5 +3,11 @@ set -euxo pipefail +# Use what we downloaded to drake_bazel_external_legacy/drake, +# rather than the URL to the latest Drake master branch +# found in drake_bazel_external_legacy/WORKSPACE. +export EXAMPLES_LOCAL_DRAKE_PATH=$(realpath drake) +trap 'unset EXAMPLES_LOCAL_DRAKE_PATH' EXIT + bazel version bazel test //... diff --git a/drake_bazel_external_legacy/.github/setup b/drake_bazel_external_legacy/.github/setup index daf45d54..d0530eef 100755 --- a/drake_bazel_external_legacy/.github/setup +++ b/drake_bazel_external_legacy/.github/setup @@ -7,4 +7,4 @@ set -euxo pipefail sudo .github/ubuntu_setup # drake source setup -setup/install_prereqs +setup/install_prereqs "$@" diff --git a/drake_bazel_external_legacy/README.md b/drake_bazel_external_legacy/README.md index ad42f2d8..626c2adb 100644 --- a/drake_bazel_external_legacy/README.md +++ b/drake_bazel_external_legacy/README.md @@ -13,7 +13,7 @@ For an introduction to Bazel, refer to ## Instructions First, run the `install_prereqs` script to download the -Drake source to `drake-master/` (from the current directory). +Drake source to `drake/` (from the current directory). This also runs Drake's setup script to install the required Ubuntu packages: ```bash diff --git a/drake_bazel_external_legacy/setup/install_prereqs b/drake_bazel_external_legacy/setup/install_prereqs index 51ced2f9..50ee7471 100755 --- a/drake_bazel_external_legacy/setup/install_prereqs +++ b/drake_bazel_external_legacy/setup/install_prereqs @@ -4,6 +4,25 @@ set -euxo pipefail +drake_commit_hash='master' + +while [ "${1:-}" != "" ]; do + case "$1" in + --drake-commit-hash) + shift + if [[ $# -eq 0 ]]; then + echo 'No argument specified for --drake-commit-hash' >&2 + exit 1 + fi + drake_commit_hash="$1" + ;; + *) + echo 'Invalid command line argument' >&2 + exit 1 + esac + shift +done + maybe_sudo= if [[ "${EUID}" -ne 0 ]]; then maybe_sudo=sudo @@ -16,11 +35,9 @@ EOF # Download the drake source wget -O drake.tar.gz \ - https://github.com/RobotLocomotion/drake/archive/master.tar.gz + https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz trap 'rm -f drake.tar.gz' EXIT - -# Setup script -tar -xf drake.tar.gz +mkdir -p drake && tar -xf drake.tar.gz -C drake --strip-components 1 # Install the source prereqs -drake-master/setup/install_prereqs --with-bazel +drake/setup/install_prereqs --with-bazel From 02ffcbc3c4b7c9764517b86fe4ad667759b8548a Mon Sep 17 00:00:00 2001 From: tyler-yankee Date: Thu, 6 Mar 2025 15:15:06 -0500 Subject: [PATCH 4/5] [drake_cmake_external] get shasum ourselves --- drake_cmake_external/.github/ci_build_test | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drake_cmake_external/.github/ci_build_test b/drake_cmake_external/.github/ci_build_test index dd633d5f..0d3d117b 100755 --- a/drake_cmake_external/.github/ci_build_test +++ b/drake_cmake_external/.github/ci_build_test @@ -4,7 +4,6 @@ set -euxo pipefail drake_commit_hash= -drake_commit_sha256= while [ "${1:-}" != "" ]; do case "$1" in @@ -16,14 +15,6 @@ while [ "${1:-}" != "" ]; do fi drake_commit_hash="$1" ;; - --drake-commit-sha256) - shift - if [[ $# -eq 0 ]]; then - echo 'No argument specified for --drake-commit-sha256' >&2 - exit 1 - fi - drake_commit_sha256="$1" - ;; *) echo 'Invalid command line argument' >&2 exit 1 @@ -42,8 +33,14 @@ cmake_args=() if [[ ! -z "${drake_commit_hash}" ]]; then # Use a specific commit of Drake source, # rather than the latest from master. - cmake_args+=("-DDRAKE_COMMIT_HASH=${drake_commit_hash}") - cmake_args+=("-DDRAKE_COMMIT_SHA256=${drake_commit_sha256}") + cmake_args+=(-DDRAKE_COMMIT_HASH=${drake_commit_hash}) + + # Find the SHA-256 by downloading and running shasum. + wget -O drake.tar.gz \ + https://github.com/RobotLocomotion/drake/archive/${drake_commit_hash}.tar.gz + trap 'rm -f drake.tar.gz' EXIT + drake_commit_sha256=$(echo $(shasum -a 256 drake.tar.gz | awk '{print $1}')) + cmake_args+=(-DDRAKE_COMMIT_SHA256=${drake_commit_sha256}) fi cmake .. "${cmake_args[@]}" From db52451f7fc50925ae724a676f977dc8ce49bc19 Mon Sep 17 00:00:00 2001 From: tyler-yankee Date: Thu, 6 Mar 2025 15:55:02 -0500 Subject: [PATCH 5/5] remove file_sync cases that no longer sync --- private/test/file_sync_test.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/private/test/file_sync_test.py b/private/test/file_sync_test.py index b6f67f4b..046ab971 100755 --- a/private/test/file_sync_test.py +++ b/private/test/file_sync_test.py @@ -41,10 +41,6 @@ "drake_pip/LICENSE", "drake_poetry/LICENSE", ), - ( - "drake_bazel_download/.github/ci_build_test", - "drake_bazel_external/.github/ci_build_test", - ), ( "drake_bazel_external/.github/ubuntu_setup", "drake_cmake_external/.github/ubuntu_setup", @@ -62,7 +58,6 @@ ".bazelignore", ".bazelproject", ".clang-format", - ".github/ci_build_test", ".github/setup", ".github/ubuntu_setup", "BUILD.bazel",