Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update devcontainers for building debians #4

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions .devcontainer/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
FROM ubuntu:22.04

RUN apt-get update --fix-missing &&\
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 &&\
apt-get autoclean &&\
apt-get autoremove &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*
RUN apt-get update --fix-missing \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
git \
libcli11-dev \
libeigen3-dev \
libgrpc++-dev \
libprotobuf-dev \
g++ \
pkg-config \
protobuf-compiler \
protobuf-compiler-grpc \
python3 \
curl \
ninja-build \
tar \
zip \
unzip \
zlib1g-dev \
libssl-dev \
wget \
&& apt-get autoclean \
&& apt-get autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN update-ca-certificates

RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
tar -xzf cmake-3.28.3.tar.gz &&\
cd cmake-3.28.3 &&\
./configure &&\
make install &&\
cd .. &&\
rm cmake-3.28.3.tar.gz &&\
rm -r cmake-3.28.3

RUN git clone https://github.com/microsoft/vcpkg &&\
cd vcpkg &&\
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
./bootstrap-vcpkg.sh -disableMetrics &&\
./vcpkg install grpc:x64-linux &&\
./vcpkg install eigen3:x64-linux &&\
./vcpkg install cli11:x64-linux
COPY entrypoint.sh .
27 changes: 27 additions & 0 deletions .devcontainer/Dockerfile.amd64_vcpkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:22.04

RUN apt-get update --fix-missing &&\
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 &&\
apt-get autoclean &&\
apt-get autoremove &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*

RUN update-ca-certificates

RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
tar -xzf cmake-3.28.3.tar.gz &&\
cd cmake-3.28.3 &&\
./configure &&\
make install &&\
cd .. &&\
rm cmake-3.28.3.tar.gz &&\
rm -r cmake-3.28.3

RUN git clone https://github.com/microsoft/vcpkg &&\
cd vcpkg &&\
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
./bootstrap-vcpkg.sh -disableMetrics &&\
./vcpkg install grpc:x64-linux &&\
./vcpkg install eigen3:x64-linux &&\
./vcpkg install cli11:x64-linux
52 changes: 28 additions & 24 deletions .devcontainer/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
FROM arm64v8/ubuntu:22.04
SHELL ["/bin/bash", "-c"]

RUN apt-get update --fix-missing &&\
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 &&\
apt-get autoclean &&\
apt-get autoremove &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*
RUN apt-get update --fix-missing \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
git \
libcli11-dev \
libeigen3-dev \
libgrpc++-dev \
libprotobuf-dev \
g++ \
pkg-config \
protobuf-compiler \
protobuf-compiler-grpc \
python3 \
curl \
ninja-build \
tar \
zip \
unzip \
zlib1g-dev \
libssl-dev \
wget \
&& apt-get autoclean \
&& apt-get autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN update-ca-certificates

RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
tar -xzf cmake-3.28.3.tar.gz &&\
cd cmake-3.28.3 &&\
./configure &&\
make install &&\
cd .. &&\
rm cmake-3.28.3.tar.gz &&\
rm -r cmake-3.28.3

RUN git clone https://github.com/microsoft/vcpkg &&\
cd vcpkg &&\
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
export VCPKG_FORCE_SYSTEM_BINARIES=arm &&\
./bootstrap-vcpkg.sh -disableMetrics &&\
./vcpkg install grpc:arm64-linux &&\
./vcpkg install eigen3:arm64-linux &&\
./vcpkg install cli11:arm64-linux
COPY entrypoint.sh .
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile.arm64_vcpkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM arm64v8/ubuntu:22.04
SHELL ["/bin/bash", "-c"]

RUN apt-get update --fix-missing &&\
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 &&\
apt-get autoclean &&\
apt-get autoremove &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*

RUN update-ca-certificates

RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz &&\
tar -xzf cmake-3.28.3.tar.gz &&\
cd cmake-3.28.3 &&\
./configure &&\
make install &&\
cd .. &&\
rm cmake-3.28.3.tar.gz &&\
rm -r cmake-3.28.3

RUN git clone https://github.com/microsoft/vcpkg &&\
cd vcpkg &&\
git checkout 3b213864579b6fa686e38715508f7cd41a50900f &&\
export VCPKG_FORCE_SYSTEM_BINARIES=arm &&\
./bootstrap-vcpkg.sh -disableMetrics &&\
./vcpkg install grpc:arm64-linux &&\
./vcpkg install eigen3:arm64-linux &&\
./vcpkg install cli11:arm64-linux
13 changes: 13 additions & 0 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
ARCH=$(dpkg --print-architecture)

if [ "$ARCH" == "amd64" ]; then
docker build -t spot_builder -f Dockerfile.amd64 .
elif [ "$ARCH" == "arm64" ]; then
docker build -t spot_builder -f Dockerfile.arm64 .
else
echo "Unknown architecture: $ARCH" > /dev/stderr
exit 1
fi

docker run -v ~/spot-cpp-sdk:/spot-cpp-sdk spot_builder /entrypoint.sh
9 changes: 9 additions & 0 deletions .devcontainer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
cd /spot-cpp-sdk/cpp
if [ -d build ]; then
rm -r build
fi
mkdir build
cd build
cmake .. -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE -DBUILD_CHOREOGRAPHY_LIBS=ON -DBUILD_SHARED_LIBS=ON
make -j8 install package
1 change: 1 addition & 0 deletions cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
51 changes: 27 additions & 24 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
# This file is autogenerated.

cmake_minimum_required (VERSION 3.10.2)
project (bosdyn VERSION 4.0.3)
project (bosdyn VERSION 4.1.0)

# Dependencies:
find_package(protobuf REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(gRPC REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GRPC REQUIRED grpc)
pkg_check_modules(GRPCPP REQUIRED grpc++)
find_program(GRPC_CPP_PLUGIN_LOCATION grpc_cpp_plugin REQUIRED)
find_package(CLI11 REQUIRED)
find_package(Threads REQUIRED)
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)

include_directories(SYSTEM $<TARGET_PROPERTY:CLI11::CLI11,INTERFACE_INCLUDE_DIRECTORIES>)

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

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

include(GNUInstallDirs)


### API protos LIBRARY ###
set(API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/protos/)
# Copy protos folders to build folder so they are in a subdirectory from the cpp folder (necessary for the proto cpp files generation).
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../protos/ DESTINATION ${API_protos_PATH})
get_filename_component(API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../protos/ ABSOLUTE)
file(GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS "${API_protos_PATH}/*.proto")
set(protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/protos)
file(MAKE_DIRECTORY ${protos_OUTPUT_DIR})
file(GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${API_protos_PATH}/*.proto")

if (bosdyn_protos_files)
add_library(bosdyn_api_obj OBJECT ${bosdyn_protos_files})
set_property(TARGET bosdyn_api_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
target_link_libraries(bosdyn_api_obj PUBLIC protobuf::libprotobuf gRPC::grpc gRPC::grpc++)
target_link_libraries(bosdyn_api_obj PUBLIC protobuf::libprotobuf ${GRPC_LINK_LIBRARIES} ${GRPCPP_LINK_LIBRARIES})
target_include_directories(bosdyn_api_obj PUBLIC
${GRPC_INCLUDE_DIRS} ${GRPCPP_INCLUDE_DIRS}
$<BUILD_INTERFACE:${protos_OUTPUT_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
protobuf_generate(TARGET bosdyn_api_obj LANGUAGE cpp
IMPORT_DIRS ${API_protos_PATH}
PROTOC_OUT_DIR ${protos_OUTPUT_DIR})
IMPORT_DIRS ${API_protos_PATH}
PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
)
protobuf_generate(TARGET bosdyn_api_obj
LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}"
PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION}"
IMPORT_DIRS ${API_protos_PATH}
PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
)
Expand Down Expand Up @@ -93,13 +95,11 @@ endif()
if (BUILD_CHOREOGRAPHY_LIBS)

### API choreography_protos LIBRARY ###
set(API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/choreography_protos/)
# Copy choreography_protos folders to build folder so they are in a subdirectory from the cpp folder (necessary for the proto cpp files generation).
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../choreography_protos/ DESTINATION ${API_choreography_protos_PATH})
get_filename_component(API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../choreography_protos/ ABSOLUTE)
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH}/*.proto")
set(choreography_protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/choreography_protos)
file(MAKE_DIRECTORY ${choreography_protos_OUTPUT_DIR})
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${API_choreography_protos_PATH}/*.proto")
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH}/*.proto")

if (bosdyn_choreography_protos_files)
add_library(bosdyn_choreography_protos_obj OBJECT ${bosdyn_choreography_protos_files})
Expand All @@ -114,7 +114,7 @@ if (bosdyn_choreography_protos_files)
PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR})
protobuf_generate(TARGET bosdyn_choreography_protos_obj
LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}"
PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION}"
IMPORT_DIRS ${API_choreography_protos_PATH}
PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR}
)
Expand Down Expand Up @@ -193,7 +193,11 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bosdyn
)


include(CMakePackageConfigHelpers)

### EXAMPLE EXECUTABLES ###
if(BUILD_EXAMPLES)

link_directories(
${PROTOBUF_LIB_DIR}
)
Expand All @@ -210,6 +214,7 @@ target_compile_features(arm_manipulation_api_walk_to PUBLIC cxx_std_17)
target_include_directories(arm_manipulation_api_walk_to PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
$<TARGET_PROPERTY:CLI11::CLI11,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(arm_manipulation_api_walk_to PUBLIC bosdyn_client_static)
install(TARGETS arm_manipulation_api_walk_to DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down Expand Up @@ -254,12 +259,12 @@ target_include_directories(spot_cam PUBLIC
target_link_libraries(spot_cam PUBLIC bosdyn_client_static)
install(TARGETS spot_cam DESTINATION ${CMAKE_INSTALL_BINDIR})
# Save a version file in the project's binary directory
include(CMakePackageConfigHelpers)
set(VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
write_basic_package_version_file("${VERSION_FILE}"
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
endif()

# This defines the instructions to generate a relocatable targets file at install time
set(PROJECT_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
Expand All @@ -273,7 +278,6 @@ install(

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

#this generates a relocatable config file for install, but it gets invoked at build time,
#so the output has to be saved in a way that will not conflict with the export config
Expand Down Expand Up @@ -322,6 +326,5 @@ if (UNIX)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGING_INSTALL_PREFIX "${PACKAGE_INSTALL_PREFIX}")
set(CPACK_INSTALLED_DIRECTORIES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/;${DEP_INSTALL_PATH}/")
include(CPack)
endif()
6 changes: 4 additions & 2 deletions cpp/cmake/ProjectConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ list(APPEND CMAKE_PREFIX_PATH @DEP_INSTALL_PATH@)
include(CMakeFindDependencyMacro)
find_dependency(Protobuf CONFIG REQUIRED)
find_dependency(Eigen3 CONFIG REQUIRED)
find_dependency(gRPC CONFIG REQUIRED)
find_dependency(CLI11 CONFIG REQUIRED)
find_dependency(PkgConfig CONFIG REQUIRED)
pkg_check_modules(GRPC REQUIRED grpc)
pkg_check_modules(GRPCPP REQUIRED grpc++)
find_dependency(Threads REQUIRED)
find_dependency(CLI11 REQUIRED)
# Pick up the auto-generated file which knows how to add the library targets
# This will mean that we do not have to supply full paths for the libraries
set(exports_file "${CMAKE_CURRENT_LIST_DIR}/@EXPORTS_FILE@")
Expand Down