Skip to content

Commit 314546c

Browse files
authored
Merge branch 'main' into fix-module-log-formatting
2 parents dbd32da + d4a6e52 commit 314546c

32 files changed

+8023
-4752
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,27 @@ jobs:
1010
runs-on: ubuntu-latest
1111
container:
1212
image: ghcr.io/viamrobotics/canon:amd64
13+
strategy:
14+
matrix:
15+
include:
16+
- BUILD_SHARED: ON
17+
- BUILD_SHARED: OFF
1318
steps:
1419
- uses: actions/checkout@v4
1520
###########################################
1621
# necessary installs for building #
1722
###########################################
1823
- name: build-docker-test
1924
run: |
20-
docker build -t cpp . -f etc/docker/tests/Dockerfile.debian.bullseye
21-
docker run --rm -i -w /tmp cpp /bin/bash
25+
docker build -t cpp . -f etc/docker/base-images/Dockerfile.debian.bullseye
26+
docker build -t cpp-test . -f etc/docker/Dockerfile.sdk-build \
27+
--build-arg BASE_TAG=cpp \
28+
--build-arg REPO_SETUP=copy \
29+
--build-arg BUILD_SHARED=${{ matrix.BUILD_SHARED }} \
30+
--build-arg BUILD_TESTS=ON \
31+
--build-arg BUILD_EXAMPLES=ON \
32+
--build-arg "EXTRA_CMAKE_ARGS=\
33+
-DVIAMCPPSDK_CLANG_TIDY=ON \
34+
-DVIAMCPPSDK_SANITIZED_BUILD=${{ matrix.BUILD_SHARED }}"
35+
36+
docker run -w /viam-cpp-sdk/build -t --entrypoint /viam-cpp-sdk/etc/docker/tests/run_test.sh cpp-test /bin/bash

CMakeLists.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# constrained by the version of CMake available on target systems.
3535
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
3636

37-
set(CMAKE_PROJECT_VERSION 0.0.12)
37+
set(CMAKE_PROJECT_VERSION 0.0.13)
3838

3939
# Identify the project.
4040
project(viam-cpp-sdk
@@ -51,7 +51,9 @@ project(viam-cpp-sdk
5151
#
5252
# Enabled by default so that we produce a
5353
# modern SDK, this option can be set to `OFF` to build a static
54-
# library. Note that this may result in non-functional examples.
54+
# library.
55+
# Note that the pkg-config files installed by the project do not work
56+
# for a static build; please use Conan for more robust pkg-config support.
5557
#
5658
option(BUILD_SHARED_LIBS "If enabled, build shared libraries" ON)
5759

@@ -129,14 +131,8 @@ option(VIAMCPPSDK_CLANG_TIDY "Run the clang-tidy linter" OFF)
129131

130132
# The following options are only defined if this project is not being included as a subproject
131133
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
132-
include(CMakeDependentOption)
133-
option(VIAMCPPSDK_BUILD_EXAMPLES "Build the example executables (requires building tests too)" ON)
134-
135-
# Note that the complex module example requires the testing library and adds its tests to the unit
136-
# test suite. Thus you can only disable tests if examples are also disabled.
137-
# The call below says don't give the user the option to disable tests unless examples are already
138-
# disabled, and default to building the tests in either case.
139-
cmake_dependent_option(VIAMCPPSDK_BUILD_TESTS "Build the unit test suite" ON "NOT VIAMCPPSDK_BUILD_EXAMPLES" ON)
134+
option(VIAMCPPSDK_BUILD_EXAMPLES "Build the example executables" ON)
135+
option(VIAMCPPSDK_BUILD_TESTS "Build the example executables" ON)
140136
endif()
141137

142138

conanfile.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from conan import ConanFile
22
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
33
from conan.tools.files import load
4+
from conan.tools.apple import is_apple_os
5+
import os
46
import re
57

68
class ViamCppSdkRecipe(ConanFile):
@@ -81,9 +83,10 @@ def package(self):
8183

8284
def package_info(self):
8385
self.cpp_info.components["viam_rust_utils"].libs = ["viam_rust_utils"]
86+
87+
self.cpp_info.components["viamsdk"].libs = ["viamsdk"]
8488

8589
for component in ["viamsdk", "viamapi"]:
86-
self.cpp_info.components[component].libs = [component]
8790
self.cpp_info.components[component].set_property("cmake_target_name", "viam-cpp-sdk::{}".format(component))
8891
self.cpp_info.components[component].set_property("pkg_config_name", "viam-cpp-sdk-lib{}".format(component))
8992
self.cpp_info.components[component].requires = ["grpc::grpc++", "protobuf::libprotobuf"]
@@ -95,6 +98,18 @@ def package_info(self):
9598

9699
self.cpp_info.components["viamapi"].includedirs.append("include/viam/api")
97100

101+
if self.options.shared:
102+
self.cpp_info.components["viamapi"].libs = ["viamapi"]
103+
else:
104+
lib_folder = os.path.join(self.package_folder, "lib")
105+
lib_fullpath = os.path.join(lib_folder, "libviamapi.a")
106+
if is_apple_os(self):
107+
whole_archive = f"-Wl,-force_load,{lib_fullpath}"
108+
else:
109+
whole_archive = f"-Wl,--push-state,--whole-archive,{lib_fullpath},--pop-state"
110+
self.cpp_info.components["viamapi"].exelinkflags.append(whole_archive)
111+
self.cpp_info.components["viamapi"].sharedlinkflags.append(whole_archive)
112+
98113
self.cpp_info.components["viamsdk"].requires.extend([
99114
"viamapi",
100115
"boost::headers",

etc/docker/Dockerfile.sdk-build

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This Dockerfile is meant to be built on top of an existing image from the base-images directory.
2+
# Suggested usage, from the SDK root:
3+
# docker build -t base/bullseye -f etc/docker/base-images/Dockerfile.debian.bullseye .
4+
# docker build --build-arg BASE_TAG=base/bullseye --build-arg GIT_TAG=[...] etc/docker/Dockerfile.sdk-build .
5+
# You can substitute the bullseye image for whichever you want to use as a base.
6+
# Note that it is necessary to tag the base image with `-t` and then refer to it using the `BASE_TAG` arg.
7+
8+
ARG REPO_SETUP=git
9+
10+
ARG BASE_TAG
11+
12+
# See https://stackoverflow.com/a/54245466 for the trick used below
13+
# The two possible branches are repo_setup_git and repo_setup_copy, which are conditionally executed
14+
# using ARG REPO_SETUP
15+
16+
FROM ${BASE_TAG} AS repo_setup_git
17+
ARG GIT_TAG
18+
ONBUILD RUN echo "Checking if GIT_TAG is set" && test -n "${GIT_TAG}"
19+
ONBUILD RUN git clone https://github.com/viamrobotics/viam-cpp-sdk/ -b ${GIT_TAG}
20+
21+
FROM ${BASE_TAG} AS repo_setup_copy
22+
ONBUILD COPY . /viam-cpp-sdk/
23+
24+
FROM repo_setup_${REPO_SETUP}
25+
ENV DEBIAN_FRONTEND=noninteractive
26+
27+
ARG BUILD_TYPE=RelWithDebInfo
28+
ARG BUILD_SHARED=ON
29+
ARG BUILD_TESTS=OFF
30+
ARG BUILD_EXAMPLES=OFF
31+
ARG EXTRA_CMAKE_ARGS
32+
33+
WORKDIR /viam-cpp-sdk
34+
35+
RUN mkdir build && \
36+
cd build && \
37+
cmake .. -G Ninja \
38+
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
39+
-DBUILD_SHARED_LIBS=${BUILD_SHARED} \
40+
-DVIAMCPPSDK_OFFLINE_PROTO_GENERATION=ON \
41+
-DVIAMCPPSDK_BUILD_TESTS=${BUILD_TESTS} \
42+
-DVIAMCPPSDK_BUILD_EXAMPLES=${BUILD_EXAMPLES} \
43+
${EXTRA_CMAKE_ARGS}
44+
45+
RUN cmake --build build --target install && \
46+
cmake --install build
47+
File renamed without changes.

etc/docker/tests/Dockerfile.debian.bullseye

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)