diff --git a/tools/workspace/drake_visualizer/.dockerignore b/tools/workspace/drake_visualizer/.dockerignore new file mode 100644 index 000000000000..f26cfc727e5e --- /dev/null +++ b/tools/workspace/drake_visualizer/.dockerignore @@ -0,0 +1,3 @@ +** +!*-dv-*.patch +!vtk-*.tar.gz diff --git a/tools/workspace/drake_visualizer/.editorconfig b/tools/workspace/drake_visualizer/.editorconfig new file mode 100644 index 000000000000..f5470cf9e48c --- /dev/null +++ b/tools/workspace/drake_visualizer/.editorconfig @@ -0,0 +1,5 @@ +# https://editorconfig.org + +[*.patch] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/tools/workspace/drake_visualizer/0001-dv-opengl-glvnd.patch b/tools/workspace/drake_visualizer/0001-dv-opengl-glvnd.patch new file mode 100644 index 000000000000..10fe004437bd --- /dev/null +++ b/tools/workspace/drake_visualizer/0001-dv-opengl-glvnd.patch @@ -0,0 +1,95 @@ +From 11f988658c1d659d2172aa9d265fe03408e6448c Mon Sep 17 00:00:00 2001 +From: Jamie Snape +Date: Wed, 7 Mar 2018 12:00:00 -0400 +Subject: [PATCH] Link to GLVND instead of legacy OpenGL + +--- + distro/superbuild/cmake/externals.cmake | 1 + + src/app/CMakeLists.txt | 5 ++++- + src/vtk/DRCFilters/CMakeLists.txt | 11 +++++++---- + 3 files changed, 12 insertions(+), 5 deletions(-) + +diff --git a/distro/superbuild/cmake/externals.cmake b/distro/superbuild/cmake/externals.cmake +index 7b35aee1..6dbb180c 100644 +--- a/distro/superbuild/cmake/externals.cmake ++++ b/distro/superbuild/cmake/externals.cmake +@@ -267,6 +267,7 @@ ExternalProject_Add(PythonQt + ${default_cmake_args} + ${qt_args} + ${python_args} ++ -DOpenGL_GL_PREFERENCE:STRING=GLVND + -DPythonQt_Wrap_Qtcore:BOOL=ON + -DPythonQt_Wrap_Qtgui:BOOL=ON + -DPythonQt_Wrap_Qtuitools:BOOL=ON +diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt +index d89b8cb8..e2f74c97 100644 +--- a/src/app/CMakeLists.txt ++++ b/src/app/CMakeLists.txt +@@ -1,5 +1,6 @@ + find_package(PythonQt REQUIRED) + find_package(CTKPythonConsole REQUIRED) ++set(OpenGL_GL_PREFERENCE GLVND) + find_package(OpenGL REQUIRED) + find_package(QtPropertyBrowser REQUIRED) + if(DD_QT_VERSION EQUAL 4) +@@ -156,7 +157,9 @@ set(deps + ${CTK_PYTHONCONSOLE_LIBRARIES} + ${PYTHONQT_LIBRARIES} + ${QTPROPERTYBROWSER_LIBRARY} +- ${OPENGL_LIBRARIES} ++ OpenGL::GLU ++ OpenGL::GLX ++ OpenGL::OpenGL + ${VTK_LIBRARIES} + ) + +diff --git a/src/vtk/DRCFilters/CMakeLists.txt b/src/vtk/DRCFilters/CMakeLists.txt +index 52e71541..7ebf9695 100644 +--- a/src/vtk/DRCFilters/CMakeLists.txt ++++ b/src/vtk/DRCFilters/CMakeLists.txt +@@ -3,6 +3,7 @@ + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + ++set(OpenGL_GL_PREFERENCE GLVND) + find_package(OpenGL REQUIRED) + + find_package(Eigen REQUIRED) +@@ -86,7 +87,9 @@ set(VTK_LIBRARIES + + set(deps + ${VTK_LIBRARIES} +- ${OPENGL_LIBRARIES} ++ OpenGL::GLU ++ OpenGL::GLX ++ OpenGL::OpenGL + ) + + set(pkg_deps) +@@ -164,7 +167,7 @@ if(USE_LCMGL) + include_directories(${LIBBOT_INCLUDE_DIRS}) + list(APPEND sources vtkLCMGLProp.cxx) + list(APPEND headers vtkLCMGLProp.h) +- list(APPEND deps ${LIBBOT_LIBRARIES} ${OPENGL_LIBRARIES}) ++ list(APPEND deps ${LIBBOT_LIBRARIES} OpenGL::GLX OpenGL::GLU OpenGL::OpenGL) + + endif() + +@@ -175,7 +178,7 @@ if(USE_OCTOMAP) + find_library(OCTOVIS_LIBRARY octovis) + list(APPEND sources vtkOctomap.cxx) + list(APPEND headers vtkOctomap.h) +- list(APPEND deps ${LIBBOT_LIBRARIES} ${OPENGL_LIBRARIES} ${OCTOVIS_LIBRARY}) ++ list(APPEND deps ${LIBBOT_LIBRARIES} OpenGL::GLX OpenGL::GLU OpenGL::OpenGL ${OCTOVIS_LIBRARY}) + + list(APPEND pkg_deps + lcmtypes_octomap-utils +@@ -187,7 +190,7 @@ if (USE_COLLECTIONS) + + list(APPEND sources vtkCollections.cxx) + list(APPEND headers vtkCollections.h) +- list(APPEND deps ${OPENGL_LIBRARIES}) ++ list(APPEND deps OpenGL::GLX OpenGL::GLU OpenGL::OpenGL) + + list(APPEND pkg_deps + lcmtypes_visualization diff --git a/tools/workspace/drake_visualizer/0002-dv-externals-warnings.patch b/tools/workspace/drake_visualizer/0002-dv-externals-warnings.patch new file mode 100644 index 000000000000..38368d2575a7 --- /dev/null +++ b/tools/workspace/drake_visualizer/0002-dv-externals-warnings.patch @@ -0,0 +1,250 @@ +From 11f988658c1d659d2172aa9d265fe03408e6448c Mon Sep 17 00:00:00 2001 +From: Jamie Snape +Date: Wed, 7 Mar 2018 12:00:00 -0400 +Subject: [PATCH] Suppress git, deprecated, and dev warnings from external projects + +--- + distro/superbuild/cmake/externals.cmake | 80 ++++++++++++++++++++++++++++++++- + 1 file changed, 78 insertions(+), 2 deletions(-) + +diff --git a/distro/superbuild/cmake/externals.cmake b/distro/superbuild/cmake/externals.cmake +index 7af04b68..61fa5d00 100644 +--- a/distro/superbuild/cmake/externals.cmake ++++ b/distro/superbuild/cmake/externals.cmake +@@ -97,6 +97,9 @@ ExternalProject_Add( + eigen + URL https://bitbucket.org/eigen/eigen/get/3.3.3.tar.gz + URL_MD5 f21cee193e15e55cfd15ebbc16fc00a7 ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${qt_args} +@@ -139,7 +142,11 @@ if (USE_LCM AND NOT USE_SYSTEM_LCM) + ExternalProject_Add(lcm + GIT_REPOSITORY https://github.com/lcm-proj/lcm.git + GIT_TAG c0a0093 ++ GIT_CONFIG advice.detachedHead=false + ${cmake3_args} ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + -DLCM_ENABLE_EXAMPLES:BOOL=OFF + -DLCM_ENABLE_LUA:BOOL=OFF +@@ -168,6 +175,10 @@ if(USE_LIBBOT AND NOT USE_SYSTEM_LIBBOT) + ExternalProject_Add(libbot + GIT_REPOSITORY https://github.com/RobotLocomotion/libbot2.git + GIT_TAG 4835477 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + -DWITH_BOT_VIS:BOOL=OFF +@@ -189,7 +200,11 @@ if (USE_LCM AND NOT USE_SYSTEM_LIBBOT) + ExternalProject_Add(bot_core_lcmtypes + GIT_REPOSITORY https://github.com/openhumanoids/bot_core_lcmtypes + GIT_TAG 9967654 ++ GIT_CONFIG advice.detachedHead=false + ${cmake3_args} ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${python_args} +@@ -205,7 +220,11 @@ if (USE_LCM AND NOT USE_SYSTEM_LIBBOT) + ExternalProject_Add(robotlocomotion-lcmtypes + GIT_REPOSITORY https://github.com/robotlocomotion/lcmtypes.git + GIT_TAG 821ff4b ++ GIT_CONFIG advice.detachedHead=false + ${cmake3_args} ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${python_args} +@@ -230,6 +249,7 @@ if(USE_STANDALONE_LCMGL) + ExternalProject_Add(bot-lcmgl-download + GIT_REPOSITORY https://github.com/RobotLocomotion/libbot.git + GIT_TAG 4835477 ++ GIT_CONFIG advice.detachedHead=false + SOURCE_DIR ${source_prefix}/bot-lcmgl + CONFIGURE_COMMAND "" + BUILD_COMMAND "" +@@ -241,6 +261,9 @@ if(USE_STANDALONE_LCMGL) + DOWNLOAD_COMMAND "" + UPDATE_COMMAND "" + DEPENDS bot-lcmgl-download ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + -DUSE_BOT_VIS:BOOL=OFF +@@ -263,6 +286,10 @@ endif() + ExternalProject_Add(PythonQt + GIT_REPOSITORY https://github.com/commontk/PythonQt.git + GIT_TAG ${PythonQt_TAG} ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${qt_args} +@@ -285,6 +312,10 @@ endif() + ExternalProject_Add(ctkPythonConsole + GIT_REPOSITORY https://github.com/patmarion/ctkPythonConsole + GIT_TAG ${ctkPythonConsole_TAG} ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${qt_args} +@@ -305,6 +336,10 @@ endif() + ExternalProject_Add(QtPropertyBrowser + GIT_REPOSITORY https://github.com/patmarion/QtPropertyBrowser + GIT_TAG ${QtPropertyBrowser_TAG} ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${qt_args} +@@ -386,7 +421,10 @@ else() + ExternalProject_Add(vtk + GIT_REPOSITORY git://vtk.org/VTK.git + GIT_TAG v8.2.0 +- ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${python_args} +@@ -422,6 +460,10 @@ if(USE_PCL AND NOT USE_SYSTEM_PCL) + flann + GIT_REPOSITORY http://github.com/mariusmuja/flann + GIT_TAG cee08ec38a8df7bc70397f10a4d30b9b33518bb4 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${boost_args} +@@ -460,6 +502,10 @@ if(USE_PCL AND NOT USE_SYSTEM_PCL) + pcl + GIT_REPOSITORY http://github.com/pointcloudlibrary/pcl.git + GIT_TAG pcl-1.8.1 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${eigen_args} +@@ -494,6 +540,10 @@ if(USE_PCL) + ExternalProject_Add(PointCloudLibraryPlugin + GIT_REPOSITORY https://github.com/patmarion/PointCloudLibraryPlugin.git + GIT_TAG 7bd45c3 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${eigen_args} +@@ -518,7 +568,11 @@ if(USE_OPENNI2_LCM) + ExternalProject_Add(openni2-camera-lcm + GIT_REPOSITORY https://github.com/openhumanoids/openni2-camera-lcm + GIT_TAG 6bd5573 ++ GIT_CONFIG advice.detachedHead=false + ${cmake3_args} ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + -DINSTALL_BOT_SPY:BOOL=OFF +@@ -533,6 +587,10 @@ if(USE_PERCEPTION) + ExternalProject_Add(cv-utils + GIT_REPOSITORY https://github.com/patmarion/cv-utils.git + GIT_TAG c4939fedf66c767de15607adde3aff44ab2b503b ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + DEPENDS +@@ -552,6 +610,10 @@ if(USE_APRILTAGS) + ExternalProject_Add(apriltags + GIT_REPOSITORY https://github.com/psiorx/apriltags-pod.git + GIT_TAG 8534e91 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ) +@@ -559,6 +621,10 @@ if(USE_APRILTAGS) + ExternalProject_Add(apriltags_driver + GIT_REPOSITORY https://github.com/patmarion/apriltags_driver.git + GIT_TAG fb0eff3 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + DEPENDS +@@ -576,13 +642,17 @@ if(USE_SIGNAL_SCOPE) + ExternalProject_Add(signal-scope + GIT_REPOSITORY https://github.com/openhumanoids/signal-scope.git + GIT_TAG a0bc791 ++ GIT_CONFIG advice.detachedHead=false ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${python_args} + ${qt_args} + -DUSED_QTVERSION:STRING=${DD_QT_VERSION} + DEPENDS +- ctkPythonConsole ++ ctkPythonConsole + PythonQt + ) + +@@ -596,6 +666,9 @@ ExternalProject_Add(director + SOURCE_DIR ${Superbuild_SOURCE_DIR}/../.. + DOWNLOAD_COMMAND "" + ${cmake3_args} ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + + -DUSE_LCM:BOOL=${USE_LCM} +@@ -634,6 +707,9 @@ if (USE_ROS) + SOURCE_DIR ${Superbuild_SOURCE_DIR}/../../catkin_ws/src + DOWNLOAD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/src/director_ros-build/devel/lib/libddROSPlugin${CMAKE_SHARED_LIBRARY_SUFFIX} ${install_prefix}/lib ++ CMAKE_ARGS ++ -Wno-deprecated ++ -Wno-dev + CMAKE_CACHE_ARGS + ${default_cmake_args} + ${vtk_args} diff --git a/tools/workspace/drake_visualizer/0003-dv-externals-module-linker-flags.patch b/tools/workspace/drake_visualizer/0003-dv-externals-module-linker-flags.patch new file mode 100644 index 000000000000..5b384c345c0d --- /dev/null +++ b/tools/workspace/drake_visualizer/0003-dv-externals-module-linker-flags.patch @@ -0,0 +1,21 @@ +From 11f988658c1d659d2172aa9d265fe03408e6448c Mon Sep 17 00:00:00 2001 +From: Jamie Snape +Date: Wed, 7 Mar 2018 12:00:00 -0400 +Subject: [PATCH] Pass CMAKE_MODULE_LINKER_FLAGS to external projects + +--- + distro/superbuild/cmake/externals.cmake | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/distro/superbuild/cmake/externals.cmake b/distro/superbuild/cmake/externals.cmake +index 61fa5d00..4d76cda7 100644 +--- a/distro/superbuild/cmake/externals.cmake ++++ b/distro/superbuild/cmake/externals.cmake +@@ -50,6 +50,7 @@ set(default_cmake_args + "-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}" + "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}" + "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}" ++ "-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS}" + "-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}" + "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + ) diff --git a/tools/workspace/drake_visualizer/Dockerfile b/tools/workspace/drake_visualizer/Dockerfile new file mode 100644 index 000000000000..ed136499cd67 --- /dev/null +++ b/tools/workspace/drake_visualizer/Dockerfile @@ -0,0 +1,220 @@ +# This Dockerfile and the accompanying shell script and patch files are used by +# the project maintainers to create the precompiled drake-visualizer binaries +# that are downloaded during the build. They are neither called during the +# build nor expected to be called by most developers or users of the project. + +# The vtk tar.gz archive for ${UBUNTU_CODENAME} must have been copied or +# downloaded to same directory as this Dockerfile before calling docker build. + +ARG UBUNTU_CODENAME=bionic +FROM ubuntu:${UBUNTU_CODENAME} +# TODO(jamiesnape): Decoupling this from the VTK build has lead to an explosion +# of non-obvious dependencies. We need to re-think directory structure and +# share common instructions if we keep building our own VTK. +# +# Note that we often use a development package even though we only need a +# runtime package since the development package names are usually the same in +# multiple Ubuntu distributions. +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update --quiet --quiet \ + && apt-get install --no-install-recommends --quiet --yes \ + ca-certificates \ + chrpath \ + default-jdk \ + file \ + g++ \ + gcc \ + git \ + gnupg \ + libdouble-conversion-dev \ + libeigen3-dev \ + libexpat1-dev \ + libfreetype6-dev \ + libgl1-mesa-dev \ + libglew-dev \ + libglib2.0-dev \ + libglu1-mesa-dev \ + libglvnd-dev \ + libhdf5-dev \ + libjpeg-turbo8-dev \ + libjpeg8-dev \ + libjsoncpp-dev \ + liblz4-dev \ + liblzma-dev \ + libnetcdf-dev \ + libogg-dev \ + libpng-dev \ + libqt5opengl5-dev \ + libqt5x11extras5-dev \ + libsqlite3-dev \ + libtbb-dev \ + libtheora-dev \ + libtiff5-dev \ + libutfcpp-dev \ + libxml2-dev \ + libxt-dev \ + lsb-release \ + ninja-build \ + patchelf \ + python3-dev \ + python3-lxml \ + python3-numpy \ + python3-scipy \ + python3-yaml \ + qt5-default \ + qtbase5-private-dev \ + qtmultimedia5-dev \ + qttools5-dev \ + unzip \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* +# Note that we need a recent CMake to ensure we get the updated FindOpenGL and +# therefore link the correct flavor of OpenGL library (GLVND). With the version +# of CMake from the the Ubuntu distribution, we would need even more drastic +# patching of drake-visualizer. +RUN export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 \ + && apt-key --keyring /etc/apt/trusted.gpg.d/bazel.gpg adv --quiet \ + --fetch-keys https://bazel.build/bazel-release.pub.gpg \ + && apt-key --keyring /etc/apt/trusted.gpg.d/kitware.gpg adv --quiet \ + --fetch-keys https://apt.kitware.com/keys/kitware-archive-latest.asc \ + && echo 'deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8' \ + > /etc/apt/sources.list.d/bazel.list \ + && echo "deb https://apt.kitware.com/ubuntu $(lsb_release --codename --short) main" \ + > /etc/apt/sources.list.d/kitware.list \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get update --quiet --quiet \ + && apt-get install --no-install-recommends --quiet --yes \ + bazel \ + cmake \ + && rm -rf /var/lib/apt/lists/* +# Note that we symlink /usr/bin/python since the package names to install an +# executable named as such are not the same in different Ubuntu packages. The +# actual version of Python does not matter, either 2 or 3 would fix Bazel. +# +# Note that we use LCM and its dependency JChart2D from Drake, partly due to +# mangled name of the LCM library in Drake. We do not use JChart2D, but +# "find_package(LCM)" would fail without it. LCM is LGPL 2.1 so we +# should not link it statically like we do for the other C/C++ dependencies of +# drake-visualizer. +# +# TODO(jamiesnape): Maybe we should bundle a separate version anyway, but are +# different LCM versions always compatible with Drake? +# +# Note that the added options are to follow the Debian build hardening +# guidelines, which is good practice anyway. +RUN git clone --depth 1 --quiet https://github.com/RobotLocomotion/drake.git \ + /drake \ + && ln /usr/bin/python3 /usr/bin/python \ + && cd /drake \ + && bazel run \ + --copt=-fstack-protector-strong \ + --host_copt=-fstack-protector-strong \ + --linkopt=-Wl,-Bsymbolic-functions \ + --linkopt=-Wl,-z,now \ + --linkopt=-Wl,-z,relro \ + @lcm//:install -- /opt/drake 2>&1 \ + && bazel run \ + --copt=-fstack-protector-strong \ + --host_copt=-fstack-protector-strong \ + --linkopt=-Wl,-Bsymbolic-functions \ + --linkopt=-Wl,-z,now \ + --linkopt=-Wl,-z,relro \ + //tools/workspace/net_sf_jchart2d:install -- /opt/drake 2>&1 \ + && bazel clean --expunge 2>&1 \ + && bazel shutdown \ + && rm -rf /drake /root/.cache /usr/bin/python +# Copy the prebuilt VTK binary from the build context to the container. +# +# TODO(jamiesnape): Maybe we should bundle a version of VTK or use a system +# version, both of which would be huge in size, regardless. +COPY vtk-*.tar.gz /tmp/ +RUN tar --extract --gzip --directory /opt/drake \ + --file /tmp/vtk-*-$(lsb_release --codename --short)-*.tar.gz \ + && rm -rf /tmp/vtk-*.tar.gz +# Copy any patches to drake-visualizer from the build context to the container. +COPY *.patch /director-patch/ +RUN git clone --branch master --config advice.detachedHead=false --quiet \ + --single-branch https://github.com/RobotLocomotion/director.git /director \ + && git -C /director checkout 4c3e570a6797ff840c74067c742455daaa113d93 \ + && git -C /director apply /director-patch/*.patch \ + && rm -rf /director-patch +# Note that some flags are added to "CMAKE_CXX_FLAGS", etc., rather than their +# usual variables (e.g., "CMAKE_CXX_STANDARD") since drake-visualizer does not +# pass those flags down to its external project builds. +# +# Note that most added flags are to follow the Debian build hardening +# guidelines, which is good practice anyway. +# +# TODO(jamiesnape): The flag "-isystem/opt/drake/include/lcm" should not be +# necessary. Something is wrong somewhere. +# +# Note that we remove several installed components that are either broken, +# unused by Drake, or duplicated by Drake. Exactly which are broken vs. unused +# vs. duplicated has been lost in time, may be wrong now. +# +# TODO(jamiesnape): Maybe we should bundle some of the duplicate components +# anyway. +# +# Note that we have to manually call "strip" since there is no "install/strip" +# target when building drake-visualizer and its dependencies as external +# projects. +# +# TODO(jamiesnape): Honestly, the RPATHs should not need separate patching, but +# CMake has been changed substantially since drake-visualizer was written and +# it handles things differently and more correctly now, thankfully. +RUN mkdir -p /director-build /opt/director \ + && cmake \ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DCMAKE_BUILD_TYPE:STRING=Release \ + -DCMAKE_C_FLAGS:STRING='-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wno-deprecated-declarations -Wno-format-security' \ + -DCMAKE_CXX_FLAGS:STRING='-D_FORTIFY_SOURCE=2 -fstack-protector-strong -isystem/opt/drake/include/lcm -Wno-conversion-null -Wno-deprecated-declarations -Wno-format-security -std=c++17' \ + -DCMAKE_EXE_LINKER_FLAGS:STRING='-Wl,--as-needed -Wl,-Bsymbolic-functions -Wl,-z,now -Wl,-z,relro' \ + -DCMAKE_INSTALL_PREFIX:PATH=/opt/director \ + -DCMAKE_MODULE_LINKER_FLAGS:STRING='-Wl,--as-needed -Wl,-Bsymbolic-functions -Wl,-z,now -Wl,-z,relro' \ + -DCMAKE_PREFIX_PATH:PATH=/opt/drake \ + -DCMAKE_SHARED_LINKER_FLAGS:STRING='-Wl,--as-needed -Wl,-Bsymbolic-functions -Wl,-z,now -Wl,-z,relro' \ + -DDD_QT_VERSION:STRING=5 \ + -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 \ + -DUSE_EXTERNAL_INSTALL:BOOL=ON \ + -DUSE_LCM:BOOL=ON \ + -DUSE_LCMGL:BOOL=OFF \ + -DUSE_LIBBOT:BOOL=OFF \ + -DUSE_SYSTEM_EIGEN:BOOL=ON \ + -DUSE_SYSTEM_LCM:BOOL=ON \ + -DUSE_SYSTEM_LIBBOT:BOOL=OFF \ + -DUSE_SYSTEM_VTK:BOOL=ON \ + -DVTK_DIR:PATH=/opt/drake/lib/cmake/vtk-8.2 \ + -GNinja \ + -Wno-deprecated \ + -Wno-dev \ + -S /director/distro/superbuild \ + -B /director-build \ + && export PYTHONWARNINGS=ignore::SyntaxWarning \ + && ninja -C /director-build \ + && rm -rf \ + /director \ + /director-build \ + /opt/director/bin/directorPython \ + /opt/director/include \ + /opt/director/lib/*.a \ + /opt/director/lib/bot2-core \ + /opt/director/lib/cmake \ + /opt/director/lib/pkgconfig \ + /opt/director/lib/python3 \ + /opt/director/lib/robotlocomotion-lcmtypes \ + && find /opt/director -name __pycache__ -type d -exec rm -rf {} + \ + && strip \ + /opt/director/bin/drake-visualizer \ + /opt/director/lib/*.so \ + /opt/director/lib/python3.*/site-packages/director/*.so \ + /opt/director/lib/python3.*/site-packages/director/thirdparty/*.so \ + && chrpath --replace '$ORIGIN/../lib' /opt/director/bin/drake-visualizer \ + && chrpath --replace '$ORIGIN' /opt/director/lib/libddApp.so \ + && chrpath --replace '$ORIGIN/../../..' \ + /opt/director/lib/python3.*/site-packages/director/vtkDRCFiltersPython.so \ + && chrpath --delete \ + /opt/director/lib/python3.*/site-packages/director/thirdparty/*.so +# Create archive named dv--python--qt- +# -vtk---.tar.gz, +RUN cd /opt/director \ + && tar --create --gzip --file dv-0.1.0-406-g4c3e570a-python-$(python3 --version 2>&1 | sed --quiet --expression 's/^.*\n*Python \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1.\2.\3/p')-qt-$(qmake --version | sed --quiet --expression 's/^.*\n*Qt version \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1.\2.\3/p')-vtk-8.2.0-$(lsb_release --codename --short)-$(uname --processor).tar.gz -- * diff --git a/tools/workspace/drake_visualizer/build_binaries_with_docker b/tools/workspace/drake_visualizer/build_binaries_with_docker new file mode 100755 index 000000000000..566fdfec26bb --- /dev/null +++ b/tools/workspace/drake_visualizer/build_binaries_with_docker @@ -0,0 +1,43 @@ +#!/bin/bash + +# This shell script and the accompanying Dockerfile and patch files are used by +# the project maintainers to create the precompiled drake-visualizer binaries +# that are downloaded during the build. They are neither called during the +# build nor expected to be called by most developers or users of the project. + +# Ensure you have docker(1) installed (apt-get install docker.io or brew +# install [--cask] docker), shasum(1) installed (apt-get install +# libdigest-sha-perl), and the vtk tar.gz archives for both bionic and focal +# have been copied or downloaded to same directory as this shell script. + +set -euxo pipefail + +rm -f dv-*-x86_64.tar.gz dv-*-x86_64.tar.gz.sha256 + +if ! compgen -G "${BASH_SOURCE%/*}/vtk-*-bionic-x86_64.tar.gz" &> /dev/null; then + echo 'ERROR: vtk tar.gz archive for bionic x86_64 was NOT found. Please copy or download it to the same directory as this script.' >&2 + exit 1; +fi + +docker build --build-arg UBUNTU_CODENAME=bionic --tag dv-bionic "${BASH_SOURCE%/*}" +trap 'docker rmi dv-bionic' EXIT +docker run --detach --name dv-bionic-build --tty dv-bionic +trap 'docker rm --force dv-bionic-build && docker rmi dv-bionic' EXIT +docker cp dv-bionic-build:$(docker exec dv-bionic-build \ + find /opt/director/ -maxdepth 1 -name 'dv-*-bionic-x86_64.tar.gz') . + +shasum --algorithm 256 dv-*-bionic-x86_64.tar.gz | tee dv-bionic-x86_64.tar.gz.sha256 + +if ! compgen -G "${BASH_SOURCE%/*}/vtk-*-focal-x86_64.tar.gz" &> /dev/null; then + echo 'ERROR: vtk tar.gz archive for focal x86_64 was NOT found. Please copy or download it to the same directory as this script.' >&2 + exit 2; +fi + +docker build --build-arg UBUNTU_CODENAME=focal --tag dv-focal "${BASH_SOURCE%/*}" +trap 'docker rmi dv-focal && docker rm --force dv-bionic-build && docker rmi dv-bionic' EXIT +docker run --detach --name dv-focal-build --tty dv-focal +trap 'docker rm --force dv-focal-build && docker rmi dv-focal && docker rm --force dv-bionic-build && docker rmi dv-bionic' EXIT +docker cp dv-focal-build:$(docker exec dv-focal-build \ + find /opt/director/ -maxdepth 1 -name 'dv-*-focal-x86_64.tar.gz') . + +shasum --algorithm 256 dv-*-focal-x86_64.tar.gz | tee dv-focal-x86_64.tar.gz.sha256