Skip to content

Commit 765fd7a

Browse files
amessing-bdaimhidalgo-rai
authored andcommitted
Update devcontainers for building debians (#4)
* Working towards depending on apt packages * Updates * Restore Spot C++ SDK builds Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com> * Remove unused gRPC CMake module Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com> * Restore cli11 dependency Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com> * Remove vcpkg reference in CPack config Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com> * Update arm version of the docker image --------- Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com> Co-authored-by: Michel Hidalgo <mhidalgo@theaiinstitute.com>
1 parent e363bcf commit 765fd7a

9 files changed

Lines changed: 165 additions & 71 deletions

File tree

.devcontainer/Dockerfile.amd64

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
FROM ubuntu:22.04
22

3-
RUN apt-get update --fix-missing &&\
4-
apt-get install -y --no-install-recommends build-essential ca-certificates git g++ pkg-config python3 curl ninja-build tar zip unzip zlib1g-dev libssl-dev wget &&\
5-
apt-get autoclean &&\
6-
apt-get autoremove &&\
7-
apt-get clean &&\
8-
rm -rf /var/lib/apt/lists/*
3+
RUN apt-get update --fix-missing \
4+
&& apt-get install -y --no-install-recommends \
5+
build-essential \
6+
ca-certificates \
7+
cmake \
8+
git \
9+
libcli11-dev \
10+
libeigen3-dev \
11+
libgrpc++-dev \
12+
libprotobuf-dev \
13+
g++ \
14+
pkg-config \
15+
protobuf-compiler \
16+
protobuf-compiler-grpc \
17+
python3 \
18+
curl \
19+
ninja-build \
20+
tar \
21+
zip \
22+
unzip \
23+
zlib1g-dev \
24+
libssl-dev \
25+
wget \
26+
&& apt-get autoclean \
27+
&& apt-get autoremove \
28+
&& apt-get clean \
29+
&& rm -rf /var/lib/apt/lists/*
930

1031
RUN update-ca-certificates
1132

12-
RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
13-
tar -xzf cmake-3.28.3.tar.gz &&\
14-
cd cmake-3.28.3 &&\
15-
./configure &&\
16-
make install &&\
17-
cd .. &&\
18-
rm cmake-3.28.3.tar.gz &&\
19-
rm -r cmake-3.28.3
20-
21-
RUN git clone https://github.com/microsoft/vcpkg &&\
22-
cd vcpkg &&\
23-
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
24-
./bootstrap-vcpkg.sh -disableMetrics &&\
25-
./vcpkg install grpc:x64-linux &&\
26-
./vcpkg install eigen3:x64-linux &&\
27-
./vcpkg install cli11:x64-linux
33+
COPY entrypoint.sh .
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt-get update --fix-missing &&\
4+
apt-get install -y --no-install-recommends build-essential ca-certificates git g++ pkg-config python3 curl ninja-build tar zip unzip zlib1g-dev libssl-dev wget &&\
5+
apt-get autoclean &&\
6+
apt-get autoremove &&\
7+
apt-get clean &&\
8+
rm -rf /var/lib/apt/lists/*
9+
10+
RUN update-ca-certificates
11+
12+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
13+
tar -xzf cmake-3.28.3.tar.gz &&\
14+
cd cmake-3.28.3 &&\
15+
./configure &&\
16+
make install &&\
17+
cd .. &&\
18+
rm cmake-3.28.3.tar.gz &&\
19+
rm -r cmake-3.28.3
20+
21+
RUN git clone https://github.com/microsoft/vcpkg &&\
22+
cd vcpkg &&\
23+
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
24+
./bootstrap-vcpkg.sh -disableMetrics &&\
25+
./vcpkg install grpc:x64-linux &&\
26+
./vcpkg install eigen3:x64-linux &&\
27+
./vcpkg install cli11:x64-linux

.devcontainer/Dockerfile.arm64

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
FROM arm64v8/ubuntu:22.04
2-
SHELL ["/bin/bash", "-c"]
32

4-
RUN apt-get update --fix-missing &&\
5-
apt-get install -y --no-install-recommends build-essential ca-certificates cmake git g++ pkg-config python3 curl ninja-build tar zip unzip zlib1g-dev libssl-dev wget &&\
6-
apt-get autoclean &&\
7-
apt-get autoremove &&\
8-
apt-get clean &&\
9-
rm -rf /var/lib/apt/lists/*
3+
RUN apt-get update --fix-missing \
4+
&& apt-get install -y --no-install-recommends \
5+
build-essential \
6+
ca-certificates \
7+
cmake \
8+
git \
9+
libcli11-dev \
10+
libeigen3-dev \
11+
libgrpc++-dev \
12+
libprotobuf-dev \
13+
g++ \
14+
pkg-config \
15+
protobuf-compiler \
16+
protobuf-compiler-grpc \
17+
python3 \
18+
curl \
19+
ninja-build \
20+
tar \
21+
zip \
22+
unzip \
23+
zlib1g-dev \
24+
libssl-dev \
25+
wget \
26+
&& apt-get autoclean \
27+
&& apt-get autoremove \
28+
&& apt-get clean \
29+
&& rm -rf /var/lib/apt/lists/*
1030

1131
RUN update-ca-certificates
1232

13-
RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
14-
tar -xzf cmake-3.28.3.tar.gz &&\
15-
cd cmake-3.28.3 &&\
16-
./configure &&\
17-
make install &&\
18-
cd .. &&\
19-
rm cmake-3.28.3.tar.gz &&\
20-
rm -r cmake-3.28.3
21-
22-
RUN git clone https://github.com/microsoft/vcpkg &&\
23-
cd vcpkg &&\
24-
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
25-
export VCPKG_FORCE_SYSTEM_BINARIES=arm &&\
26-
./bootstrap-vcpkg.sh -disableMetrics &&\
27-
./vcpkg install grpc:arm64-linux &&\
28-
./vcpkg install eigen3:arm64-linux &&\
29-
./vcpkg install cli11:arm64-linux
33+
COPY entrypoint.sh .
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM arm64v8/ubuntu:22.04
2+
SHELL ["/bin/bash", "-c"]
3+
4+
RUN apt-get update --fix-missing &&\
5+
apt-get install -y --no-install-recommends build-essential ca-certificates cmake git g++ pkg-config python3 curl ninja-build tar zip unzip zlib1g-dev libssl-dev wget &&\
6+
apt-get autoclean &&\
7+
apt-get autoremove &&\
8+
apt-get clean &&\
9+
rm -rf /var/lib/apt/lists/*
10+
11+
RUN update-ca-certificates
12+
13+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
14+
tar -xzf cmake-3.28.3.tar.gz &&\
15+
cd cmake-3.28.3 &&\
16+
./configure &&\
17+
make install &&\
18+
cd .. &&\
19+
rm cmake-3.28.3.tar.gz &&\
20+
rm -r cmake-3.28.3
21+
22+
RUN git clone https://github.com/microsoft/vcpkg &&\
23+
cd vcpkg &&\
24+
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
25+
export VCPKG_FORCE_SYSTEM_BINARIES=arm &&\
26+
./bootstrap-vcpkg.sh -disableMetrics &&\
27+
./vcpkg install grpc:arm64-linux &&\
28+
./vcpkg install eigen3:arm64-linux &&\
29+
./vcpkg install cli11:arm64-linux

.devcontainer/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
ARCH=$(dpkg --print-architecture)
3+
4+
if [ "$ARCH" == "amd64" ]; then
5+
docker build -t spot_builder -f Dockerfile.amd64 .
6+
elif [ "$ARCH" == "arm64" ]; then
7+
docker build -t spot_builder -f Dockerfile.arm64 .
8+
else
9+
echo "Unknown architecture: $ARCH" > /dev/stderr
10+
exit 1
11+
fi
12+
13+
docker run -v ~/spot-cpp-sdk:/spot-cpp-sdk spot_builder /entrypoint.sh

.devcontainer/entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
cd /spot-cpp-sdk/cpp
3+
if [ -d build ]; then
4+
rm -r build
5+
fi
6+
mkdir build
7+
cd build
8+
cmake .. -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE -DBUILD_CHOREOGRAPHY_LIBS=ON -DBUILD_SHARED_LIBS=ON
9+
make -j8 install package

cpp/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

cpp/CMakeLists.txt

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ cmake_minimum_required (VERSION 3.10.2)
1010
project (bosdyn VERSION 5.1.1)
1111

1212
# Dependencies:
13-
find_package(protobuf REQUIRED)
13+
find_package(Protobuf REQUIRED)
1414
find_package(Eigen3 REQUIRED)
15-
find_package(gRPC REQUIRED)
15+
16+
find_package(PkgConfig REQUIRED)
17+
pkg_check_modules(GRPC REQUIRED grpc)
18+
pkg_check_modules(GRPCPP REQUIRED grpc++)
19+
find_program(GRPC_CPP_PLUGIN_LOCATION grpc_cpp_plugin REQUIRED)
1620
find_package(CLI11 REQUIRED)
1721
find_package(Threads REQUIRED)
18-
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
22+
1923
include_directories(SYSTEM $<TARGET_PROPERTY:CLI11::CLI11,INTERFACE_INCLUDE_DIRECTORIES>)
2024

2125
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
@@ -24,37 +28,35 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS true)
2428
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
2529
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
2630
option(BUILD_CHOREOGRAPHY_LIBS "Boolean to control whether choreography proto libraries are built" ON)
31+
option(BUILD_EXAMPLES "Boolean to control whether examples are built" OFF)
2732

2833
IF (NOT UNIX)
2934
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Build using shared libraries" FORCE)
3035
ENDIF (NOT UNIX)
3136

3237
include(GNUInstallDirs)
3338

34-
3539
### API protos LIBRARY ###
36-
set(API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/protos/)
37-
# Copy protos folders to build folder so they are in a subdirectory from the cpp folder (necessary for the proto cpp files generation).
38-
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../protos/ DESTINATION ${API_protos_PATH})
40+
get_filename_component(API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../protos/ ABSOLUTE)
41+
file(GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS "${API_protos_PATH}/*.proto")
3942
set(protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/protos)
4043
file(MAKE_DIRECTORY ${protos_OUTPUT_DIR})
41-
file(GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS
42-
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${API_protos_PATH}/*.proto")
43-
4444
if (bosdyn_protos_files)
4545
add_library(bosdyn_api_obj OBJECT ${bosdyn_protos_files})
4646
set_property(TARGET bosdyn_api_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
47-
target_link_libraries(bosdyn_api_obj PUBLIC protobuf::libprotobuf gRPC::grpc gRPC::grpc++)
47+
target_link_libraries(bosdyn_api_obj PUBLIC protobuf::libprotobuf ${GRPC_LINK_LIBRARIES} ${GRPCPP_LINK_LIBRARIES})
4848
target_include_directories(bosdyn_api_obj PUBLIC
49+
${GRPC_INCLUDE_DIRS} ${GRPCPP_INCLUDE_DIRS}
4950
$<BUILD_INTERFACE:${protos_OUTPUT_DIR}>
5051
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
5152
)
5253
protobuf_generate(TARGET bosdyn_api_obj LANGUAGE cpp
53-
IMPORT_DIRS ${API_protos_PATH}
54-
PROTOC_OUT_DIR ${protos_OUTPUT_DIR})
54+
IMPORT_DIRS ${API_protos_PATH}
55+
PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
56+
)
5557
protobuf_generate(TARGET bosdyn_api_obj
5658
LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
57-
PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}"
59+
PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION}"
5860
IMPORT_DIRS ${API_protos_PATH}
5961
PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
6062
)
@@ -93,13 +95,11 @@ endif()
9395
if (BUILD_CHOREOGRAPHY_LIBS)
9496

9597
### API choreography_protos LIBRARY ###
96-
set(API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/choreography_protos/)
97-
# Copy choreography_protos folders to build folder so they are in a subdirectory from the cpp folder (necessary for the proto cpp files generation).
98-
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../choreography_protos/ DESTINATION ${API_choreography_protos_PATH})
98+
get_filename_component(API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../choreography_protos/ ABSOLUTE)
99+
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH}/*.proto")
99100
set(choreography_protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/choreography_protos)
100101
file(MAKE_DIRECTORY ${choreography_protos_OUTPUT_DIR})
101-
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS
102-
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${API_choreography_protos_PATH}/*.proto")
102+
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH}/*.proto")
103103

104104
if (bosdyn_choreography_protos_files)
105105
add_library(bosdyn_choreography_protos_obj OBJECT ${bosdyn_choreography_protos_files})
@@ -114,7 +114,7 @@ if (bosdyn_choreography_protos_files)
114114
PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR})
115115
protobuf_generate(TARGET bosdyn_choreography_protos_obj
116116
LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
117-
PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}"
117+
PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION}"
118118
IMPORT_DIRS ${API_choreography_protos_PATH}
119119
PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR}
120120
)
@@ -193,7 +193,11 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bosdyn
193193
)
194194

195195

196+
include(CMakePackageConfigHelpers)
197+
196198
### EXAMPLE EXECUTABLES ###
199+
if(BUILD_EXAMPLES)
200+
197201
link_directories(
198202
${PROTOBUF_LIB_DIR}
199203
)
@@ -210,6 +214,7 @@ target_compile_features(arm_manipulation_api_walk_to PUBLIC cxx_std_17)
210214
target_include_directories(arm_manipulation_api_walk_to PUBLIC
211215
${CMAKE_CURRENT_SOURCE_DIR}
212216
${PROTOBUF_INCLUDE_DIR}
217+
$<TARGET_PROPERTY:CLI11::CLI11,INTERFACE_INCLUDE_DIRECTORIES>
213218
)
214219
target_link_libraries(arm_manipulation_api_walk_to PUBLIC bosdyn_client_static)
215220
install(TARGETS arm_manipulation_api_walk_to DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -255,12 +260,12 @@ target_include_directories(spot_cam PUBLIC
255260
target_link_libraries(spot_cam PUBLIC bosdyn_client_static)
256261
install(TARGETS spot_cam DESTINATION ${CMAKE_INSTALL_BINDIR})
257262
# Save a version file in the project's binary directory
258-
include(CMakePackageConfigHelpers)
259263
set(VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
260264
write_basic_package_version_file("${VERSION_FILE}"
261265
VERSION ${PACKAGE_VERSION}
262266
COMPATIBILITY AnyNewerVersion
263267
)
268+
endif()
264269

265270
# This defines the instructions to generate a relocatable targets file at install time
266271
set(PROJECT_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
@@ -274,7 +279,6 @@ install(
274279

275280
# Define Variables needed by package config file
276281
set(PACKAGE_INSTALL_PREFIX /opt/spot-cpp-sdk)
277-
set(DEP_INSTALL_PATH ${PACKAGE_INSTALL_PREFIX}/external)
278282

279283
#this generates a relocatable config file for install, but it gets invoked at build time,
280284
#so the output has to be saved in a way that will not conflict with the export config
@@ -323,6 +327,5 @@ if (UNIX)
323327
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
324328
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
325329
set(CPACK_PACKAGING_INSTALL_PREFIX "${PACKAGE_INSTALL_PREFIX}")
326-
set(CPACK_INSTALLED_DIRECTORIES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/;${DEP_INSTALL_PATH}/")
327330
include(CPack)
328331
endif()

cpp/cmake/ProjectConfig.cmake.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ list(APPEND CMAKE_PREFIX_PATH @DEP_INSTALL_PATH@)
77
include(CMakeFindDependencyMacro)
88
find_dependency(Protobuf CONFIG REQUIRED)
99
find_dependency(Eigen3 CONFIG REQUIRED)
10-
find_dependency(gRPC CONFIG REQUIRED)
11-
find_dependency(CLI11 CONFIG REQUIRED)
10+
find_dependency(PkgConfig CONFIG REQUIRED)
11+
pkg_check_modules(GRPC REQUIRED grpc)
12+
pkg_check_modules(GRPCPP REQUIRED grpc++)
1213
find_dependency(Threads REQUIRED)
14+
find_dependency(CLI11 REQUIRED)
1315
# Pick up the auto-generated file which knows how to add the library targets
1416
# This will mean that we do not have to supply full paths for the libraries
1517
set(exports_file "${CMAKE_CURRENT_LIST_DIR}/@EXPORTS_FILE@")

0 commit comments

Comments
 (0)