Skip to content

Commit

Permalink
feat(build): add configuration files for VS Code devcontainer (#137)
Browse files Browse the repository at this point in the history
Add development stage to Dockerfile.ci and devcontainer configuration files.

Use the development-dependencies image as base image.
  • Loading branch information
domire8 authored Sep 20, 2023
1 parent 74585ab commit 4671bb2
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 31 deletions.
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "control libraries",
"remoteUser": "ros2",
"build": {
"dockerfile": "../Dockerfile.ci",
"context": "..",
"target": "development",
"args": {
"BASE_TAG": "22.04",
"PINOCCHIO_TESTS": "OFF"
}
},
"workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind,consistency=cached",
"workspaceFolder": "/src",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools-extension-pack",
"eamodio.gitlens"
]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDE generated directories
.idea
cmake-build-*
build/

# Prerequisites
*.d
Expand Down
15 changes: 15 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "AMD",
"includePath": [
"/src/source/**/include"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cmake.sourceDirectory": "/src/source",
"cmake.configureArgs": [ "-DBUILD_TESTING=ON" ],
"C_Cpp.clang_format_style": "file:/home/ros2/.clang-format"
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Release Versions:

## Upcoming changes (in development)

- feat(build): add configuration files for VS Code devcontainer (#137)
- feat(python): auto-generate stubs for python modules in Dockerfile (#135)
- fix: build all python modules (#134)

Expand Down
51 changes: 26 additions & 25 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ghcr.io/aica-technology/ros2-ws:humble as base
ARG BASE_TAG=22.04
FROM ghcr.io/aica-technology/control-libraries/development-dependencies:${BASE_TAG} as base
USER ${USER}

FROM base as apt-dependencies
Expand Down Expand Up @@ -61,36 +62,35 @@ HEREDOC
FROM base as dep-pinocchio
COPY --from=apt-dependencies /tmp/apt /
ARG TARGETPLATFORM
ARG CACHEID
ARG PINOCCHIO_TAG=v2.6.9
ARG PINOCCHIO_TESTS=OFF
# FIXME: it would be nicer to have it all in the root CMakelists.txt but:
# * `pinocchio` doesn't provide an include directory we can easily plug into `target_include_directories` and thus needs to be installed first
# * `pinocchio` uses hacks relying on undocumented CMake quirks which break if you use `FetchContent`
# FIXME: it needs `CMAKE_INSTALL_PREFIX` and `--prefix` because it doesn't install to the right place otherwise
RUN \
--mount=type=cache,target=./pinocchio,id=cmake-pinocchio-src-${PINOCCHIO_TAG}-${TARGETPLATFORM},uid=1000 \
--mount=type=cache,target=./build,id=cmake-pinocchio-${PINOCCHIO_TAG}-${TARGETPLATFORM},uid=1000 \
RUN --mount=type=cache,target=./pinocchio,id=cmake-pinocchio-src-${PINOCCHIO_TAG}-${TARGETPLATFORM}-${CACHEID},uid=1000 \
--mount=type=cache,target=./build,id=cmake-pinocchio-${PINOCCHIO_TAG}-${TARGETPLATFORM}-${CACHEID},uid=1000 \
if [ ! -f pinocchio/CMakeLists.txt ]; then rm -rf pinocchio/* && git clone --depth 1 -b ${PINOCCHIO_TAG} --recursive https://github.com/stack-of-tasks/pinocchio; fi \
&& cmake -B build -S pinocchio -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON_INTERFACE=OFF -DCMAKE_INSTALL_PREFIX=/tmp/deps \
&& cmake -B build -S pinocchio -DBUILD_TESTING=${PINOCCHIO_TESTS} -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON_INTERFACE=OFF -DCMAKE_INSTALL_PREFIX=/tmp/deps \
&& cmake --build build --target all install
# FIXME: pinocchio produces non-portable paths
RUN find /tmp/deps -type f -exec sed -i 's#/tmp/deps#/usr#g' '{}' \;

FROM base as dep-osqp
ARG TARGETPLATFORM
ARG CACHEID
COPY dependencies/osqp.cmake CMakeLists.txt
RUN \
--mount=type=cache,target=./build,id=cmake-osqp-${TARGETPLATFORM},uid=1000 \
cmake -B build -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build \
&& cmake --install build --prefix /tmp/deps
RUN --mount=type=cache,target=./build,id=cmake-osqp-${TARGETPLATFORM}-${CACHEID},uid=1000 \
cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build && cmake --install build --prefix /tmp/deps

FROM base as dependencies
ARG TARGETPLATFORM
ARG CACHEID
# Needed to build `osqp-eigen`
COPY --from=dep-osqp /tmp/deps /usr
COPY dependencies/dependencies.cmake CMakeLists.txt
RUN \
--mount=type=cache,target=./build,id=cmake-deps-${TARGETPLATFORM},uid=1000 \
RUN --mount=type=cache,target=./build,id=cmake-deps-${TARGETPLATFORM}-${CACHEID},uid=1000 \
cmake -B build -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build \
&& cmake --install build --prefix /tmp/deps
Expand All @@ -103,46 +103,47 @@ COPY --from=apt-dependencies /tmp/apt /
COPY --from=dependencies /tmp/deps /usr
COPY --chown=${USER}:${USER} . /src

FROM code as development

FROM code as build
ARG TARGETPLATFORM
RUN \
--mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM},uid=1000 \
cmake -B build -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build
ARG CACHEID
RUN --mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM}-${CACHEID},uid=1000 \
cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build

FROM build as test
ARG TARGETPLATFORM
RUN \
--mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM},uid=1000 \
cmake -B build -DBUILD_TESTING=ON \
&& CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test
ARG CACHEID
RUN --mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM}-${CACHEID},uid=1000 \
cmake -B build -DBUILD_TESTING=ON && cd build && make && CTEST_OUTPUT_ON_FAILURE=1 make test

FROM build as install
ARG TARGETPLATFORM
RUN \
--mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM},uid=1000 \
ARG CACHEID
RUN --mount=type=cache,target=./build,id=cmake-${TARGETPLATFORM}-${CACHEID},uid=1000 \
cmake --install build --prefix /tmp/cl

FROM base as python
ARG TARGETPLATFORM
ARG CACHEID
COPY --from=apt-dependencies /tmp/apt /
COPY --from=dependencies /tmp/deps /usr
COPY --from=install /tmp/cl /usr
COPY --chown=${USER}:${USER} ./python /python
RUN \
--mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM},uid=1000 \
RUN --mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM}-${CACHEID},uid=1000 \
python3 -m pip install --prefix=/tmp/python /python
RUN mkdir -p /tmp/python-home/${USER}/.local/lib/python3.10/ \
&& mv /tmp/python/local/lib/python3.10/dist-packages/ /tmp/python-home/${USER}/.local/lib/python3.10/site-packages/

FROM base as python-stubs
ARG TARGETPLATFORM
ARG CACHEID
COPY --from=apt-dependencies /tmp/apt /
COPY --from=dependencies /tmp/deps /usr
COPY --from=install /tmp/cl /usr
COPY --from=python /tmp/python-home /home
RUN sudo pip install pybind11-stubgen
RUN --mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM}-5,uid=1000 \
RUN --mount=type=cache,target=${HOME}/.cache,id=pip-${TARGETPLATFORM}-${CACHEID},uid=1000 \
<<HEREDOC
for PKG in state_representation dynamical_systems robot_model controllers; do
python3 -c "import ${PKG}"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.3
7.1.4
2 changes: 1 addition & 1 deletion demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(control_libraries 7.1.3 CONFIG REQUIRED)
find_package(control_libraries 7.1.4 CONFIG REQUIRED)

set(DEMOS_SCRIPTS
task_space_control_loop
Expand Down
2 changes: 1 addition & 1 deletion doxygen/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Control Libraries"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 7.1.3
PROJECT_NUMBER = 7.1.4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion protocol/clproto_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15)

project(clproto VERSION 7.1.3)
project(clproto VERSION 7.1.4)

# Default to C99
if(NOT CMAKE_C_STANDARD)
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# names of the environment variables that define osqp and openrobots include directories
osqp_path_var = 'OSQP_INCLUDE_DIR'

__version__ = "7.1.3"
__version__ = "7.1.4"
__libraries__ = ['state_representation', 'clproto', 'controllers', 'dynamical_systems', 'robot_model']
__include_dirs__ = ['include']

Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15)

project(control_libraries VERSION 7.1.3)
project(control_libraries VERSION 7.1.4)

# Build options
option(BUILD_TESTING "Build all tests." OFF)
Expand Down

0 comments on commit 4671bb2

Please sign in to comment.