Skip to content

Commit

Permalink
Use the source version of drake's install_prereqs for external examples
Browse files Browse the repository at this point in the history
Previously, the binary version of the script was called in addition to
replicating much of the source version. With this change, the
copy-and-paste is removed.
  • Loading branch information
BetsyMcPhail committed Nov 14, 2024
1 parent b01ab48 commit f4555d7
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 344 deletions.
12 changes: 8 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ node('linux-jammy-unprovisioned') {
stage('checkout') {
checkout scm
}
}
dir('src/drake_bazel_external'){
stage('bazel_external setup') {
sh './drake_bazel_external/.github/setup'
sh './.github/setup'
}
stage('bazel_external build and test') {
sh './drake_bazel_external/.github/ci_build_test'
sh './.github/ci_build_test'
}
}
} catch (e) {
Expand Down Expand Up @@ -58,11 +60,13 @@ node('linux-jammy-unprovisioned') {
stage('checkout') {
checkout scm
}
}
dir('src/drake_cmake_external'){
stage('cmake_external setup') {
sh './drake_cmake_external/.github/setup'
sh './.github/setup'
}
stage('cmake_external build and test') {
sh './drake_cmake_external/.github/ci_build_test'
sh './.github/ci_build_test'
}
}
} catch (e) {
Expand Down
4 changes: 0 additions & 4 deletions drake_bazel_external/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@

set -euxo pipefail

pushd drake_bazel_external

bazel version
bazel test //...

popd
20 changes: 12 additions & 8 deletions drake_bazel_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

set -euxo pipefail

cd $(dirname "${BASH_SOURCE}")
sudo ./ubuntu_setup

cat > "${HOME}/.bazelrc" << EOF
startup --output_user_root=${WORKSPACE}/_bazel_${USER}
test --color=yes
test --keep_going
EOF
# CI setup
sudo ./.github/ubuntu_setup

# Download the drake source
mkdir ~/drake_install
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C ~/drake_install

# Install the source prereqs
sudo ~/drake_install/drake-master/setup/ubuntu/install_prereqs.sh
19 changes: 17 additions & 2 deletions drake_bazel_external/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@

set -euxo pipefail

if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

cd $(dirname "${BASH_SOURCE}")/..
setup/install_prereqs
apt-get update
apt-get install --no-install-recommends lsb-release

if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
echo 'This script requires Ubuntu 22.04 (Jammy)' >&2
exit 3
fi

apt-get install --no-install-recommends $(cat <<EOF
wget
EOF
)
12 changes: 9 additions & 3 deletions drake_bazel_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ For an introduction to Bazel, refer to

## Instructions

First, install the required Ubuntu packages:
First, download the drake source to a location of your choice, importantly
not this directory, and run the source setup script to install the required
Ubuntu packages:

```
sudo setup/install_prereqs
mkdir ~/drake_install
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
tar -xf drake.tar.gz -C ~/drake_install
sudo ~/drake_install/drake-master/setup/ubuntu/install_prereqs.sh
```

Then, to build and test all apps:
Then, build and test all apps:
```
bazel test //...
```
Expand Down
149 changes: 0 additions & 149 deletions drake_bazel_external/setup/install_prereqs

This file was deleted.

5 changes: 1 addition & 4 deletions drake_cmake_external/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ set -euxo pipefail

cmake --version

pushd drake_cmake_external

mkdir build
pushd build

export LD_LIBRARY_PATH="${PWD}/install/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"

cmake ..
make
cmake --build .

cd drake_external_examples
ctest -V .
Expand All @@ -23,4 +21,3 @@ popd
chmod -R a+w build || true
rm -rf build

popd
21 changes: 13 additions & 8 deletions drake_cmake_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

set -euxo pipefail

cd $(dirname "${BASH_SOURCE}")
sudo ./ubuntu_setup

cat > "${HOME}/.bazelrc" << EOF
startup --output_user_root=${WORKSPACE}/_bazel_${USER}
test --color=yes
test --keep_going
EOF
# CI setup
sudo ./.github/ubuntu_setup

# Download the drake source
mkdir ~/drake_install
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C ~/drake_install

# Install the source prereqs
sudo ~/drake_install/drake-master/setup/ubuntu/install_prereqs.sh

19 changes: 17 additions & 2 deletions drake_cmake_external/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@

set -euxo pipefail

if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

cd $(dirname "${BASH_SOURCE}")/..
setup/install_prereqs
apt-get update
apt-get install --no-install-recommends lsb-release

if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
echo 'This script requires Ubuntu 22.04 (Jammy)' >&2
exit 3
fi

apt-get install --no-install-recommends $(cat <<EOF
wget
EOF
)
29 changes: 24 additions & 5 deletions drake_cmake_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@

This pulls in Drake using the CMake `ExternalProject_Add(drake)` mechanism.

To build all apps using CMake and Make:
## Instructions

First, download the drake source to a location of your choice and run the
source setup script to install the required Ubuntu packages:

```
mkdir ~/drake_install
wget -O drake.tar.gz \
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
tar -xf drake.tar.gz -C ~/drake_install
sudo ~/drake_install/drake-master/setup/ubuntu/install_prereqs.sh
```

Keep in mind that within the top-level CMakeLists, the drake source is once
again downloaded as an external project. If the CMakeLists is modified to use
a specific version of drake other than master, and any dependencies have
changed within that version, then the same version must also be used above.

Once all necessary dependencies have been installed, build and run tests
using CMake:

```
mkdir build
cd build
cmake ..
make
```

**Under Construction**
cmake --build .
cd drake_external_examples
ctest -V .
```
Loading

0 comments on commit f4555d7

Please sign in to comment.