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.

In addition, update the drake_cmake_external instructions.
  • Loading branch information
BetsyMcPhail committed Nov 13, 2024
1 parent b01ab48 commit 38717a6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 192 deletions.
97 changes: 3 additions & 94 deletions drake_bazel_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@

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
Expand All @@ -59,91 +45,14 @@ if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
fi

apt-get install --no-install-recommends $(cat <<EOF
ca-certificates
wget
EOF
)

# Download the drake source and install the source prereqs
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

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
/opt/drake-master/setup/ubuntu/install_prereqs
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, install the required Ubuntu packages:

```
sudo setup/install_prereqs
```

This script will first download the drake source and then call drake's source
`install_prereqs` script to install any required packages. It is expected that
the script will have been run prior to building with CMake as described below.

Within the top-level CMakeLists, the drake source is once again downloaded as
an external project. Keep in mind that if a specific commit of drake is used
rather than master, and any dependencies have changed within that commit, then
the appropriate `install_prereqs` script will need to be run.

To build and run tests using CMake:

```
mkdir build
cd build
cmake ..
make
cmake --build .
ctest -V .
```

**Under Construction**

95 changes: 3 additions & 92 deletions drake_cmake_external/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@

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
Expand All @@ -59,91 +45,16 @@ if [[ "$(lsb_release -sc)" != 'jammy' ]]; then
fi

apt-get install --no-install-recommends $(cat <<EOF
ca-certificates
wget
EOF
)

# Download the drake source and install the source prereqs
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

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
/opt/drake-master/setup/ubuntu/install_prereqs

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
2 changes: 1 addition & 1 deletion drake_cmake_installed/.github/ci_build_test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir build
pushd build

cmake -DCMAKE_PREFIX_PATH=/opt/drake "$@" ..
make
cmake --build .
ctest -V .

popd
Expand Down

0 comments on commit 38717a6

Please sign in to comment.