diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 84611ac..7e1ae35 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -37,6 +37,13 @@ jobs: - uses: actions/checkout@v4 - run: make -f ccws/tests/test_main_ros2.mk ROS_DISTRO=humble + jammy_ros2_ccws2: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + - run: make -f ccws/tests/test_main_ros2_ccws2.mk ROS_DISTRO=humble + noble_ros2: runs-on: ubuntu-24.04 diff --git a/Makefile b/Makefile index 5d3f728..b550a5b 100644 --- a/Makefile +++ b/Makefile @@ -20,9 +20,18 @@ export AUTHOR?=$(shell git config --get user.name) export ROS_DISTRO # default profile -export BUILD_PROFILE?=reldebug +BUILD_PROFILE?=reldebug # used in build profile mixins and profile creation targets -export BASE_BUILD_PROFILE?=reldebug +BASE_BUILD_PROFILE?= + +export CCWS_BUILD_PROFILES?=$(shell echo "${BUILD_PROFILE},${BASE_BUILD_PROFILE}" | sed -e 's/,,//g' -e 's/,$$//g') +CCWS_BUILD_PROFILES_ID=$(shell echo "${CCWS_BUILD_PROFILES}" | sed -e 's/,/_/g') +CCWS_PRIMARY_BUILD_PROFILE=$(shell echo ${CCWS_BUILD_PROFILES} | cut -f 1 -d ',') +CCWS_SECONDARY_BUILD_PROFILE=$(shell echo ${CCWS_BUILD_PROFILES} | cut -f 2 -d ',') +CCWS_SECONDARY_BUILD_PROFILES=$(shell echo ${CCWS_BUILD_PROFILES} | cut -f 2- -d ',') +export CCWS_BUILD_SPACE_DIR=${WORKSPACE_DIR}/build/${CCWS_BUILD_PROFILES_ID} + + # default package type export PKG_TYPE?=catkin # global version, string, added to deb package names to enable multiple installations @@ -33,7 +42,7 @@ export VENDOR?=ccws export LICENSE?=Apache 2.0 export REPO_LIST_FORMAT?=repos -export WORKSPACE_INSTALL?=${WORKSPACE_DIR}/install/${BUILD_PROFILE} +export WORKSPACE_INSTALL?=${WORKSPACE_DIR}/install/${CCWS_BUILD_PROFILES} export ARTIFACTS_DIR=${WORKSPACE_DIR}/artifacts # maximum amout of memory required for a single compilation job -- used to compute job limit @@ -59,7 +68,7 @@ export PKG_ID=$(shell echo "${PKG}" | md5sum | cut -f 1 -d ' ') export BUILD_PROFILES_DIR=${CCWS_DIR}/profiles/build/ export EXEC_PROFILES_DIR=${CCWS_DIR}/profiles/exec/ MAKE_QUIET=${MAKE} --quiet --no-print-directory -SETUP_SCRIPT?=source ${BUILD_PROFILES_DIR}/${BUILD_PROFILE}/setup.bash +SETUP_SCRIPT?=source ${BUILD_PROFILES_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}/setup.bash ${CCWS_SECONDARY_BUILD_PROFILES} CMD_PKG_NAME_LIST=colcon --log-base /dev/null list --topological-order --names-only --base-paths ${WORKSPACE_SRC} CMD_PKG_LIST=colcon --log-base /dev/null list --topological-order --base-paths ${WORKSPACE_SRC} CMD_PKG_INFO=colcon --log-base /dev/null info --base-paths ${WORKSPACE_SRC} @@ -175,16 +184,17 @@ build_glob: build_all: bash -c "${MAKE} PKG=\"\$$(${CMD_PKG_NAME_LIST} | paste -d ' ' -s)\"" -build: assert_BUILD_PROFILE_must_exist - ${MAKE} wswraptarget TARGET=bp_${BUILD_PROFILE}_build +build: assert_BUILD_PROFILES_must_exist + ${MAKE} wswraptarget TARGET=bp_${CCWS_PRIMARY_BUILD_PROFILE}_build bp_%_build: private_build # skip to default # --log-level DEBUG private_build: assert_PKG_arg_must_be_specified - mkdir -p "${CCWS_BUILD_DIR}" + mkdir -p "${CCWS_BUILD_SPACE_DIR}" # override make flags to enable multithreaded builds + env | sort env MAKEFLAGS="-j${JOBS}" ${CCWS_BUILD_WRAPPER} colcon \ --log-base ${CCWS_LOG_DIR} \ build \ @@ -192,7 +202,7 @@ private_build: assert_PKG_arg_must_be_specified --merge-install \ --executor sequential \ --base-paths ${WORKSPACE_SRC} \ - --build-base "${CCWS_BUILD_DIR}" \ + --build-base "${CCWS_BUILD_SPACE_DIR}" \ --install-base "${CCWS_INSTALL_DIR_BUILD}" \ --cmake-args -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" \ --packages-up-to ${PKG} diff --git a/ccws/examples/pkg_catkin/CMakeLists.txt b/ccws/examples/pkg_catkin/CMakeLists.txt index 732f93b..5d4f62e 100644 --- a/ccws/examples/pkg_catkin/CMakeLists.txt +++ b/ccws/examples/pkg_catkin/CMakeLists.txt @@ -118,7 +118,6 @@ catkin_package( # set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CCWS_LINKER_FLAGS}") #endif() #add_definitions(-DCCWS_DEBUG=${CCWS_DEBUG}) -#add_definitions(-DCCWS_BUILD_PROFILE="${CCWS_BUILD_PROFILE}") ## -------------- ## Specify additional locations of header files diff --git a/ccws/make/clean.mk b/ccws/make/clean.mk index e03be69..ac9d2c7 100644 --- a/ccws/make/clean.mk +++ b/ccws/make/clean.mk @@ -20,17 +20,17 @@ cmake_cfg_clean: ${MAKE} wswraptarget TARGET=cmake_cfg_clean private_cmake_cfg_clean: - rm -f ${CCWS_BUILD_DIR}/*/CMakeCache.txt + rm -f ${CCWS_BUILD_SPACE_DIR}/*/CMakeCache.txt bp_purge: - ${MAKE} wswraptarget TARGET=bp_${BUILD_PROFILE}_purge + ${MAKE} wswraptarget TARGET=bp_${CCWS_PRIMARY_BUILD_PROFILE}_purge -bp_%_purge: assert_BUILD_PROFILE_must_exist +bp_%_purge: assert_BUILD_PROFILES_must_exist # placeholder target bp_clean: - ${MAKE} wswraptarget TARGET=bp_${BUILD_PROFILE}_clean + ${MAKE} wswraptarget TARGET=bp_${CCWS_PRIMARY_BUILD_PROFILE}_clean -bp_%_clean: assert_BUILD_PROFILE_must_exist - rm -rf "${WORKSPACE_DIR}/build/${BUILD_PROFILE}" - rm -rf "${WORKSPACE_DIR}/install/${BUILD_PROFILE}" +bp_%_clean: assert_BUILD_PROFILES_must_exist + rm -rf "${CCWS_BUILD_SPACE_DIR}" + rm -rf "${WORKSPACE_DIR}/install/${CCWS_BUILD_PROFILES_ID}" diff --git a/ccws/make/conan.mk b/ccws/make/conan.mk index e7924e1..b23aa55 100644 --- a/ccws/make/conan.mk +++ b/ccws/make/conan.mk @@ -4,7 +4,7 @@ # conflict resolution is fragile and inconvenient https://docs.conan.io/2/tutorial/versioning/conflicts.html # https://docs.conan.io/2/reference/environment.html#conan-home -export CCWS_CONAN_HOME?="${CCWS_CACHE}/conan/${BUILD_PROFILE}" +export CCWS_CONAN_HOME?="${CCWS_CACHE}/conan/${CCWS_PRIMARY_BUILD_PROFILE}" install_conan: install_python3 ${PIP3_INSTALL} conan diff --git a/ccws/make/cross.mk b/ccws/make/cross.mk index f599f20..a78afb5 100644 --- a/ccws/make/cross.mk +++ b/ccws/make/cross.mk @@ -57,7 +57,7 @@ private_cross_build: assert_CCWS_SYSROOT_must_be_mounted cross_mount: # implementation is profile specific - ${MAKE} bp_${BUILD_PROFILE}_mount + ${MAKE} bp_${CCWS_PRIMARY_BUILD_PROFILE}_mount cross_umount: bash -c "${SETUP_SCRIPT}; \ @@ -76,7 +76,7 @@ cross_common_install_build: bash -c "${SETUP_SCRIPT}; mkdir -p \"\$${CCWS_SYSROOT_DATA}\"" cross_flash: - ${MAKE} bp_${BUILD_PROFILE}_flash + ${MAKE} bp_${CCWS_PRIMARY_BUILD_PROFILE}_flash bp_%_flash: test "${DEVICE}" != "" @@ -84,10 +84,10 @@ bp_%_flash: bash -c "${SETUP_SCRIPT}; sudo dd if=\"\$${CCWS_SYSROOT_DATA}/system.img\" of=${DEVICE} status=progress bs=16M" cross_get: - ${MAKE} bp_${BUILD_PROFILE}_get + ${MAKE} bp_${CCWS_PRIMARY_BUILD_PROFILE}_get cross_initialize: - ${MAKE} bp_${BUILD_PROFILE}_initialize + ${MAKE} bp_${CCWS_PRIMARY_BUILD_PROFILE}_initialize cross_install: cross_get ${MAKE} cross_mount @@ -97,15 +97,15 @@ cross_install: cross_get cross_pack: ${MAKE} cross_umount - ${MAKE} wswraptarget TARGET=private_bp_${BUILD_PROFILE}_pack + ${MAKE} wswraptarget TARGET=private_bp_${CCWS_PRIMARY_BUILD_PROFILE}_pack cross_unpack: ${MAKE} cross_umount - ${MAKE} wswraptarget TARGET=private_bp_${BUILD_PROFILE}_unpack + ${MAKE} wswraptarget TARGET=private_bp_${CCWS_PRIMARY_BUILD_PROFILE}_unpack cross_purge: ${MAKE} cross_umount - ${MAKE} wswraptarget TARGET=private_bp_${BUILD_PROFILE}_purge + ${MAKE} wswraptarget TARGET=private_bp_${CCWS_PRIMARY_BUILD_PROFILE}_purge cross_python_soabi: assert_CCWS_SYSROOT_must_be_mounted printf "from sysconfig import get_config_var\nprint(get_config_var('SOABI'))\n" \ diff --git a/ccws/make/dependency.mk b/ccws/make/dependency.mk index f2208a0..cd876f3 100644 --- a/ccws/make/dependency.mk +++ b/ccws/make/dependency.mk @@ -1,6 +1,6 @@ -DEPLIST_DIR=${WORKSPACE_DIR}/build/${BUILD_PROFILE}_dep/ +DEPLIST_DIR=${WORKSPACE_DIR}/build/${CCWS_BUILD_PROFILES_ID}_dep/ DEPLIST_FILE=${DEPLIST_DIR}/deps_${PKG_ID} -CCWS_ROSDEP_CACHE=${CCWS_CACHE}/profiles/${BUILD_PROFILE} +CCWS_ROSDEP_CACHE=${CCWS_CACHE}/profiles/${CCWS_PRIMARY_BUILD_PROFILE} dep_%: diff --git a/ccws/make/install.mk b/ccws/make/install.mk index fd510a6..e67d312 100644 --- a/ccws/make/install.mk +++ b/ccws/make/install.mk @@ -59,10 +59,10 @@ install_ccws_deps_noble: install_ccws_deps_jammy bp_install_build: - echo "CCWS/bp_install_build: ${BUILD_PROFILE}" - ${MAKE} bp_${BUILD_PROFILE}_install_build + echo "CCWS/bp_install_build: ${CCWS_PRIMARY_BUILD_PROFILE}" + ${MAKE} bp_${CCWS_PRIMARY_BUILD_PROFILE}_install_build -bp_%_install_build: assert_BUILD_PROFILE_must_exist bp_common_install_build +bp_%_install_build: assert_BUILD_PROFILES_must_exist bp_common_install_build # placeholder target ep_install: diff --git a/ccws/make/profile.mk b/ccws/make/profile.mk index 813eeda..11e97ac 100644 --- a/ccws/make/profile.mk +++ b/ccws/make/profile.mk @@ -1,21 +1,17 @@ -assert_BUILD_PROFILE_must_exist: - test -f "${BUILD_PROFILES_DIR}/${BUILD_PROFILE}/setup.bash" +assert_BUILD_PROFILES_must_exist: + echo "${CCWS_BUILD_PROFILES}" | sed -e 's/,/\n/g' | xargs -I {} test -f "${BUILD_PROFILES_DIR}/{}/setup.bash" -assert_BASE_BUILD_PROFILE_must_exist: - test -f "${BUILD_PROFILES_DIR}/${BASE_BUILD_PROFILE}/setup.bash" +assert_SECONDARY_BUILD_PROFILE_must_exist: + test -f "${BUILD_PROFILES_DIR}/${CCWS_SECONDARY_BUILD_PROFILE}/setup.bash" -assert_BUILD_PROFILE_must_not_exist: - test ! -d "${BUILD_PROFILES_DIR}/${BUILD_PROFILE}" +bp_new: + test ! -d "${BUILD_PROFILES_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}" + ${MAKE} assert_BUILD_PROFILES_must_exist CCWS_BUILD_PROFILES=${CCWS_SECONDARY_BUILD_PROFILES} + cp -R "${CCWS_DIR}/profiles/template_build" "${BUILD_PROFILES_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}" + find "${BUILD_PROFILES_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}" -type f \ + | xargs sed -i -e "s/@@BUILD_PROFILE@@/${CCWS_PRIMARY_BUILD_PROFILE}/g" -e "s/@@BASE_BUILD_PROFILE@@/${CCWS_SECONDARY_BUILD_PROFILE}/g" -assert_EXEC_PROFILE_must_not_exist: +ep_new: test ! -d "${EXEC_PROFILES_DIR}/${EXEC_PROFILE}" - -bp_new: assert_BUILD_PROFILE_must_not_exist - ${MAKE} assert_BUILD_PROFILE_must_exist BUILD_PROFILE=${BASE_BUILD_PROFILE} - cp -R "${CCWS_DIR}/profiles/template_build" "${BUILD_PROFILES_DIR}/${BUILD_PROFILE}" - find "${BUILD_PROFILES_DIR}/${BUILD_PROFILE}" -type f | xargs sed -i "s/@@BUILD_PROFILE@@/${BUILD_PROFILE}/g" - find "${BUILD_PROFILES_DIR}/${BUILD_PROFILE}" -type f | xargs sed -i "s/@@BASE_BUILD_PROFILE@@/${BASE_BUILD_PROFILE}/g" - -ep_new: assert_EXEC_PROFILE_must_not_exist cp -R "${CCWS_DIR}/profies/template_exec" "${EXEC_PROFILES_DIR}/${EXEC_PROFILE}" find "${EXEC_PROFILES_DIR}/${EXEC_PROFILE}" -type f | xargs sed -i "s/@@EXEC_PROFILE@@/${EXEC_PROFILE}/g" diff --git a/ccws/make/test.mk b/ccws/make/test.mk index 156c670..a97dbcc 100644 --- a/ccws/make/test.mk +++ b/ccws/make/test.mk @@ -1,6 +1,6 @@ TEST_REGEX?=.* -TEST_PKG_LIST=${WORKSPACE_DIR}/build/${BUILD_PROFILE}/ccws.tests.packages -TEST_PKG_LIST_EXCEPT=${WORKSPACE_DIR}/build/${BUILD_PROFILE}/ccws.tests.exceptions.packages +TEST_PKG_LIST=${CCWS_BUILD_SPACE_DIR}/ccws.tests.packages +TEST_PKG_LIST_EXCEPT=${CCWS_BUILD_SPACE_DIR}/ccws.tests.exceptions.packages wslist_test: @${MAKE_QUIET} wslist | sort > "${TEST_PKG_LIST}" @@ -28,7 +28,7 @@ wsctest: # this target uses colcon and unlike `ctest` target does not respect `--output-on-failure` test: assert_PKG_arg_must_be_specified - bash -c "time ( source ${CCWS_ROOT}/setup.bash ${BUILD_PROFILE} test ${EXEC_PROFILE}; \ + bash -c "time ( source ${CCWS_ROOT}/setup.bash ${CCWS_BUILD_PROFILES} test ${EXEC_PROFILE}; \ colcon \ --log-base \$${CCWS_LOG_DIR} \ test \ @@ -36,7 +36,7 @@ test: assert_PKG_arg_must_be_specified --merge-install \ --executor sequential \ --ctest-args --output-on-failure -j ${JOBS} \ - --build-base \"\$${CCWS_BUILD_DIR}\" \ + --build-base \"\$${CCWS_BUILD_SPACE_DIR}\" \ --install-base \"\$${CCWS_INSTALL_DIR_BUILD}\" \ --base-paths "${WORKSPACE_SRC}" \ --test-result-base \$${CCWS_LOG_DIR}/testing \ @@ -45,9 +45,9 @@ test: assert_PKG_arg_must_be_specified ctest: assert_PKG_arg_must_be_specified echo '${PKG}' | sed 's/ /\n/g' | xargs --no-run-if-empty -I {} bash -c \ - "time ( source ${CCWS_ROOT}/setup.bash ${BUILD_PROFILE} test ${EXEC_PROFILE}; \ + "time ( source ${CCWS_ROOT}/setup.bash ${CCWS_BUILD_PROFILES} test ${EXEC_PROFILE}; \ mkdir -p \"\$${CCWS_ARTIFACTS_DIR}\"; \ - cd \"\$${CCWS_BUILD_DIR}/{}\"; \ + cd \"\$${CCWS_BUILD_SPACE_DIR}/{}\"; \ time ctest --schedule-random --output-on-failure --output-log \"\$${CCWS_ARTIFACTS_DIR}/ctest_{}.log\" -j ${JOBS} --tests-regex '${TEST_REGEX}')" \ && ${MAKE} showtestresults || ${MAKE} showtestresults @@ -64,15 +64,15 @@ showtestresults: test_results test_results: assert_PKG_arg_must_be_specified # shows fewer tests echo '${PKG}' | sed 's/ /\n/g' | xargs --no-run-if-empty -I {} bash -c "${SETUP_SCRIPT}; ${MAKE} private_test_results_pkg PKG={}" - #bash -c "${SETUP_SCRIPT}; catkin_test_results \$${CCWS_BUILD_DIR}/${PKG}" + #bash -c "${SETUP_SCRIPT}; catkin_test_results \$${CCWS_BUILD_SPACE_DIR}/${PKG}" private_test_results_pkg: assert_PKG_arg_must_be_specified @mkdir -p ${CCWS_ARTIFACTS_DIR}/${PKG}/ - @cp -R ${CCWS_BUILD_DIR}/${PKG}/Testing ${CCWS_ARTIFACTS_DIR}/${PKG}/ 2> /dev/null || true - @cp -R ${CCWS_BUILD_DIR}/${PKG}/test_results ${CCWS_ARTIFACTS_DIR}/${PKG}/ 2> /dev/null || true - @colcon --log-base /dev/null test-result --all --test-result-base ${CCWS_BUILD_DIR}/${PKG} + @cp -R ${CCWS_BUILD_SPACE_DIR}/${PKG}/Testing ${CCWS_ARTIFACTS_DIR}/${PKG}/ 2> /dev/null || true + @cp -R ${CCWS_BUILD_SPACE_DIR}/${PKG}/test_results ${CCWS_ARTIFACTS_DIR}/${PKG}/ 2> /dev/null || true + @colcon --log-base /dev/null test-result --all --test-result-base ${CCWS_BUILD_SPACE_DIR}/${PKG} test_list: assert_PKG_arg_must_be_specified - bash -c "time ( source ${CCWS_ROOT}/setup.bash ${BUILD_PROFILE} test ${EXEC_PROFILE} \ - && echo '${PKG}' | sed 's/ /\n/g' | xargs --no-run-if-empty -I {} ctest --show-only --test-dir \"\$${CCWS_BUILD_DIR}/{}\")" + bash -c "time ( source ${CCWS_ROOT}/setup.bash ${CCWS_BUILD_PROFILES} test ${EXEC_PROFILE} \ + && echo '${PKG}' | sed 's/ /\n/g' | xargs --no-run-if-empty -I {} ctest --show-only --test-dir \"\$${CCWS_BUILD_SPACE_DIR}/{}\")" diff --git a/ccws/profiles/build/addr_undef_sanitizers/setup.bash b/ccws/profiles/build/addr_undef_sanitizers/setup.bash index 021047c..e3ebf86 100644 --- a/ccws/profiles/build/addr_undef_sanitizers/setup.bash +++ b/ccws/profiles/build/addr_undef_sanitizers/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" @@ -14,15 +14,15 @@ source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" # https://stackoverflow.com/questions/48267394/what-are-the-valid-sanitizer-suppression-strings-for-gcc # undefined -UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1:suppressions=${CCWS_BUILD_PROFILE_DIR}/undefined.supp +UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1:suppressions=${BUILD_PROFILES_DIR}/addr_undef_sanitizers/undefined.supp export UBSAN_OPTIONS # leaks -LSAN_OPTIONS=suppressions=${CCWS_BUILD_PROFILE_DIR}/leak.supp +LSAN_OPTIONS=suppressions=${BUILD_PROFILES_DIR}/addr_undef_sanitizers/leak.supp export LSAN_OPTIONS # Suppressions dont work on alloc-dealloc-mismatch for some reason -ASAN_OPTIONS=alloc_dealloc_mismatch=0:new_delete_type_mismatch=0:suppressions=${CCWS_BUILD_PROFILE_DIR}/address.supp +ASAN_OPTIONS=alloc_dealloc_mismatch=0:new_delete_type_mismatch=0:suppressions=${BUILD_PROFILES_DIR}/addr_undef_sanitizers/address.supp export ASAN_OPTIONS # address sanitizer diff --git a/ccws/profiles/build/clangd/setup.bash b/ccws/profiles/build/clangd/setup.bash index a29a29b..5e32bf7 100644 --- a/ccws/profiles/build/clangd/setup.bash +++ b/ccws/profiles/build/clangd/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" ########################################################################################## diff --git a/ccws/profiles/build/clangd/targets.mk b/ccws/profiles/build/clangd/targets.mk index 0f5bc91..d38db9a 100644 --- a/ccws/profiles/build/clangd/targets.mk +++ b/ccws/profiles/build/clangd/targets.mk @@ -1,11 +1,11 @@ -bp_clangd_build: assert_BASE_BUILD_PROFILE_must_exist - mkdir -p "${CCWS_CACHE}/clangd/${BASE_BUILD_PROFILE}/" +bp_clangd_build: assert_BUILD_PROFILES_must_exist + mkdir -p "${CCWS_CACHE}/clangd/${CCWS_BUILD_PROFILES_ID}/" # generated by colcon cmake (https://colcon.readthedocs.io/en/released/user/how-to.html#cmake-packages-generating-compile-commands-json) - cp "build/${BASE_BUILD_PROFILE}/compile_commands.json" "${CCWS_CACHE}/clangd/${BASE_BUILD_PROFILE}/compile_commands.json" - #find "build/${BASE_BUILD_PROFILE}/" -name "compile_commands.json" | xargs jq -s add > "${CCWS_CACHE}/clangd/${BASE_BUILD_PROFILE}/compile_commands.json" + cp "build/${CCWS_SECONDARY_BUILD_PROFILE}/compile_commands.json" "${CCWS_CACHE}/clangd/${CCWS_BUILD_PROFILES_ID}/compile_commands.json" + #find "build/${CCWS_SECONDARY_BUILD_PROFILE}/" -name "compile_commands.json" | xargs jq -s add > "${CCWS_CACHE}/clangd/${CCWS_SECONDARY_BUILD_PROFILE}/compile_commands.json" # https://clangd.llvm.org/config.html - echo "CompileFlags:" > "${WORKSPACE_DIR}/.clangd" - echo " CompilationDatabase: ${CCWS_CACHE}/clangd/${BASE_BUILD_PROFILE}/" >> "${WORKSPACE_DIR}/.clangd" + echo "CompileFlags:" > "${WORKSPACE_DIR}/.clangd" + echo " CompilationDatabase: ${CCWS_CACHE}/clangd/${CCWS_BUILD_PROFILES_ID}/" >> "${WORKSPACE_DIR}/.clangd" # note: cache is created next to compile commands -> https://github.com/clangd/clangd/issues/184 # a few notes regarding clangd-indexer # https://github.com/clangd/clangd/issues/587 diff --git a/ccws/profiles/build/common/setup.bash b/ccws/profiles/build/common/setup.bash index 4d318dc..66d2135 100644 --- a/ccws/profiles/build/common/setup.bash +++ b/ccws/profiles/build/common/setup.bash @@ -6,43 +6,30 @@ WORKSPACE_DIR=${WORKSPACE_DIR:-"$(pwd)"} BUILD_PROFILES_DIR=${BUILD_PROFILES_DIR:-"${CCWS_DIR}/profiles/build"} export WORKSPACE_DIR BUILD_PROFILES_DIR -if [ -z "${BUILD_PROFILE}" ] +if [ -z "${CCWS_BUILD_PROFILES}" ] then echo "Profile is not defined" - test -n "${BUILD_PROFILE}" + test -n "${CCWS_BUILD_PROFILES}" else - echo "Selected profile: '${BUILD_PROFILE}'" - export BUILD_PROFILE + echo "Selected profiles: '${CCWS_BUILD_PROFILES}'" + export CCWS_BUILD_PROFILES fi -# some profiles can be used as wrappers -#if [ -z "${SOURCED_BUILD_PROFILE}" ] -#then -# SOURCED_BUILD_PROFILE="${BUILD_PROFILE}" -# export SOURCED_BUILD_PROFILE -#else -# if [ "${SOURCED_BUILD_PROFILE}" != "${BUILD_PROFILE}" ] -# then -# echo "CCWS: cannot source '${BUILD_PROFILE}' profile, '${SOURCED_BUILD_PROFILE}' is already in use." -# return 0 -# fi -#fi if [ -z "${CCWS_ARTIFACTS_DIR}" ] then if [ -z "${ARTIFACTS_DIR}" ] then - CCWS_ARTIFACTS_DIR="${WORKSPACE_DIR}/artifacts/${BUILD_PROFILE}" + CCWS_ARTIFACTS_DIR="${WORKSPACE_DIR}/artifacts/${CCWS_BUILD_PROFILES_ID}" else - CCWS_ARTIFACTS_DIR="${ARTIFACTS_DIR}/${BUILD_PROFILE}" + CCWS_ARTIFACTS_DIR="${ARTIFACTS_DIR}/${CCWS_BUILD_PROFILES_ID}" fi fi -CCWS_BUILD_PROFILE_DIR="${BUILD_PROFILES_DIR}/${BUILD_PROFILE}" -CCWS_BUILD_DIR=${CCWS_BUILD_DIR:-"${WORKSPACE_DIR}/build/${BUILD_PROFILE}"} -CCWS_LOG_DIR=${CCWS_LOG_DIR:-"${WORKSPACE_DIR}/build/log/${BUILD_PROFILE}"} +CCWS_PRIMARY_BUILD_PROFILE_DIR="${BUILD_PROFILES_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}" +CCWS_LOG_DIR=${CCWS_LOG_DIR:-"${WORKSPACE_DIR}/build/log/${CCWS_BUILD_PROFILES_ID}"} CCWS_SOURCE_DIR="${WORKSPACE_SRC}" CCWS_SOURCE_EXTRAS="${CCWS_SOURCE_DIR}/.ccws" -export CCWS_ARTIFACTS_DIR CCWS_BUILD_PROFILE_DIR CCWS_BUILD_DIR CCWS_SOURCE_DIR CCWS_LOG_DIR CCWS_SOURCE_EXTRAS +export CCWS_ARTIFACTS_DIR CCWS_PRIMARY_BUILD_PROFILE_DIR CCWS_SOURCE_DIR CCWS_LOG_DIR CCWS_SOURCE_EXTRAS CCWS_PROOT_BIN="${CCWS_DIR}/scripts/proot" export CCWS_PROOT_BIN @@ -134,12 +121,16 @@ then then case "${OS_DISTRO_HOST}" in bionic) + ROS_VERSION=1 ROS_DISTRO=melodic;; focal) + ROS_VERSION=1 ROS_DISTRO=noetic;; jammy) + ROS_VERSION=2 ROS_DISTRO=humble;; noble) + ROS_VERSION=2 ROS_DISTRO=jazzy;; esac fi @@ -152,6 +143,14 @@ else export ROS_DISTRO fi +case "${ROS_DISTRO}" in + melodic|noetic) + ROS_VERSION=1;; + *) + ROS_VERSION=2;; +esac +export ROS_VERSION + # has to be set for colcon to determine dependencies properly case "${ROS_DISTRO}" in melodic) @@ -203,7 +202,7 @@ CCWS_CXX_STANDARD=17 export CCWS_CXX_STANDARD # since 3.21: https://cmake.org/cmake/help/latest/envvar/CMAKE_TOOLCHAIN_FILE.html -CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-"${CCWS_BUILD_PROFILE_DIR}/toolchain.cmake"} +CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-"${CCWS_PRIMARY_BUILD_PROFILE_DIR}/toolchain.cmake"} export CMAKE_TOOLCHAIN_FILE # since 3.12: https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html @@ -233,7 +232,7 @@ CCACHE_BASEDIR="${WORKSPACE_DIR}" CCACHE_NOHASHDIR="YES" CCACHE_MAXSIZE=${CCACHE_MAXSIZE:-"8G"} #CCACHE_LOGFILE=${CCWS_ARTIFACTS_DIR}/ccache.log -#CCACHE_LOGFILE=${CCWS_BUILD_DIR}/ccache.log +#CCACHE_LOGFILE=${CCWS_BUILD_SPACE_DIR}/ccache.log #export CCACHE_LOGFILE export CCACHE_DIR CCACHE_BASEDIR CCACHE_MAXSIZE CCACHE_NOHASHDIR @@ -298,12 +297,12 @@ then source "${HOME}/.nix-profile/etc/profile.d/nix.sh" - CCWS_BUILD_DIR_NIX="${CCWS_BUILD_DIR}/nix" + CCWS_BUILD_SPACE_DIR_NIX="${CCWS_BUILD_SPACE_DIR}/nix" - mkdir -p "${CCWS_BUILD_DIR_NIX}" - ${CCWS_NIX} develop "${CCWS_SOURCE_DIR}" --command env > "${CCWS_BUILD_DIR_NIX}/env" + mkdir -p "${CCWS_BUILD_SPACE_DIR_NIX}" + ${CCWS_NIX} develop "${CCWS_SOURCE_DIR}" --command env > "${CCWS_BUILD_SPACE_DIR_NIX}/env" - #PATH="$(grep '^PATH=' < "${CCWS_BUILD_DIR_NIX}/env" | sed 's/^PATH=//'):${PATH}" + #PATH="$(grep '^PATH=' < "${CCWS_BUILD_SPACE_DIR_NIX}/env" | sed 's/^PATH=//'):${PATH}" # nix compilers mess up CMAKE_LIBRARY_ARCHITECTURE @@ -319,9 +318,9 @@ then fi - NIX_CMAKE_PREFIX_PATH="$(grep '^CMAKE_PREFIX_PATH=' < "${CCWS_BUILD_DIR_NIX}/env" | sed 's/^CMAKE_PREFIX_PATH=//' || echo -n '')" - NIX_CMAKE_LIBRARY_PATH="$(grep '^CMAKE_LIBRARY_PATH=' < "${CCWS_BUILD_DIR_NIX}/env" | sed 's/^CMAKE_LIBRARY_PATH=//' || echo -n '')" - NIX_CMAKE_INCLUDE_PATH="$(grep '^CMAKE_INCLUDE_PATH=' < "${CCWS_BUILD_DIR_NIX}/env" | sed 's/^CMAKE_INCLUDE_PATH=//' || echo -n '')" + NIX_CMAKE_PREFIX_PATH="$(grep '^CMAKE_PREFIX_PATH=' < "${CCWS_BUILD_SPACE_DIR_NIX}/env" | sed 's/^CMAKE_PREFIX_PATH=//' || echo -n '')" + NIX_CMAKE_LIBRARY_PATH="$(grep '^CMAKE_LIBRARY_PATH=' < "${CCWS_BUILD_SPACE_DIR_NIX}/env" | sed 's/^CMAKE_LIBRARY_PATH=//' || echo -n '')" + NIX_CMAKE_INCLUDE_PATH="$(grep '^CMAKE_INCLUDE_PATH=' < "${CCWS_BUILD_SPACE_DIR_NIX}/env" | sed 's/^CMAKE_INCLUDE_PATH=//' || echo -n '')" if [ -n "${NIX_CMAKE_PREFIX_PATH}" ] then @@ -368,18 +367,21 @@ export DEBIAN_FRONTEND ccws_read_exceptions() { - FILENAME_PREFIX="${CCWS_SOURCE_EXTRAS}/${BUILD_PROFILE}.exceptions.${1}" - for FILE in "${FILENAME_PREFIX}" "${FILENAME_PREFIX}.*" + for PROFILE in $(echo ${CCWS_BUILD_PROFILES} | tr "," "\n") do - if [ -f "${FILE}" ] - then - if [ "$1" = "paths" ] + FILENAME_PREFIX="${CCWS_SOURCE_EXTRAS}/${PROFILE}.exceptions.${1}" + for FILE in "${FILENAME_PREFIX}" "${FILENAME_PREFIX}.*" + do + if [ -f "${FILE}" ] then - JOIN_PATTERN="s=^=:${CCWS_SOURCE_DIR}/=" - else - JOIN_PATTERN="s=^=:=" + if [ "$1" = "paths" ] + then + JOIN_PATTERN="s=^=:${CCWS_SOURCE_DIR}/=" + else + JOIN_PATTERN="s=^=:=" + fi + sed -e 's/[[:space:]]*#.*//' -e '/^[[:space:]]*$/d' -e "${JOIN_PATTERN}" < "${FILE}" | tr -d '\n' fi - sed -e 's/[[:space:]]*#.*//' -e '/^[[:space:]]*$/d' -e "${JOIN_PATTERN}" < "${FILE}" | tr -d '\n' - fi + done done } diff --git a/ccws/profiles/build/common/toolchain.cmake b/ccws/profiles/build/common/toolchain.cmake index 2c1a8e7..0939e66 100644 --- a/ccws/profiles/build/common/toolchain.cmake +++ b/ccws/profiles/build/common/toolchain.cmake @@ -7,9 +7,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE STRING "" FORCE) set(CMAKE_C_COMPILER_LAUNCHER ccache CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER_LAUNCHER ccache CACHE STRING "" FORCE) -set(CCWS_BUILD_PROFILE "$ENV{BUILD_PROFILE}" CACHE STRING "" FORCE) +# TODO deprecated +set(CCWS_BUILD_PROFILE "$ENV{CCWS_PRIMARY_BUILD_PROFILE}" CACHE STRING "" FORCE) +string(REPLACE "," ";" CCWS_BUILD_PROFILES_LIST "$ENV{CCWS_BUILD_PROFILES}") +set(CCWS_BUILD_PROFILES "${CCWS_BUILD_PROFILES_LIST}" CACHE STRING "" FORCE) -set(CTEST_BUILD_NAME "${CCWS_BUILD_PROFILE}" CACHE STRING "" FORCE) +set(CTEST_BUILD_NAME "${CCWS_BUILD_PROFILES}" CACHE STRING "" FORCE) # controls testing of CCWS-aware packages set(CCWS_ENABLE_TESTING ON CACHE STRING "" FORCE) # debug level @@ -44,11 +47,6 @@ set(CCWS_CXX_FLAGS_COMMON "-std=c++$ENV{CCWS_CXX_STANDARD} -fstack-protector-str set(CCWS_CXX_FLAGS_WARNINGS "-Wall -Wextra -Wshadow -Werror -Werror=return-type -Werror=pedantic -pedantic-errors" CACHE STRING "" FORCE) set(CCWS_CXX_FLAGS "${CCWS_CXX_FLAGS_COMMON} ${CCWS_CXX_FLAGS_WARNINGS}" CACHE STRING "" FORCE) -# 1. it is generally a bad idea to depend on a build profile in the code -# 2. this may lead to unnecessary cache misses during compilation (ccache) -# 3. if necessary this define can be added for a specific package -#add_definitions(-DCCWS_BUILD_PROFILE="${CCWS_BUILD_PROFILE}") - # -flto # performance gain seems to be marginal in general, but the main limiting # factor currently (gcc7) is: diff --git a/ccws/profiles/build/cppcheck/setup.bash b/ccws/profiles/build/cppcheck/setup.bash index abe2208..ef4d87d 100644 --- a/ccws/profiles/build/cppcheck/setup.bash +++ b/ccws/profiles/build/cppcheck/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../static_checks/setup.bash" "${@:1}" "" ########################################################################################## diff --git a/ccws/profiles/build/cppcheck/targets.mk b/ccws/profiles/build/cppcheck/targets.mk index d95fe3b..feffb22 100644 --- a/ccws/profiles/build/cppcheck/targets.mk +++ b/ccws/profiles/build/cppcheck/targets.mk @@ -1,13 +1,13 @@ -bp_cppcheck_build: assert_BASE_BUILD_PROFILE_must_exist - rm -Rf "${WORKSPACE_DIR}/build/${BUILD_PROFILE}/" - mkdir -p "${WORKSPACE_DIR}/build/${BUILD_PROFILE}/" +bp_cppcheck_build: assert_BUILD_PROFILES_must_exist assert_SECONDARY_BUILD_PROFILE_must_exist + rm -Rf "${CCWS_BUILD_SPACE_DIR}/" + mkdir -p "${CCWS_BUILD_SPACE_DIR}/" bash -c "${SETUP_SCRIPT}; \ echo '${SETUP_SCRIPT}'; \ echo \"<<\$${CCWS_STATIC_DIR_EXCEPTIONS}>>>\"; \ - echo $${CCWS_STATIC_DIR_EXCEPTIONS} > '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/suppressions'" - sed -i -e 's/:/\n/g' '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/suppressions' - sed -i -e '/^$$/d' '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/suppressions' - sed -i -e 's/^/*:/' -e 's/$$/*/' '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/suppressions' + echo $${CCWS_STATIC_DIR_EXCEPTIONS} > '${CCWS_BUILD_SPACE_DIR}/suppressions'" + sed -i -e 's/:/\n/g' '${CCWS_BUILD_SPACE_DIR}/suppressions' + sed -i -e '/^$$/d' '${CCWS_BUILD_SPACE_DIR}/suppressions' + sed -i -e 's/^/*:/' -e 's/$$/*/' '${CCWS_BUILD_SPACE_DIR}/suppressions' bash -c "${SETUP_SCRIPT}; \ cppcheck \ -j ${JOBS} \ @@ -21,11 +21,11 @@ bp_cppcheck_build: assert_BASE_BUILD_PROFILE_must_exist --inline-suppr \ -i /usr \ \$${CCWS_CPPCHECK_EXCEPTIONS} \ - --suppressions-list='${WORKSPACE_DIR}/build/${BUILD_PROFILE}/suppressions' \ - --project='${WORKSPACE_DIR}/build/${BASE_BUILD_PROFILE}/compile_commands.json' \ + --suppressions-list='${CCWS_BUILD_SPACE_DIR}/suppressions' \ + --project='${WORKSPACE_DIR}/build/${CCWS_SECONDARY_BUILD_PROFILE}/compile_commands.json' \ 3>&1 1>&2 2>&3 \ - | tee --append '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/cppcheck.err' " - test ! -s '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/cppcheck.err' || exit 1 + | tee --append '${CCWS_BUILD_SPACE_DIR}/cppcheck.err' " + test ! -s '${CCWS_BUILD_SPACE_DIR}/cppcheck.err' || exit 1 bp_cppcheck_install_build: bp_common_install_build diff --git a/ccws/profiles/build/cross_jetson_nano/targets.mk b/ccws/profiles/build/cross_jetson_nano/targets.mk index 62476c4..35263df 100644 --- a/ccws/profiles/build/cross_jetson_nano/targets.mk +++ b/ccws/profiles/build/cross_jetson_nano/targets.mk @@ -1,5 +1,5 @@ assert_BUILD_PROFILE_must_be_cross_jetson_nano: - test "${BUILD_PROFILE}" = "cross_jetson_nano" + test "${CCWS_PRIMARY_BUILD_PROFILE}" = "cross_jetson_nano" bp_cross_jetson_nano_install_build: cross_common_install_build bp_common_install_build assert_BUILD_PROFILE_must_be_cross_jetson_nano ${MAKE} cross_jetson_install_build_${OS_DISTRO_BUILD} diff --git a/ccws/profiles/build/cross_jetson_xavier/setup.bash b/ccws/profiles/build/cross_jetson_xavier/setup.bash index ef29701..1214678 100644 --- a/ccws/profiles/build/cross_jetson_xavier/setup.bash +++ b/ccws/profiles/build/cross_jetson_xavier/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} CROSS_PROFILE="$(basename "$(dirname "${BASH_SOURCE[0]}")")" export CROSS_PROFILE diff --git a/ccws/profiles/build/cross_jetson_xavier/targets.mk b/ccws/profiles/build/cross_jetson_xavier/targets.mk index 52698f0..e1b750c 100644 --- a/ccws/profiles/build/cross_jetson_xavier/targets.mk +++ b/ccws/profiles/build/cross_jetson_xavier/targets.mk @@ -1,5 +1,5 @@ assert_BUILD_PROFILE_must_be_cross_jetson_xavier: - test "${BUILD_PROFILE}" = "cross_jetson_xavier" + test "${CCWS_PRIMARY_BUILD_PROFILE}" = "cross_jetson_xavier" bp_cross_jetson_xavier_install_build: cross_common_install_build bp_common_install_build assert_BUILD_PROFILE_must_be_cross_jetson_xavier ${MAKE} cross_jetson_install_build_${OS_DISTRO_BUILD} diff --git a/ccws/profiles/build/cross_raspberry_pi/setup.bash b/ccws/profiles/build/cross_raspberry_pi/setup.bash index 0661428..7ed3fb5 100644 --- a/ccws/profiles/build/cross_raspberry_pi/setup.bash +++ b/ccws/profiles/build/cross_raspberry_pi/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} CROSS_PROFILE="$(basename "$(dirname "${BASH_SOURCE[0]}")")" export CROSS_PROFILE diff --git a/ccws/profiles/build/cross_raspberry_pi/targets.mk b/ccws/profiles/build/cross_raspberry_pi/targets.mk index 6a2d647..b3b307c 100644 --- a/ccws/profiles/build/cross_raspberry_pi/targets.mk +++ b/ccws/profiles/build/cross_raspberry_pi/targets.mk @@ -1,5 +1,5 @@ assert_BUILD_PROFILE_must_be_cross_raspberry_pi: - test "${BUILD_PROFILE}" = "cross_raspberry_pi" + test "${CCWS_PRIMARY_BUILD_PROFILE}" = "cross_raspberry_pi" bp_cross_raspberry_pi_install_build: cross_common_install_build cross_purge bp_common_install_build ${MAKE} -j${JOBS} bp_cross_raspberry_pi_install_build_compiler @@ -62,8 +62,8 @@ bp_cross_raspberry_pi_build: private_cross_build private_bp_cross_raspberry_pi_pack: assert_BUILD_PROFILE_must_be_cross_raspberry_pi mkdir -p "${CCWS_ARTIFACTS_DIR}" cd "${CCWS_SYSROOT_DATA}"; \ - tar -cjf "${CCWS_ARTIFACTS_DIR}/${BUILD_PROFILE}_image.tar.bz2" system.img cross-pi-gcc + tar -cjf "${CCWS_ARTIFACTS_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}_image.tar.bz2" system.img cross-pi-gcc private_bp_cross_raspberry_pi_unpack: assert_BUILD_PROFILE_must_be_cross_raspberry_pi cd "${CCWS_SYSROOT_DATA}"; \ - tar -xf "${CCWS_ARTIFACTS_DIR}/${BUILD_PROFILE}_image.tar.bz2" + tar -xf "${CCWS_ARTIFACTS_DIR}/${CCWS_PRIMARY_BUILD_PROFILE}_image.tar.bz2" diff --git a/ccws/profiles/build/deb/bin/control.sh b/ccws/profiles/build/deb/bin/control.sh index d56da82..77f25c1 100755 --- a/ccws/profiles/build/deb/bin/control.sh +++ b/ccws/profiles/build/deb/bin/control.sh @@ -9,7 +9,7 @@ Version: $(sed 's/_/-/g' < "${CCWS_DEB_INFO_DIR}/version_hash.txt") Architecture: ${CCWS_DEB_ARCH} Maintainer: ${AUTHOR} <${EMAIL}> Description: ${VENDOR} ${PKG} -Depends: $(paste -s -d ',' < "${WORKSPACE_DIR}/build/${BUILD_PROFILE}_dep/deps_${PKG_ID}.deb") +Depends: $(paste -s -d ',' < "${WORKSPACE_DIR}/build/${CCWS_BUILD_PROFILES_ID}_dep/deps_${PKG_ID}.deb") Installed-Size: $(du -s "${CCWS_INSTALL_DIR_BUILD_ROOT}" | cut -f 1) EOF diff --git a/ccws/profiles/build/deb/setup.bash b/ccws/profiles/build/deb/setup.bash index 053790a..4dfeabe 100644 --- a/ccws/profiles/build/deb/setup.bash +++ b/ccws/profiles/build/deb/setup.bash @@ -6,11 +6,11 @@ set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} -BASE_BUILD_PROFILE=${1:-"$BASE_BUILD_PROFILE"} -if [ -z "${BASE_BUILD_PROFILE}" ] +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_SECONDARY_BUILD_PROFILE=${1:-"${CCWS_SECONDARY_BUILD_PROFILE}"} +if [ -z "${CCWS_SECONDARY_BUILD_PROFILE}" ] then - echo "Build profile cannot be chosen automatically for 'deb' mixin, make sure BASE_BUILD_PROFILE is set." + echo "Build profile cannot be chosen automatically for 'deb' mixin, make sure that secondary profile is set." return 0 fi @@ -19,8 +19,6 @@ fi # override parameters usually set in common/setup.bash # -CCWS_BUILD_DIR="${WORKSPACE_DIR}/build/${BUILD_PROFILE}_${BASE_BUILD_PROFILE}" - if [ -z "${INSTALL_PKG_PREFIX}" ] then case "${PKG}" in @@ -37,7 +35,7 @@ then esac fi -CCWS_PKG_FULL_NAME=${INSTALL_PKG_PREFIX}__${BASE_BUILD_PROFILE}__$(echo "${VERSION}" | sed -e 's/[[:punct:]]/_/g' -e 's/[[:space:]]/_/g') +CCWS_PKG_FULL_NAME=${INSTALL_PKG_PREFIX}__$(echo "${CCWS_SECONDARY_BUILD_PROFILES}" | sed -e 's/,/_/g')__$(echo "${VERSION}" | sed -e 's/[[:punct:]]/_/g' -e 's/[[:space:]]/_/g') CCWS_INSTALL_DIR_HOST="/opt/${VENDOR}/${CCWS_PKG_FULL_NAME}" CCWS_INSTALL_DIR_BUILD_ROOT="${WORKSPACE_DIR}/install/${CCWS_PKG_FULL_NAME}" @@ -46,11 +44,11 @@ CCWS_INSTALL_DIR_BUILD="${CCWS_INSTALL_DIR_BUILD_ROOT}/${CCWS_INSTALL_DIR_HOST}" export CCWS_INSTALL_DIR_BUILD_ROOT CCWS_INSTALL_DIR_HOST -CMAKE_TOOLCHAIN_FILE=${BUILD_PROFILES_DIR}/${BASE_BUILD_PROFILE}/toolchain.cmake +CMAKE_TOOLCHAIN_FILE=${BUILD_PROFILES_DIR}/${CCWS_SECONDARY_BUILD_PROFILE}/toolchain.cmake ########################################################################################## -source "$(dirname "${BASH_SOURCE[0]}")/../${BASE_BUILD_PROFILE}/setup.bash" "${@:2}" "" +source "$(dirname "${BASH_SOURCE[0]}")/../${CCWS_SECONDARY_BUILD_PROFILE}/setup.bash" "${@:2}" "" ########################################################################################## diff --git a/ccws/profiles/build/deb/targets.mk b/ccws/profiles/build/deb/targets.mk index cdbae6a..0d05050 100644 --- a/ccws/profiles/build/deb/targets.mk +++ b/ccws/profiles/build/deb/targets.mk @@ -1,13 +1,11 @@ -# this script automatically sources profile specific setup script -DEB_SETUP_SCRIPT=${SETUP_SCRIPT} ${BASE_BUILD_PROFILE} - deb_%: - ${MAKE} wswraptarget TARGET="private_$@" SETUP_SCRIPT="${DEB_SETUP_SCRIPT}" + ${MAKE} wswraptarget TARGET="private_$@" private_deb_compile: echo ${CCWS_EXTRA_INSTALL_DIRS} | sed -e "s/ /\n/g" | xargs -I {} mkdir -p ${CCWS_INSTALL_DIR_BUILD_ROOT}/{} mkdir -p "${CCWS_DEBIAN_POSTINST_DIR}" "${CCWS_DEBIAN_PREINST_DIR}" "${CCWS_DEBIAN_POSTRM_DIR}" "${CCWS_DEBIAN_PRERM_DIR}" - ${MAKE} bp_${BASE_BUILD_PROFILE}_build BUILD_PROFILE=${BASE_BUILD_PROFILE} + # trim first profile (must be deb) and proceed with the rest + ${MAKE} bp_${CCWS_SECONDARY_BUILD_PROFILE}_build CCWS_BUILD_PROFILES=${CCWS_SECONDARY_BUILD_PROFILES} echo "#!/bin/bash -x" > "${CCWS_SOURCE_SCRIPT}" echo "CCWS_EXTRA_SOURCE_SCRIPTS=\"${CCWS_EXTRA_SOURCE_SCRIPTS}\"" >> "${CCWS_SOURCE_SCRIPT}" cat "${EXEC_PROFILES_DIR}/common/setup.bash" | grep -v "^#!" >> "${CCWS_SOURCE_SCRIPT}" @@ -28,7 +26,7 @@ private_deb_info: assert_PKG_arg_must_be_specified private_deb_version_hash private_deb_pack: assert_PKG_arg_must_be_specified private_dep_resolve private_deb_info assert_AUTHOR_must_not_be_empty assert_EMAIL_must_not_be_empty # generate scripts mkdir -p "${CCWS_DEBIAN_DIR}" - find "${CCWS_BUILD_PROFILE_DIR}/bin/" -iname "*.sh" | xargs -I {} bash {} + find "${CCWS_PRIMARY_BUILD_PROFILE_DIR}/bin/" -iname "*.sh" | xargs -I {} bash {} rm -Rf "${CCWS_DEBIAN_POSTINST_DIR}" "${CCWS_DEBIAN_PREINST_DIR}" "${CCWS_DEBIAN_POSTRM_DIR}" "${CCWS_DEBIAN_PRERM_DIR}" # cleanup find "${CCWS_INSTALL_DIR_BUILD_ROOT}/" -iname '*.pyc' -or -iname '__pycache__' | xargs --no-run-if-empty rm -Rf @@ -47,7 +45,7 @@ private_dpkg_deb_focal: private_dpkg_deb_bionic private_dpkg_deb_jammy: dpkg-deb -Zzstd -z9 --root-owner-group --build "${CCWS_INSTALL_DIR_BUILD_ROOT}" "${CCWS_ARTIFACTS_DIR}/${CCWS_PKG_FULL_NAME}.deb" -private_dpkg_deb_noble: +private_dpkg_deb_noble: dpkg-deb -Zzstd -z9 --root-owner-group --threads-max=${JOBS} --build "${CCWS_INSTALL_DIR_BUILD_ROOT}" "${CCWS_ARTIFACTS_DIR}/${CCWS_PKG_FULL_NAME}.deb" @@ -61,9 +59,9 @@ private_deb_version_hash: assert_PKG_arg_must_be_specified private_deb_lint: assert_PKG_arg_must_be_specified test -f "${CCWS_ARTIFACTS_DIR}/${CCWS_PKG_FULL_NAME}.deb" - lintian --pedantic --suppress-tags-from-file ${CCWS_BUILD_PROFILE_DIR}/lintian_${OS_DISTRO_BUILD}.supp "${CCWS_ARTIFACTS_DIR}/${CCWS_PKG_FULL_NAME}.deb" + lintian --pedantic --suppress-tags-from-file ${CCWS_PRIMARY_BUILD_PROFILE_DIR}/lintian_${OS_DISTRO_BUILD}.supp "${CCWS_ARTIFACTS_DIR}/${CCWS_PKG_FULL_NAME}.deb" -bp_deb_build: assert_BASE_BUILD_PROFILE_must_exist +bp_deb_build: assert_BUILD_PROFILES_must_exist ${MAKE} private_deb_compile ${MAKE} private_deb_pack diff --git a/ccws/profiles/build/doxygen/setup.bash b/ccws/profiles/build/doxygen/setup.bash index babd9e0..9fada51 100644 --- a/ccws/profiles/build/doxygen/setup.bash +++ b/ccws/profiles/build/doxygen/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" diff --git a/ccws/profiles/build/reldebug/setup.bash b/ccws/profiles/build/reldebug/setup.bash index 212c602..972ab9c 100644 --- a/ccws/profiles/build/reldebug/setup.bash +++ b/ccws/profiles/build/reldebug/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" ########################################################################################## diff --git a/ccws/profiles/build/scan_build/setup.bash b/ccws/profiles/build/scan_build/setup.bash index a0c68a4..945890b 100644 --- a/ccws/profiles/build/scan_build/setup.bash +++ b/ccws/profiles/build/scan_build/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"static_checks"}/setup.bash" "${@:2}" "" CCWS_STATIC_DIR_EXCEPTIONS="${CCWS_STATIC_DIR_EXCEPTIONS}$(ccws_read_exceptions paths)" diff --git a/ccws/profiles/build/scan_build/toolchain_body.cmake b/ccws/profiles/build/scan_build/toolchain_body.cmake index fdc09e3..789b953 100644 --- a/ccws/profiles/build/scan_build/toolchain_body.cmake +++ b/ccws/profiles/build/scan_build/toolchain_body.cmake @@ -8,7 +8,7 @@ set(CMAKE_C_COMPILER /usr/share/clang/scan-build-$ENV{CCWS_LLVM_VERSION}/libexec find_program(CCWS_CLANG_TIDY_EXECUTABLE NAMES clang-tidy-$ENV{CCWS_LLVM_VERSION} REQUIRED) -set(CCWS_CLANG_TIDY "${CCWS_CLANG_TIDY_EXECUTABLE};--config-file=$ENV{CCWS_BUILD_PROFILE_DIR}/clang_tidy_config.yaml;--header-filter=$ENV{WORKSPACE_DIR}/.*") +set(CCWS_CLANG_TIDY "${CCWS_CLANG_TIDY_EXECUTABLE};--config-file=$ENV{BUILD_PROFILES_DIR}/scan_build/clang_tidy_config.yaml;--header-filter=$ENV{WORKSPACE_DIR}/.*") set(CCWS_CLANG_TIDY "${CCWS_CLANG_TIDY}" CACHE STRING "" FORCE) diff --git a/ccws/profiles/build/static_checks/setup.bash b/ccws/profiles/build/static_checks/setup.bash index dc99104..0024023 100644 --- a/ccws/profiles/build/static_checks/setup.bash +++ b/ccws/profiles/build/static_checks/setup.bash @@ -5,7 +5,7 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" diff --git a/ccws/profiles/build/static_checks/targets.mk b/ccws/profiles/build/static_checks/targets.mk index 0caeda4..5fb7022 100644 --- a/ccws/profiles/build/static_checks/targets.mk +++ b/ccws/profiles/build/static_checks/targets.mk @@ -58,11 +58,11 @@ cppcheck: # header paths with `-I` flags but that is not trivial in a workspace, # might require parsing compilation commands from cmake. ${MAKE} static_checks_generic_dir_filter TARGET=$@ - find "${WORKSPACE_SRC}" -type f -iname '*.hpp' -or -iname "*.cpp" -or -iname "*.h" > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input - rm -f '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/cppcheck.err' + find "${WORKSPACE_SRC}" -type f -iname '*.hpp' -or -iname "*.cpp" -or -iname "*.h" > ${CCWS_BUILD_SPACE_DIR}/$@/input + rm -f '${CCWS_BUILD_SPACE_DIR}/$@/cppcheck.err' bash -c "${SETUP_SCRIPT}; \ - source ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/filter > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered; \ - cat ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered | xargs --max-procs=${JOBS} --no-run-if-empty -I {} \ + source ${CCWS_BUILD_SPACE_DIR}/$@/filter > ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered; \ + cat ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered | xargs --max-procs=${JOBS} --no-run-if-empty -I {} \ cppcheck \ -j 1 \ --relative-paths \ @@ -77,8 +77,8 @@ cppcheck: \$${CCWS_CPPCHECK_EXCEPTIONS} \ 3>&1 1>&2 2>&3 \ {} \ - | tee --append '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/cppcheck.err' " - test ! -s '${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/cppcheck.err' || exit 1 + | tee --append '${CCWS_BUILD_SPACE_DIR}/$@/cppcheck.err' " + test ! -s '${CCWS_BUILD_SPACE_DIR}/$@/cppcheck.err' || exit 1 cpplint: @@ -92,27 +92,27 @@ cpplint: # internal target static_checks_generic_dir_filter: - mkdir -p ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/${TARGET} - echo -n "test -f ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/${TARGET}/input && (cat ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/${TARGET}/input" > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/${TARGET}/filter + mkdir -p ${CCWS_BUILD_SPACE_DIR}/${TARGET} + echo -n "test -f ${CCWS_BUILD_SPACE_DIR}/${TARGET}/input && (cat ${CCWS_BUILD_SPACE_DIR}/${TARGET}/input" > ${CCWS_BUILD_SPACE_DIR}/${TARGET}/filter bash -c "${SETUP_SCRIPT}; \ - echo -n \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/:/ :/g' -e 's=:\([[:graph:]]*\)= | grep -v \"\1\" =g' >> ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/${TARGET}/filter" - echo -n " || true)" >> ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/${TARGET}/filter + echo -n \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/:/ :/g' -e 's=:\([[:graph:]]*\)= | grep -v \"\1\" =g' >> ${CCWS_BUILD_SPACE_DIR}/${TARGET}/filter" + echo -n " || true)" >> ${CCWS_BUILD_SPACE_DIR}/${TARGET}/filter flawfinder: ${MAKE} static_checks_generic_dir_filter TARGET=$@ - find "${WORKSPACE_SRC}" -type f \( -iname '*.cpp' -or -iname '*.h' \) > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input + find "${WORKSPACE_SRC}" -type f \( -iname '*.cpp' -or -iname '*.h' \) > ${CCWS_BUILD_SPACE_DIR}/$@/input bash -c " \ - source ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/filter > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered; \ - cat ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered | xargs --no-run-if-empty --max-procs=${JOBS} -I {} flawfinder --singleline --dataonly --quiet --minlevel=0 {}" + source ${CCWS_BUILD_SPACE_DIR}/$@/filter > ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered; \ + cat ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered | xargs --no-run-if-empty --max-procs=${JOBS} -I {} flawfinder --singleline --dataonly --quiet --minlevel=0 {}" yamllint: ${MAKE} static_checks_generic_dir_filter TARGET=$@ - find "${WORKSPACE_SRC}" -type f -iname '*.yaml' > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input + find "${WORKSPACE_SRC}" -type f -iname '*.yaml' > ${CCWS_BUILD_SPACE_DIR}/$@/input bash -c "${SETUP_SCRIPT}; \ - source ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/filter > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered; \ - cat ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered | xargs --max-procs=${JOBS} --no-run-if-empty -I {} \ + source ${CCWS_BUILD_SPACE_DIR}/$@/filter > ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered; \ + cat ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered | xargs --max-procs=${JOBS} --no-run-if-empty -I {} \ env LC_ALL=C.UTF-8 yamllint -d \"{extends: default, \ rules: { \ colons: {max-spaces-before: 0, max-spaces-after: -1}, \ @@ -134,9 +134,9 @@ shellcheck: && find ${CCWS_DIR}/scripts -type f \( -iname '*.sh' -or -iname '*.bash' \) \ && find ${WORKSPACE_DIR} -maxdepth 2 -type f \( -iname '*.sh' -or -iname '*.bash' \) \ && find "${WORKSPACE_SRC}" -iname '*.sh' -or -iname '*.bash' ) \ - > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input; \ - source ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/filter > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered; \ - cat ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered | xargs --no-run-if-empty --max-procs=${JOBS} -I {} shellcheck -x \$${CCWS_SHELLCHECK_EXCEPTIONS} {}" + > ${CCWS_BUILD_SPACE_DIR}/$@/input; \ + source ${CCWS_BUILD_SPACE_DIR}/$@/filter > ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered; \ + cat ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered | xargs --no-run-if-empty --max-procs=${JOBS} -I {} shellcheck -x \$${CCWS_SHELLCHECK_EXCEPTIONS} {}" catkin_lint: @@ -155,19 +155,19 @@ catkin_lint: pylint: bash -c "${SETUP_SCRIPT}; \ DIR_EXCEPTIONS=\$$(echo \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/^://' -e 's/:/,/g'); \ - pylint --rcfile \$${CCWS_BUILD_PROFILE_DIR}/pylintrc --jobs ${JOBS} --ignore-paths \"\$${DIR_EXCEPTIONS}\" '${WORKSPACE_SRC}'" + pylint --rcfile \$${CCWS_PRIMARY_BUILD_PROFILE_DIR}/pylintrc --jobs ${JOBS} --ignore-paths \"\$${DIR_EXCEPTIONS}\" '${WORKSPACE_SRC}'" flake8: bash -c "${SETUP_SCRIPT}; \ DIR_EXCEPTIONS=\$$(echo \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/^://' -e 's/:/,/g'); \ - flake8 --config \$${CCWS_BUILD_PROFILE_DIR}/flake8 --exclude \"\$${DIR_EXCEPTIONS}\" '${WORKSPACE_SRC}'" + flake8 --config \$${CCWS_PRIMARY_BUILD_PROFILE_DIR}/flake8 --exclude \"\$${DIR_EXCEPTIONS}\" '${WORKSPACE_SRC}'" mypy: ${MAKE} static_checks_generic_dir_filter TARGET=$@ bash -c "${SETUP_SCRIPT}; \ DIR_EXCEPTIONS=\$$(echo \$${CCWS_STATIC_DIR_EXCEPTIONS} | sed -e 's/:/ --exclude /g' -e 's=${WORKSPACE_SRC}==g'); \ - find '${WORKSPACE_SRC}' -iname '*\.py' > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input; \ - source ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/filter > ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered; \ - test -e ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered -a ! -s ${WORKSPACE_DIR}/build/${BUILD_PROFILE}/$@/input.filtered \ + find '${WORKSPACE_SRC}' -iname '*\.py' > ${CCWS_BUILD_SPACE_DIR}/$@/input; \ + source ${CCWS_BUILD_SPACE_DIR}/$@/filter > ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered; \ + test -e ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered -a ! -s ${CCWS_BUILD_SPACE_DIR}/$@/input.filtered \ || mypy --namespace-packages --explicit-package-bases --ignore-missing-imports \$${DIR_EXCEPTIONS} '${WORKSPACE_SRC}'" diff --git a/ccws/profiles/build/thread_sanitizer/setup.bash b/ccws/profiles/build/thread_sanitizer/setup.bash index 0d8cf32..bc1719c 100644 --- a/ccws/profiles/build/thread_sanitizer/setup.bash +++ b/ccws/profiles/build/thread_sanitizer/setup.bash @@ -5,13 +5,13 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"common"}/setup.bash" "${@:2}" "" ########################################################################################## # thread # not supported on Linux (yet?): ignore_noninstrumented_modules=1:ignore_interceptors_accesses=1 -TSAN_OPTIONS=second_deadlock_stack=1:suppressions=${CCWS_BUILD_PROFILE_DIR}/thread.supp:history_size=7:halt_on_error=1 +TSAN_OPTIONS=second_deadlock_stack=1:suppressions=${BUILD_PROFILES_DIR}/thread_sanitizer/thread.supp:history_size=7:halt_on_error=1 export TSAN_OPTIONS diff --git a/ccws/profiles/template_build/setup.bash b/ccws/profiles/template_build/setup.bash index d66a374..c1fc3c3 100644 --- a/ccws/profiles/template_build/setup.bash +++ b/ccws/profiles/template_build/setup.bash @@ -5,6 +5,6 @@ set -e set -o pipefail ########################################################################################## -BUILD_PROFILE=${BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} +CCWS_PRIMARY_BUILD_PROFILE=${CCWS_PRIMARY_BUILD_PROFILE:-"$(basename "$(dirname "${BASH_SOURCE[0]}")")"} source "$(dirname "${BASH_SOURCE[0]}")/../${1:-"@@BASE_BUILD_PROFILE@@"}/setup.bash" "${@:2}" "" diff --git a/ccws/tests/test_main_ros2_ccws2.mk b/ccws/tests/test_main_ros2_ccws2.mk new file mode 100644 index 0000000..a37e078 --- /dev/null +++ b/ccws/tests/test_main_ros2_ccws2.mk @@ -0,0 +1,124 @@ +THIS_MAKEFILE=ccws/tests/test_main_ros2.mk +WORKSPACE_SRC?=src + +export ROS_DISTRO?=foxy + + +test: + # --- + # package & profile creation + ${MAKE} wspurge + rm -Rf ccws/profiles/build/test_profile/ + ${MAKE} bp_new CCWS_BUILD_PROFILES=test_profile,reldebug + ${MAKE} bp_install_build CCWS_BUILD_PROFILES=test_profile + ${MAKE} wsinit + ${MAKE} new PKG=test_pkg EMAIL=example@example.org AUTHOR=example + ${MAKE} wsscrape_all + ${MAKE} dep_to_repolist PKG=test_pkg + ${MAKE} wsupdate + ${MAKE} log_output TARGET=wsstatus + ${MAKE} dep_install PKG=test_pkg + ${MAKE} test_pkg CCWS_BUILD_PROFILES=test_profile + # --- + ${MAKE} -f ${THIS_MAKEFILE} test_dependencies + ${MAKE} -f ${THIS_MAKEFILE} test_deb + ${MAKE} -f ${THIS_MAKEFILE} test_cmake_toolchain + # --- + # test various build profiles + sudo apt install ros-${ROS_DISTRO}-ros2cli # used to test setup.bash + ${MAKE} -f ${THIS_MAKEFILE} build_with_profile CCWS_BUILD_PROFILES=addr_undef_sanitizers + ${MAKE} -f ${THIS_MAKEFILE} build_with_profile CCWS_BUILD_PROFILES=thread_sanitizer + ${MAKE} -f ${THIS_MAKEFILE} build_with_profile CCWS_BUILD_PROFILES=scan_build + ${MAKE} -f ${THIS_MAKEFILE} build_with_profile CCWS_BUILD_PROFILES=reldebug + # --- + # clangd + ${MAKE} bp_install_build CCWS_BUILD_PROFILES=clangd + ${MAKE} CCWS_BUILD_PROFILES=clangd,reldebug + # --- + # check valgrind exec profile + ${MAKE} ep_install EXEC_PROFILE=valgrind + ${MAKE} wstest EXEC_PROFILE=valgrind + # --- + # check core_pattern exec profile + ${MAKE} ep_install EXEC_PROFILE=core_pattern + ${MAKE} wstest EXEC_PROFILE="core_pattern valgrind" + # --- + # documentation + ${MAKE} bp_install_build CCWS_BUILD_PROFILES=doxygen + ${MAKE} PKG=examples_rclcpp_minimal_subscriber CCWS_BUILD_PROFILES=doxygen + ${MAKE} CCWS_BUILD_PROFILES=doxygen + ${MAKE} graph PKG=examples_rclcpp_minimal_subscriber + ${MAKE} graph + ${MAKE} cache_clean + # --- + ${MAKE} wspurge + ${MAKE} wsinit + ${MAKE} add REPO="https://github.com/asherikov/ariles.git" VERSION="pkg_ws_2" + ${MAKE} wsupdate + ${MAKE} dep_install + ${MAKE} ros2param + # --- + # cppcheck + cp -R ccws/examples/.ccws "${WORKSPACE_SRC}" + ${MAKE} bp_install_build CCWS_BUILD_PROFILES=cppcheck + ${MAKE} CCWS_BUILD_PROFILES=cppcheck,reldebug + rm -Rf "${WORKSPACE_SRC}/.ccws" + # --- + # static checks + -sudo apt purge flake8 # broken? + -sudo python3 -m pip flake8 + -find /usr/lib/python3/ -iname "*flake8*" | xargs sudo rm -Rf + ${MAKE} bp_install_build CCWS_BUILD_PROFILES=static_checks + ${MAKE} CCWS_BUILD_PROFILES=static_checks + +test_dependencies: + ${MAKE} bp_purge + ${MAKE} wspurge + ${MAKE} new PKG=test_dependencies + cp -R ccws/tests/dependencies/package.xml "${WORKSPACE_SRC}/test_dependencies" + ${MAKE} dep_install PKG=test_dependencies + ${MAKE} wspurge + ${MAKE} add REPO="https://github.com/ros2/examples" VERSION="${ROS_DISTRO}" + ${MAKE} wsupdate + ${MAKE} dep_to_repolist + ${MAKE} dep_install + ${MAKE} wsupdate + # --- + # drop downloaded ROS packages, we are going to install binaries + ${MAKE} wsclean + mv "${WORKSPACE_SRC}/examples" ./ + rm -Rf "${WORKSPACE_SRC}"/* + mv examples "${WORKSPACE_SRC}" + +test_deb: + ${MAKE} bp_install_build CCWS_BUILD_PROFILES=deb + ${MAKE} examples_rclcpp_minimal_subscriber CCWS_BUILD_PROFILES=deb,reldebug + ${MAKE} deb_lint PKG=examples_rclcpp_minimal_subscriber CCWS_BUILD_PROFILES=deb,reldebug + sudo dpkg -i artifacts/*/*.deb + dpkg --get-selections | grep minimal-subscriber | cut -f 1 | xargs sudo apt purge --yes + +test_cmake_toolchain: + # workspace cmake toolchain + cp -R ccws/examples/.ccws "${WORKSPACE_SRC}/" + echo 'message(FATAL_ERROR "toolchain inclusion")' > "${WORKSPACE_SRC}/.ccws/toolchain.cmake" + # should fail + ! ${MAKE} examples_rclcpp_minimal_subscriber + rm -Rf "${WORKSPACE_SRC}/.ccws" + +build_with_profile: + ${MAKE} wsclean + ${MAKE} bp_install_build + ${MAKE} build_all + ${MAKE} examples_rclcpp_minimal_subscriber + # workspace test + ${MAKE} wstest + ${MAKE} wsctest + # test recursively + ${MAKE} test_with_deps PKG=examples_rclcpp_minimal_subscriber + ${MAKE} ctest_with_deps PKG=examples_rclcpp_minimal_subscriber + # test exceptions + cp -R ccws/examples/.ccws "${WORKSPACE_SRC}/" + ${MAKE} test_with_deps PKG=examples_rclcpp_minimal_subscriber + ${MAKE} ctest_with_deps PKG=examples_rclcpp_minimal_subscriber + rm -Rf "${WORKSPACE_SRC}/.ccws" + bash -c "source setup.bash && ros2" diff --git a/setup.bash b/setup.bash index 19c0d7d..d9bdd69 100644 --- a/setup.bash +++ b/setup.bash @@ -3,22 +3,23 @@ CCWS_ROOT=$(dirname "${BASH_SOURCE[0]}" | xargs realpath) PROFILES_DIR="${CCWS_ROOT}/ccws/profiles/" -if [ -z "${BUILD_PROFILE}" ]; +if [ -z "${CCWS_BUILD_PROFILES}" ]; then - BUILD_PROFILE="reldebug" + CCWS_BUILD_PROFILES="reldebug" fi if [ $# -gt 0 ] then - BUILD_PROFILE=$1 + CCWS_BUILD_PROFILES=$1 shift fi -SETUP_SCRIPT="${PROFILES_DIR}/build/${BUILD_PROFILE}/setup.bash" +SETUP_SCRIPT="${PROFILES_DIR}/build/$(echo "${CCWS_BUILD_PROFILES}" | cut -f 1 -d ',')/setup.bash" if [ -f "${SETUP_SCRIPT}" ] then - source "${SETUP_SCRIPT}" ""; + # shellcheck disable=SC2046 + source "${SETUP_SCRIPT}" $(echo "${CCWS_BUILD_PROFILES}" | cut -f 2- -d ',' | sed 's/,/ /g'); if [ -t 0 ]; then # ignore errors to prevent session termination if interactive