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 24, 2024
1 parent 559561c commit 91b1e27
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 256 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
2 changes: 2 additions & 0 deletions drake_bazel_external/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Used for setup, do not build
drake-master
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
11 changes: 4 additions & 7 deletions drake_bazel_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

set -euxo pipefail

cd $(dirname "${BASH_SOURCE}")
sudo ./ubuntu_setup
# CI setup
sudo ./.github/ubuntu_setup

cat > "${HOME}/.bazelrc" << EOF
startup --output_user_root=${WORKSPACE}/_bazel_${USER}
test --color=yes
test --keep_going
EOF
# drake source setup
setup/install_prereqs
14 changes: 12 additions & 2 deletions drake_bazel_external/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@

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
11 changes: 8 additions & 3 deletions drake_bazel_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ For an introduction to Bazel, refer to

## Instructions

First, install the required Ubuntu packages:
First, run the `install_prereqs` script to download the drake source and run
drake's 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
115 changes: 7 additions & 108 deletions drake_bazel_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -31,119 +31,18 @@

set -euxo pipefail

ros_humble=0

while [ "${1:-}" != "" ]; do
case "$1" in
--ros-humble)
ros_humble=1
;;
*)
echo 'Invalid command line argument' >&2
exit 1
esac
shift
done

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

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
ca-certificates
sudo apt-get install --no-install-recommends $(cat <<EOF
wget
EOF
)

# Download the drake source
wget -O drake.tar.gz \
https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz
https://github.com/RobotLocomotion/drake/archive/master.tar.gz
trap 'rm -f drake.tar.gz' EXIT
tar -xf drake.tar.gz -C /opt

# Show version for debugging; use echo for newline / readability.
echo -e "\ndrake VERSION.TXT: $(cat /opt/drake/share/doc/drake/VERSION.TXT)\n"

/opt/drake/share/drake/setup/install_prereqs

apt-get install --no-install-recommends gnupg

apt-key adv --fetch-keys https://bazel.build/bazel-release.pub.gpg
echo 'deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8' \
> /etc/apt/sources.list.d/bazel.list
# Setup script
tar -xf drake.tar.gz

apt-get update
apt-get install --no-install-recommends $(cat <<EOF
bazel
cmake
default-jdk
file
gfortran
git
libblas-dev
libclang-15-dev
libeigen3-dev
libgflags-dev
libgl-dev
libglib2.0-dev
libglx-dev
liblapack-dev
libmumps-seq-dev
libopengl-dev
libspdlog-dev
libx11-dev
locales
nasm
ocl-icd-opencl-dev
opencl-headers
openssh-client
patch
patchelf
pkg-config
python-is-python3
python3-all-dev
python3-ipywidgets
python3-matplotlib
python3-munkres
python3-numpy
python3-pil
python3-pydot
python3-pygame
python3-yaml
zlib1g-dev
EOF
)

locale-gen en_US.UTF-8

if [[ ${ros_humble} -eq 1 ]]; then
apt-key adv --fetch-keys \
https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc
echo 'deb http://packages.ros.org/ros2/ubuntu jammy main' \
> /etc/apt/sources.list.d/ros2-latest.list

apt-get update
apt-get install --no-install-recommends $(cat <<EOF
python3-colcon-common-extensions
ros-humble-ament-cmake
ros-humble-ament-cmake-gtest
ros-humble-ament-cmake-lint-cmake
ros-humble-ament-cmake-xmllint
ros-humble-ament-lint-auto
EOF
)
else
apt-get install --no-install-recommends $(cat <<EOF
catkin
python3-pkg-resources
EOF
)
fi
# Install the source prereqs
sudo ./drake-master/setup/ubuntu/install_prereqs.sh
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
11 changes: 4 additions & 7 deletions drake_cmake_external/.github/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

set -euxo pipefail

cd $(dirname "${BASH_SOURCE}")
sudo ./ubuntu_setup
# CI setup
sudo ./.github/ubuntu_setup

cat > "${HOME}/.bazelrc" << EOF
startup --output_user_root=${WORKSPACE}/_bazel_${USER}
test --color=yes
test --keep_going
EOF
# drake source setup
setup/install_prereqs
14 changes: 12 additions & 2 deletions drake_cmake_external/.github/ubuntu_setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@

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
25 changes: 20 additions & 5 deletions drake_cmake_external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@

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

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

First, run the `install_prereqs` script to download the drake source and run
drake's source setup script to install the required Ubuntu packages:

```
./setup/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 script ran above must also be modified.

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 91b1e27

Please sign in to comment.