diff --git a/setup/BUILD.bazel b/setup/BUILD.bazel index ca1656cedaf6..2521b0a733f1 100644 --- a/setup/BUILD.bazel +++ b/setup/BUILD.bazel @@ -19,10 +19,12 @@ exports_files([ "ubuntu/binary_distribution/packages-bionic.txt", "ubuntu/binary_distribution/packages-focal.txt", "ubuntu/source_distribution/packages-bionic.txt", + "ubuntu/source_distribution/packages-bionic-clang.txt", "ubuntu/source_distribution/packages-bionic-doc-only.txt", "ubuntu/source_distribution/packages-bionic-maintainer-only.txt", "ubuntu/source_distribution/packages-bionic-test-only.txt", "ubuntu/source_distribution/packages-focal.txt", + "ubuntu/source_distribution/packages-focal-clang.txt", "ubuntu/source_distribution/packages-focal-doc-only.txt", "ubuntu/source_distribution/packages-focal-maintainer-only.txt", "ubuntu/source_distribution/packages-focal-test-only.txt", diff --git a/setup/ubuntu/install_prereqs.sh b/setup/ubuntu/install_prereqs.sh index fb15cc13783d..f50f51a3a36a 100755 --- a/setup/ubuntu/install_prereqs.sh +++ b/setup/ubuntu/install_prereqs.sh @@ -31,16 +31,21 @@ while [ "${1:-}" != "" ]; do --with-kcov) source_distribution_args+=(--with-kcov) ;; + # Install prerequisites that are only needed to when CC=clang-9, i.e., + # opts-in to the ability to compile Drake's C++ code using Clang. + --with-clang) + source_distribution_args+=(--with-clang) + ;; + # Do NOT install prerequisites that are only needed to when CC=clang-9, + # i.e., opts-out of the ability to compile Drake's C++ code using Clang. + --without-clang) + source_distribution_args+=(--without-clang) + ;; # Install prerequisites that are only needed to run select maintainer # scripts. Most developers will not need to install these dependencies. --with-maintainer-only) source_distribution_args+=(--with-maintainer-only) ;; - # Do NOT install prerequisites that are only needed to build documentation, - # i.e., those prerequisites that are dependencies of bazel run //doc:build. - --without-doc-only) - source_distribution_args+=(--without-doc-only) - ;; # Do NOT install prerequisites that are only needed to build and/or run # unit tests, i.e., those prerequisites that are not dependencies of # bazel { build, run } //:install. diff --git a/setup/ubuntu/source_distribution/install_prereqs.sh b/setup/ubuntu/source_distribution/install_prereqs.sh index d120809fa9ad..d7d67422b479 100755 --- a/setup/ubuntu/source_distribution/install_prereqs.sh +++ b/setup/ubuntu/source_distribution/install_prereqs.sh @@ -11,10 +11,13 @@ set -euo pipefail with_doc_only=0 with_kcov=0 with_maintainer_only=0 +with_clang=1 with_test_only=1 with_update=1 with_asking=1 +# TODO(jwnimmer-tri) Eventually we should default to with_clang=0. + while [ "${1:-}" != "" ]; do case "$1" in # Install prerequisites that are only needed to build documentation, @@ -29,6 +32,16 @@ while [ "${1:-}" != "" ]; do --with-kcov) with_kcov=1 ;; + # Install prerequisites that are only needed to when CC=clang-9, i.e., + # opts-in to the ability to compile Drake's C++ code using Clang. + --with-clang) + with_clang=1 + ;; + # Do NOT install prerequisites that are only needed to when CC=clang-9, + # i.e., opts-out of the ability to compile Drake's C++ code using Clang. + --without-clang) + with_clang=0 + ;; # Install prerequisites that are only needed to run select maintainer # scripts. Most developers will not need to install these dependencies. --with-maintainer-only) @@ -124,6 +137,11 @@ if [[ "${with_doc_only}" -eq 1 ]]; then apt-get install ${maybe_yes} --no-install-recommends ${packages} fi +if [[ "${with_clang}" -eq 1 ]]; then + packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-clang.txt") + apt-get install ${maybe_yes} --no-install-recommends ${packages} +fi + if [[ "${with_test_only}" -eq 1 ]]; then packages=$(cat "${BASH_SOURCE%/*}/packages-${codename}-test-only.txt") # Suppress Python 3.8 warnings when installing python3-pandas on Focal. diff --git a/setup/ubuntu/source_distribution/packages-bionic-clang.txt b/setup/ubuntu/source_distribution/packages-bionic-clang.txt new file mode 100644 index 000000000000..5db5152c0670 --- /dev/null +++ b/setup/ubuntu/source_distribution/packages-bionic-clang.txt @@ -0,0 +1,2 @@ +clang-9 +libomp-9-dev diff --git a/setup/ubuntu/source_distribution/packages-bionic.txt b/setup/ubuntu/source_distribution/packages-bionic.txt index a5c2881a66e3..86650c85f788 100644 --- a/setup/ubuntu/source_distribution/packages-bionic.txt +++ b/setup/ubuntu/source_distribution/packages-bionic.txt @@ -1,4 +1,3 @@ -clang-9 clang-format-9 coinor-libclp-dev coinor-libcoinutils-dev diff --git a/setup/ubuntu/source_distribution/packages-focal-clang.txt b/setup/ubuntu/source_distribution/packages-focal-clang.txt new file mode 100644 index 000000000000..5db5152c0670 --- /dev/null +++ b/setup/ubuntu/source_distribution/packages-focal-clang.txt @@ -0,0 +1,2 @@ +clang-9 +libomp-9-dev diff --git a/setup/ubuntu/source_distribution/packages-focal.txt b/setup/ubuntu/source_distribution/packages-focal.txt index 5cfb58cabce1..9a5371e9be6b 100644 --- a/setup/ubuntu/source_distribution/packages-focal.txt +++ b/setup/ubuntu/source_distribution/packages-focal.txt @@ -1,4 +1,3 @@ -clang-9 clang-format-9 coinor-libclp-dev coinor-libcoinutils-dev