From 239fbd41f55381e6525d3e0eae8bd8260f79bca2 Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 11 Jan 2023 08:32:18 +0100 Subject: [PATCH 01/15] feat: add arm triplets in enable_cross_compiler --- src/CrossCompiler.cmake | 52 ++++++++++++++++++- src/toolchains/aarch64.toolchain.cmake | 30 +++++++++++ src/toolchains/arm.toolchain.cmake | 30 +++++++++++ src/toolchains/arm64.toolchain.cmake | 30 +++++++++++ .../i686-w64-mingw32.toolchain.cmake | 9 ++-- .../x86_64-w64-mingw32.toolchain.cmake | 9 ++-- 6 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 src/toolchains/aarch64.toolchain.cmake create mode 100644 src/toolchains/arm.toolchain.cmake create mode 100644 src/toolchains/arm64.toolchain.cmake diff --git a/src/CrossCompiler.cmake b/src/CrossCompiler.cmake index c2a4f6b0..23608557 100644 --- a/src/CrossCompiler.cmake +++ b/src/CrossCompiler.cmake @@ -31,6 +31,10 @@ macro(enable_cross_compiler) set(_cc "emcc") set(_cxx "em++") set(TARGET_ARCHITECTURE "wasm32-emscripten") + elseif("${DEFAULT_TRIPLET}" STREQUAL "arm-linux") + set(TARGET_ARCHITECTURE "arm-linux") + elseif("${DEFAULT_TRIPLET}" STREQUAL "arm64-linux") + set(TARGET_ARCHITECTURE "arm64-linux") endif() if("${TARGET_ARCHITECTURE}" STREQUAL "") @@ -48,6 +52,7 @@ macro(enable_cross_compiler) set(TARGET_ARCHITECTURE "wasm32-emscripten") else() # TODO: check for arm compiler + message(WARNING "if you are using arm cross-compiler, please set DEFAULT_TRIPLET") set(TARGET_ARCHITECTURE ${_arch}) endif() endif() @@ -64,11 +69,20 @@ macro(enable_cross_compiler) set(USE_CROSSCOMPILER_MINGW) set(USE_CROSSCOMPILER_EMSCRIPTEN) + set(USE_CROSSCOMPILER_ARM) + set(USE_CROSSCOMPILER_ARM64) + set(USE_CROSSCOMPILER_AARCH64) if(_cc MATCHES "(x86_64|i686)(-w64)?-mingw32-[gc]..?" OR _cxx MATCHES "(x86_64|i686)(-w64)?-mingw32-[gc]..?") set(MINGW TRUE) set(USE_CROSSCOMPILER_MINGW TRUE) elseif(_cc MATCHES "emcc" OR _cxx MATCHES "em\\+\\+") set(USE_CROSSCOMPILER_EMSCRIPTEN TRUE) + elseif(_cc MATCHES "aarch64-linux-gnu-gcc" OR _cxx MATCHES "aarch64-linux-gnu-g\\+\\+") + set(USE_CROSSCOMPILER_AARCH64 TRUE) + elseif("${DEFAULT_TRIPLET}" STREQUAL "arm-linux") + set(USE_CROSSCOMPILER_ARM TRUE) + elseif("${DEFAULT_TRIPLET}" STREQUAL "arm64-linux") + set(USE_CROSSCOMPILER_ARM64 TRUE) endif() set(LIBRARY_LINKAGE) @@ -92,6 +106,26 @@ macro(enable_cross_compiler) set(CROSS_ROOT "/usr/x86_64-w64-mingw32") elseif(_cc MATCHES "i686(-w64)?-mingw32-[gc]..?" OR _cxx MATCHES "i686(-w64)?-mingw32-[gc]..?") set(CROSS_ROOT "/usr/i686-w64-mingw32") + elseif(_cc MATCHES "(gcc-)?arm-linux-gnueabi-[gc]..?" OR _cxx MATCHES "(gcc-)?arm-linux-gnueabi-[gc]..?") + set(CROSS_ROOT "/usr/gcc-arm-linux-gnueabi") + if(NOT DEFINED CROSS_TRIPLET) + set(CROSS_TRIPLET "arm-linux-gnueabi") + endif() + elseif(_cc MATCHES "(gcc-)?arm-linux-gnueabihf-[gc]..?" OR _cxx MATCHES "(gcc-)?arm-linux-gnueabihf-[gc]..?") + set(CROSS_ROOT "/usr/gcc-arm-linux-gnueabihf") + if(NOT DEFINED CROSS_TRIPLET) + set(CROSS_TRIPLET "arm-linux-gnueabihf") + endif() + elseif(_cc MATCHES "(gcc-)?arm-none-eabi-[gc]..?" OR _cxx MATCHES "(gcc-)?arm-none-eabi-[gc]..?") + set(CROSS_ROOT "/usr/gcc-arm-none-eabi") + if(NOT DEFINED CROSS_TRIPLET) + set(CROSS_TRIPLET "arm-none-eabi") + endif() + elseif(_cc MATCHES "(gcc-)?aarch64-linux-gnu-[gc]..?" OR _cxx MATCHES "(gcc-)?aarch64-linux-gnu-[gc]..?") + set(CROSS_ROOT "/usr/gcc-aarch64-linux-gnu") + if(NOT DEFINED CROSS_TRIPLET) + set(CROSS_TRIPLET "gcc-aarch64-linux-gnu") + endif() endif() # TODO: check if path is right, check for header files or something endif() @@ -133,7 +167,9 @@ macro(enable_cross_compiler) set(_toolchain_file) get_toolchain_file(_toolchain_file) - set(CMAKE_TOOLCHAIN_FILE ${_toolchain_file}) + if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE ${_toolchain_file}) + endif() set(CROSSCOMPILING TRUE) message(STATUS "enable cross-compiling") @@ -183,5 +219,19 @@ function(get_toolchain_file value) else() message(ERROR "EMSCRIPTEN_ROOT is not set, please define EMSCRIPTEN_ROOT (emscripten repo)") endif() + elseif(USE_CROSSCOMPILER_AARCH64) + set(${value} + ${ProjectOptions_SRC_DIR}/toolchains/aarch64.toolchain.cmake + PARENT_SCOPE) + elseif(USE_CROSSCOMPILER_ARM) + set(${value} + ${ProjectOptions_SRC_DIR}/toolchains/arm.toolchain.cmake + PARENT_SCOPE) + elseif(USE_CROSSCOMPILER_ARM64) + set(${value} + ${ProjectOptions_SRC_DIR}/toolchains/arm64.toolchain.cmake + PARENT_SCOPE) + elseif("${DEFAULT_TRIPLET}" STREQUAL "arm-linux" OR "${DEFAULT_TRIPLET}" STREQUAL "arm64-linux") + message(STATUS "Don't forget to provide an cmake-toolchain file (for ${DEFAULT_TRIPLET})") endif() endfunction() diff --git a/src/toolchains/aarch64.toolchain.cmake b/src/toolchains/aarch64.toolchain.cmake new file mode 100644 index 00000000..9035cb5d --- /dev/null +++ b/src/toolchains/aarch64.toolchain.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +if(CROSS_ROOT) + set(CMAKE_SYSROOT ${CROSS_ROOT}) + #set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT}) +elseif("${CMAKE_SYSROOT}" STREQUAL "") + #set(CMAKE_SYSROOT /usr/aarch64-linux-gnu) + set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) +endif() + +if(CROSS_C) + set(CMAKE_C_COMPILER ${CROSS_C}) +else() + set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +endif() +if(CROSS_CXX) + set(CMAKE_CXX_COMPILER ${CROSS_CXX}) +else() + set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) +endif() + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/src/toolchains/arm.toolchain.cmake b/src/toolchains/arm.toolchain.cmake new file mode 100644 index 00000000..a2238f0b --- /dev/null +++ b/src/toolchains/arm.toolchain.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +if(CROSS_ROOT) + set(CMAKE_SYSROOT ${CROSS_ROOT}) + #set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT}) +elseif("${CMAKE_SYSROOT}" STREQUAL "") + set(CMAKE_SYSROOT /usr/${CROSS_TRIPLET}) + #set(CMAKE_FIND_ROOT_PATH /usr/${CROSS_TRIPLET}) +endif() + +if(CROSS_C) + set(CMAKE_C_COMPILER ${CROSS_C}) +else() + set(CMAKE_C_COMPILER ${CROSS_TRIPLET}-gcc) +endif() +if(CROSS_CXX) + set(CMAKE_CXX_COMPILER ${CROSS_CXX}) +else() + set(CMAKE_CXX_COMPILER ${CROSS_TRIPLET}-g++) +endif() + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) \ No newline at end of file diff --git a/src/toolchains/arm64.toolchain.cmake b/src/toolchains/arm64.toolchain.cmake new file mode 100644 index 00000000..396366d7 --- /dev/null +++ b/src/toolchains/arm64.toolchain.cmake @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm64) + +if(CROSS_ROOT) + set(CMAKE_SYSROOT ${CROSS_ROOT}) + #set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT}) +elseif("${CMAKE_SYSROOT}" STREQUAL "") + set(CMAKE_SYSROOT /usr/${CROSS_TRIPLET}) + #set(CMAKE_FIND_ROOT_PATH /usr/${CROSS_TRIPLET}) +endif() + +if(CROSS_C) + set(CMAKE_C_COMPILER ${CROSS_C}) +else() + set(CMAKE_C_COMPILER ${CROSS_TRIPLET}-gcc) +endif() +if(CROSS_CXX) + set(CMAKE_CXX_COMPILER ${CROSS_CXX}) +else() + set(CMAKE_CXX_COMPILER ${CROSS_TRIPLET}-g++) +endif() + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) \ No newline at end of file diff --git a/src/toolchains/i686-w64-mingw32.toolchain.cmake b/src/toolchains/i686-w64-mingw32.toolchain.cmake index 61f6d207..0ba729fd 100644 --- a/src/toolchains/i686-w64-mingw32.toolchain.cmake +++ b/src/toolchains/i686-w64-mingw32.toolchain.cmake @@ -3,12 +3,9 @@ cmake_minimum_required(VERSION 3.16) set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR "i686") -if(NOT - "$ENV{CROSS_ROOT}" - STREQUAL - "") - set(CMAKE_SYSROOT $ENV{CROSS_ROOT}) - #set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT}) +if(CROSS_ROOT) + set(CMAKE_SYSROOT ${CROSS_ROOT}) + #set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT}) elseif("${CMAKE_SYSROOT}" STREQUAL "") set(CMAKE_SYSROOT /usr/i686-w64-mingw32) #set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) diff --git a/src/toolchains/x86_64-w64-mingw32.toolchain.cmake b/src/toolchains/x86_64-w64-mingw32.toolchain.cmake index c2a1b6eb..ad234935 100644 --- a/src/toolchains/x86_64-w64-mingw32.toolchain.cmake +++ b/src/toolchains/x86_64-w64-mingw32.toolchain.cmake @@ -3,12 +3,9 @@ cmake_minimum_required(VERSION 3.16) set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR "x64") -if(NOT - "$ENV{CROSS_ROOT}" - STREQUAL - "") - set(CMAKE_SYSROOT $ENV{CROSS_ROOT}) - #set(CMAKE_FIND_ROOT_PATH $ENV{CROSS_ROOT}) +if(CROSS_ROOT) + set(CMAKE_SYSROOT ${CROSS_ROOT}) + #set(CMAKE_FIND_ROOT_PATH ${CROSS_ROOT}) elseif("${CMAKE_SYSROOT}" STREQUAL "") set(CMAKE_SYSROOT /usr/x86_64-w64-mingw32) #set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) From 65afa0a6fc1fbedca5cc40a50c192442212d0def Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 11 Jan 2023 08:36:45 +0100 Subject: [PATCH 02/15] feat: add arm docker tests --- Taskfile.yml | 13 +++ docker-compose.yml | 42 +++++++- docker/Dockerfile.aarch64 | 52 ++++++++++ docker/Dockerfile.arm | 33 ++++++ docker/Dockerfile.pico | 37 +++++++ docker/Taskfile.yml | 32 ++++++ tests/pico/.dockerignore | 8 ++ tests/pico/.gitignore | 7 ++ tests/pico/CMakeLists.txt | 119 +++++++++++++++++++++ tests/pico/LICENSE.TXT | 21 ++++ tests/pico/Taskfile.yml | 10 ++ tests/pico/hello_world.c | 8 ++ tests/pico/pico_sdk_import.cmake | 73 +++++++++++++ tests/pico/vcpkg.json | 8 ++ tests/rpi3/.dockerignore | 1 + tests/rpi3/CMakeLists.txt | 120 +++++++++++++++++++++ tests/rpi3/Taskfile.yml | 26 +++++ tests/rpi3/main.c | 6 ++ tests/rpi3/main.cpp | 6 ++ tests/rpi3/vcpkg.json | 8 ++ tests/rpi4-vcpkg/.dockerignore | 1 + tests/rpi4-vcpkg/CMakeLists.txt | 121 ++++++++++++++++++++++ tests/rpi4-vcpkg/Taskfile.yml | 16 +++ tests/rpi4-vcpkg/cmake/my-toolchain.cmake | 15 +++ tests/rpi4-vcpkg/main.cpp | 6 ++ tests/rpi4-vcpkg/vcpkg.json | 8 ++ tests/rpi4/.dockerignore | 1 + tests/rpi4/CMakeLists.txt | 112 ++++++++++++++++++++ tests/rpi4/Taskfile.yml | 32 ++++++ tests/rpi4/cmake/my-toolchain.cmake | 15 +++ tests/rpi4/main.cpp | 6 ++ tests/rpi4/vcpkg.json | 8 ++ 32 files changed, 970 insertions(+), 1 deletion(-) create mode 100644 docker/Dockerfile.aarch64 create mode 100644 docker/Dockerfile.arm create mode 100644 docker/Dockerfile.pico create mode 100644 tests/pico/.dockerignore create mode 100644 tests/pico/.gitignore create mode 100644 tests/pico/CMakeLists.txt create mode 100644 tests/pico/LICENSE.TXT create mode 100644 tests/pico/Taskfile.yml create mode 100644 tests/pico/hello_world.c create mode 100644 tests/pico/pico_sdk_import.cmake create mode 100644 tests/pico/vcpkg.json create mode 100644 tests/rpi3/.dockerignore create mode 100644 tests/rpi3/CMakeLists.txt create mode 100644 tests/rpi3/Taskfile.yml create mode 100644 tests/rpi3/main.c create mode 100644 tests/rpi3/main.cpp create mode 100644 tests/rpi3/vcpkg.json create mode 100644 tests/rpi4-vcpkg/.dockerignore create mode 100644 tests/rpi4-vcpkg/CMakeLists.txt create mode 100644 tests/rpi4-vcpkg/Taskfile.yml create mode 100644 tests/rpi4-vcpkg/cmake/my-toolchain.cmake create mode 100644 tests/rpi4-vcpkg/main.cpp create mode 100644 tests/rpi4-vcpkg/vcpkg.json create mode 100644 tests/rpi4/.dockerignore create mode 100644 tests/rpi4/CMakeLists.txt create mode 100644 tests/rpi4/Taskfile.yml create mode 100644 tests/rpi4/cmake/my-toolchain.cmake create mode 100644 tests/rpi4/main.cpp create mode 100644 tests/rpi4/vcpkg.json diff --git a/Taskfile.yml b/Taskfile.yml index 9c9af0dd..dc241b02 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -17,6 +17,18 @@ includes: emscripten: taskfile: ./tests/emscripten/Taskfile.yml dir: ./tests/emscripten + rpi3: + taskfile: ./tests/rpi3/Taskfile.yml + dir: ./tests/rpi3 + rpi4: + taskfile: ./tests/rpi4/Taskfile.yml + dir: ./tests/rpi4 + rpi4-vcpkg: + taskfile: ./tests/rpi4-vcpkg/Taskfile.yml + dir: ./tests/rpi4-vcpkg + pico: + taskfile: ./tests/pico/Taskfile.yml + dir: ./tests/pico vars: CWD: @@ -35,6 +47,7 @@ tasks: - task: install:lint - task: minimal:lint - task: emscripten:lint + - task: rpi:lint - npx -y cspell lint --no-progress --show-suggestions clean: diff --git a/docker-compose.yml b/docker-compose.yml index 623cbb7d..27f88a16 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -78,4 +78,44 @@ services: target: build-minimal environment: - CROSS_CC=i686-w64-mingw32-gcc - - CROSS_CXX=i686-w64-mingw32-g++ \ No newline at end of file + - CROSS_CXX=i686-w64-mingw32-g++ + build-rpi3: + build: + context: . + dockerfile: ./docker/Dockerfile.arm + target: build + build-rpi3-release: + build: + context: . + dockerfile: ./docker/Dockerfile.arm + target: build-release + build-rpi4: + build: + context: . + dockerfile: ./docker/Dockerfile.aarch64 + target: build + build-rpi4-release: + build: + context: . + dockerfile: ./docker/Dockerfile.aarch64 + target: build-release + test-rpi4: + build: + context: . + dockerfile: ./docker/Dockerfile.aarch64 + target: test + build-rpi4-vcpkg: + build: + context: . + dockerfile: ./docker/Dockerfile.aarch64 + target: build-vcpkg + build-rpi4-custom: + build: + context: . + dockerfile: ./docker/Dockerfile.aarch64 + target: build-custom + build-pico: + build: + context: . + dockerfile: ./docker/Dockerfile.pico + target: build \ No newline at end of file diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 new file mode 100644 index 00000000..46f7bcec --- /dev/null +++ b/docker/Dockerfile.aarch64 @@ -0,0 +1,52 @@ +FROM ubuntu:22.04 AS base + +ARG setup_cpp_linux_version="0.24.1" + +# add setup_cpp https://github.com/aminya/setup-cpp +ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux +RUN chmod +x /setup_cpp_linux + + + +FROM base AS setup + +# install cmake, ninja, and ccache +RUN /setup_cpp_linux --clangtidy true --clangformat true --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true + +RUN apt-get update && apt-get install -y \ + g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu \ + && rm -rf /var/lib/apt/lists/* + +COPY ./docker/entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT [ "/docker-entrypoint.sh" ] + + +FROM setup AS build +COPY . /home/project_options +WORKDIR /home/project_options +CMD ["/bin/bash", "-c", "task rpi4:build.cross"] + +FROM setup AS build-release +COPY . /home/project_options +WORKDIR /home/project_options +CMD ["/bin/bash", "-c", "task rpi4:build.cross.release"] + +FROM setup AS build-vcpkg +COPY . /home/project_options +WORKDIR /home/project_options +CMD ["/bin/bash", "-c", "task rpi4-vcpkg:build.cross"] + +FROM setup AS build-custom +COPY . /home/project_options +WORKDIR /home/project_options +CMD ["/bin/bash", "-c", "task rpi4:build.cross.custom-toolchain"] + + +FROM setup AS test +RUN apt-get update && apt-get install -y \ + qemu-user \ + && rm -rf /var/lib/apt/lists/* +COPY . /home/project_options +WORKDIR /home/project_options +ENV QEMU_LD_PREFIX /usr/aarch64-linux-gnu +CMD ["/bin/bash", "-c", "task rpi4:build.cross.release && qemu-aarch64 /home/project_options/tests/rpi4/build/Release/example"] diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm new file mode 100644 index 00000000..2e581801 --- /dev/null +++ b/docker/Dockerfile.arm @@ -0,0 +1,33 @@ +FROM ubuntu:22.04 AS base + +ARG setup_cpp_linux_version="0.24.1" + +# add setup_cpp https://github.com/aminya/setup-cpp +ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux +RUN chmod +x /setup_cpp_linux + + + +FROM base AS setup + +# install cmake, ninja, and ccache +RUN /setup_cpp_linux --clangtidy true --clangformat true --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true + +RUN apt-get update && apt-get install -y \ + gcc-arm-none-eabi binutils-arm-none-eabi \ + && rm -rf /var/lib/apt/lists/* + +COPY ./docker/entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT [ "/docker-entrypoint.sh" ] + + +FROM setup AS build +COPY . /home/project_options +WORKDIR /home/project_options +CMD ["/bin/bash", "-c", "task rpi3:build.cross"] + + +FROM setup AS build-release +COPY . /home/project_options +WORKDIR /home/project_options +CMD ["/bin/bash", "-c", "task rpi3:build.cross.release"] \ No newline at end of file diff --git a/docker/Dockerfile.pico b/docker/Dockerfile.pico new file mode 100644 index 00000000..a140c263 --- /dev/null +++ b/docker/Dockerfile.pico @@ -0,0 +1,37 @@ +FROM ubuntu:22.04 AS base + +ARG setup_cpp_linux_version="0.24.1" + +# add setup_cpp https://github.com/aminya/setup-cpp +ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux +RUN chmod +x /setup_cpp_linux + + + +FROM base AS setup + +# install cmake, ninja, and ccache +RUN /setup_cpp_linux --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true + +RUN apt-get update && apt-get install -y \ + gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib \ + && rm -rf /var/lib/apt/lists/* + +# https://github.com/raspberrypi/pico-sdk +RUN git clone https://github.com/raspberrypi/pico-sdk /home/pico-sdk +ENV PICO_SDK_PATH /home/pico-sdk +WORKDIR /home/pico-sdk +RUN git submodule update --init +WORKDIR / + +COPY ./docker/entrypoint.sh /docker-entrypoint.sh +ENTRYPOINT [ "/docker-entrypoint.sh" ] + + +FROM setup AS build +COPY . /home/project_options +RUN cp -rf /home/pico-sdk/external/pico_sdk_import.cmake /home/project_options/tests/pico/pico_sdk_import.cmake +WORKDIR /home/project_options +ENV PROJECT_DIR /home/project_options +CMD ["/bin/bash", "-c", "task pico:build"] + diff --git a/docker/Taskfile.yml b/docker/Taskfile.yml index 19dd8d3d..0facf3d7 100644 --- a/docker/Taskfile.yml +++ b/docker/Taskfile.yml @@ -20,4 +20,36 @@ tasks: emscripten: - docker-compose up --build build-emscripten + - docker-compose down + + rpi3: + - docker-compose up --build build-rpi3 + - docker-compose down + + rpi3.release: + - docker-compose up --build build-rpi3-release + - docker-compose down + + rpi4: + - docker-compose up --build build-rpi4 + - docker-compose down + + rpi4.release: + - docker-compose up --build build-rpi4-release + - docker-compose down + + rpi4.test: + - docker-compose up --build test-rpi4 + - docker-compose down + + rpi4.vcpkg: + - docker-compose up --build build-rpi4-vcpkg + - docker-compose down + + rpi4.custom: + - docker-compose up --build build-rpi4-custom + - docker-compose down + + pico: + - docker-compose up --build build-pico - docker-compose down \ No newline at end of file diff --git a/tests/pico/.dockerignore b/tests/pico/.dockerignore new file mode 100644 index 00000000..98f8675f --- /dev/null +++ b/tests/pico/.dockerignore @@ -0,0 +1,8 @@ +build/ +.idea +.vscode +_deps +cmake-* +build +.DS_Store +*.pdf \ No newline at end of file diff --git a/tests/pico/.gitignore b/tests/pico/.gitignore new file mode 100644 index 00000000..9a4a7f5d --- /dev/null +++ b/tests/pico/.gitignore @@ -0,0 +1,7 @@ +.idea +.vscode +_deps +cmake-* +build +.DS_Store +*.pdf \ No newline at end of file diff --git a/tests/pico/CMakeLists.txt b/tests/pico/CMakeLists.txt new file mode 100644 index 00000000..71288af6 --- /dev/null +++ b/tests/pico/CMakeLists.txt @@ -0,0 +1,119 @@ +cmake_minimum_required(VERSION 3.13) + +# set a default CXX standard used by the external tools like clang-tidy, cppcheck, etc. +# You can later set fine-grained standards for each target using `target_compile_features` +#set(CMAKE_CXX_STANDARD 20) +#set(CMAKE_C_STANDARD 99) + +# initialize pico-sdk from GIT +# (note this can come from environment, CMake cache etc) +#set(PICO_SDK_FETCH_FROM_GIT on) + +# Pull in SDK (must be before project) +include(pico_sdk_import.cmake) + + +### Add project_options +# include(FetchContent) +# FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/heads/main.zip) +# FetchContent_MakeAvailable(_project_options) +# include(${_project_options_SOURCE_DIR}/Index.cmake) +include(../../src/Index.cmake) + + +#include(example_auto_set_url.cmake) +# Set the project name to your project name, my project isn't very descriptive +project( + pico + VERSION 0.1.0 + LANGUAGES C CXX ASM) + +# initialize the Raspberry Pi Pico SDK +pico_sdk_init() + +set(ENABLE_CLANG_TIDY OFF) +set(ENABLE_CPPCHECK OFF) +set(ENABLE_SANITIZER_ADDRESS OFF) +set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR OFF) +set(ENABLE_COVERAGE OFF) +set(ENABLE_INCLUDE_WHAT_YOU_USE OFF) + +option(ENABLE_CHECKING "Enable Static analyzer" OFF) +option(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE "Enable Static analyzer for include-what-you-use" OFF) +if(ENABLE_CHECKING) + set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() +if(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE) + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() + +#option(ENABLE_TESTING "Enable the tests" OFF) +option(DISABLE_SANITIZER "Disable Sanitizer" OFF) +if(ENABLE_TESTING) + if(NOT DEFINED OPT_ENABLE_COVERAGE) + set(ENABLE_COVERAGE "ENABLE_COVERAGE") + endif() + + if(NOT DISABLE_SANITIZER) + if(NOT + "${CMAKE_SYSTEM_NAME}" + STREQUAL + "Windows") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR") + else() + # or it is MSVC and has run vcvarsall + string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir) + if(MSVC AND "${index_of_vs_install_dir}" STREQUAL "-1") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + endif() + endif() + endif() +endif() + +project_options( + ENABLE_CACHE + ${ENABLE_CPPCHECK} + ${ENABLE_CLANG_TIDY} + ${ENABLE_INCLUDE_WHAT_YOU_USE} + ENABLE_VS_ANALYSIS + ${ENABLE_COVERAGE} + ${ENABLE_SANITIZER_ADDRESS} + ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} + #DISABLE_EXCEPTIONS + #DISABLE_RTTI + # Note: PCH is disabled by default in developer mode because these headers become globally included and they can mask other errors + PCH_HEADERS + # This is a list of headers to pre-compile, here are some common ones + + + + + + + + CPPCHECK_OPTIONS + --enable=style,performance,warning,portability + --inline-suppr + # We cannot act on a bug/missing feature of cppcheck + --suppress=cppcheckError + --suppress=internalAstError + # if a file does not have an internalAstError, we get an unmatchedSuppression error + --suppress=unmatchedSuppression + --suppress=passedByValue + --suppress=syntaxError + --inconclusive) + +add_executable(hello_world + hello_world.c +) + +# Add pico_stdlib library which aggregates commonly used features +target_link_system_libraries(hello_world PRIVATE pico_stdlib) + +# create map/bin/hex/uf2 file in addition to ELF. +pico_add_extra_outputs(hello_world) + +target_link_libraries(hello_world PRIVATE project_options project_warnings) \ No newline at end of file diff --git a/tests/pico/LICENSE.TXT b/tests/pico/LICENSE.TXT new file mode 100644 index 00000000..e8a64f19 --- /dev/null +++ b/tests/pico/LICENSE.TXT @@ -0,0 +1,21 @@ +Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following + disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/tests/pico/Taskfile.yml b/tests/pico/Taskfile.yml new file mode 100644 index 00000000..7c68737f --- /dev/null +++ b/tests/pico/Taskfile.yml @@ -0,0 +1,10 @@ +# https://taskfile.dev/#6/installation +version: 3 + +tasks: + build: + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Release + + lint: + - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/pico/hello_world.c b/tests/pico/hello_world.c new file mode 100644 index 00000000..42fca187 --- /dev/null +++ b/tests/pico/hello_world.c @@ -0,0 +1,8 @@ +#include +#include "pico/stdlib.h" + +int main() { + setup_default_uart(); + printf("Hello, world!\n"); + return 0; +} \ No newline at end of file diff --git a/tests/pico/pico_sdk_import.cmake b/tests/pico/pico_sdk_import.cmake new file mode 100644 index 00000000..0ba75584 --- /dev/null +++ b/tests/pico/pico_sdk_import.cmake @@ -0,0 +1,73 @@ +# This is a copy of /external/pico_sdk_import.cmake + +# This can be dropped into an external project to help locate this SDK +# It should be include()ed prior to project() + +if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) + set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) + message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") +endif () + +if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) + set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) + message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") +endif () + +if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) + set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) + message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") +endif () + +set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") +set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") +set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") + +if (NOT PICO_SDK_PATH) + if (PICO_SDK_FETCH_FROM_GIT) + include(FetchContent) + set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) + if (PICO_SDK_FETCH_FROM_GIT_PATH) + get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") + endif () + # GIT_SUBMODULES_RECURSE was added in 3.17 + if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") + FetchContent_Declare( + pico_sdk + GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk + GIT_TAG master + GIT_SUBMODULES_RECURSE FALSE + ) + else () + FetchContent_Declare( + pico_sdk + GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk + GIT_TAG master + ) + endif () + + if (NOT pico_sdk) + message("Downloading Raspberry Pi Pico SDK") + FetchContent_Populate(pico_sdk) + set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) + endif () + set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) + else () + message(FATAL_ERROR + "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." + ) + endif () +endif () + +get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") +if (NOT EXISTS ${PICO_SDK_PATH}) + message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") +endif () + +set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) +if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) + message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") +endif () + +set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) + +include(${PICO_SDK_INIT_CMAKE_FILE}) \ No newline at end of file diff --git a/tests/pico/vcpkg.json b/tests/pico/vcpkg.json new file mode 100644 index 00000000..5aa0e59b --- /dev/null +++ b/tests/pico/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "example", + "version-string": "0.1.0", + "dependencies": [ + "fmt", + "ms-gsl" + ] +} diff --git a/tests/rpi3/.dockerignore b/tests/rpi3/.dockerignore new file mode 100644 index 00000000..d1638636 --- /dev/null +++ b/tests/rpi3/.dockerignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/tests/rpi3/CMakeLists.txt b/tests/rpi3/CMakeLists.txt new file mode 100644 index 00000000..fd58bcb7 --- /dev/null +++ b/tests/rpi3/CMakeLists.txt @@ -0,0 +1,120 @@ +cmake_minimum_required(VERSION 3.16...3.21) + +# set a default CXX standard used by the external tools like clang-tidy, cppcheck, etc. +# You can later set fine-grained standards for each target using `target_compile_features` +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_C_STANDARD 99) + +### Add project_options +# include(FetchContent) +# FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/heads/main.zip) +# FetchContent_MakeAvailable(_project_options) +# include(${_project_options_SOURCE_DIR}/Index.cmake) +include(../../src/Index.cmake) + +# opt-in cross-compiling +option(ENABLE_CROSS_COMPILING "Detect cross compiler and setup toolchain" OFF) +if(ENABLE_CROSS_COMPILING) + enable_cross_compiler() +endif() + +# Set the project name to your project name, my project isn't very descriptive +project( + example + VERSION 0.1.0 + LANGUAGES C CXX ASM) + +set(ENABLE_CLANG_TIDY OFF) +set(ENABLE_CPPCHECK OFF) +set(ENABLE_SANITIZER_ADDRESS OFF) +set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR OFF) +set(ENABLE_COVERAGE OFF) +set(ENABLE_INCLUDE_WHAT_YOU_USE OFF) + +option(ENABLE_CHECKING "Enable Static analyzer" OFF) +option(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE "Enable Static analyzer for include-what-you-use" OFF) +if(ENABLE_CHECKING) + set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() +if(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE) + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() + +#option(ENABLE_TESTING "Enable the tests" OFF) +option(DISABLE_SANITIZER "Disable Sanitizer" OFF) +if(ENABLE_TESTING) + if(NOT DEFINED OPT_ENABLE_COVERAGE) + set(ENABLE_COVERAGE "ENABLE_COVERAGE") + endif() + + if(NOT DISABLE_SANITIZER) + if(NOT + "${CMAKE_SYSTEM_NAME}" + STREQUAL + "Windows") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR") + else() + # or it is MSVC and has run vcvarsall + string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir) + if(MSVC AND "${index_of_vs_install_dir}" STREQUAL "-1") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + endif() + endif() + endif() +endif() + +project_options( + ENABLE_CACHE + ${ENABLE_CPPCHECK} + ${ENABLE_CLANG_TIDY} + ${ENABLE_INCLUDE_WHAT_YOU_USE} + ENABLE_VS_ANALYSIS + ${ENABLE_COVERAGE} + ${ENABLE_SANITIZER_ADDRESS} + ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} + DISABLE_EXCEPTIONS + DISABLE_RTTI + # Note: PCH is disabled by default in developer mode because these headers become globally included and they can mask other errors + PCH_HEADERS + # This is a list of headers to pre-compile, here are some common ones + + + + + + + + CPPCHECK_OPTIONS + --enable=style,performance,warning,portability + --inline-suppr + # We cannot act on a bug/missing feature of cppcheck + --suppress=cppcheckError + --suppress=internalAstError + # if a file does not have an internalAstError, we get an unmatchedSuppression error + --suppress=unmatchedSuppression + --suppress=passedByValue + --suppress=syntaxError + --inconclusive) + +#add_executable(example) +#target_sources(example PRIVATE main.cpp) +#target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +#target_link_libraries(example PRIVATE project_options project_warnings) +#target_link_options(example PRIVATE -Wl,--start-group -lgcc -lc -lstdc++ -lm -lrdimon -Wl,--end-group) +#FIXME: linking with c++ (libs) ... /libstdc++.a(cxx11-ios_failure.o): in function `(anonymous namespace)::__io_category_instance()': + +add_executable(example_c) +target_sources(example_c PRIVATE main.c) +target_include_directories(example_c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(example_c PRIVATE project_options project_warnings) + +if(ENABLE_CROSS_COMPILING) + # fix: ...arm-none-eabi/lib/libg.a(lib_a-exit.o): in function `exit': + target_link_options(example_c PRIVATE -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group) + + # custom raspberry pi 3 options + target_compile_options(project_options INTERFACE -march=armv8-a -mfpu=neon-fp-armv8 -mthumb) +endif() \ No newline at end of file diff --git a/tests/rpi3/Taskfile.yml b/tests/rpi3/Taskfile.yml new file mode 100644 index 00000000..66e18a40 --- /dev/null +++ b/tests/rpi3/Taskfile.yml @@ -0,0 +1,26 @@ +# https://taskfile.dev/#6/installation +version: 3 + +tasks: + build: + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Debug + + build.release: + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Release + + build.cross: + cmds: + - task: build + vars: + CMAKE_ARGS: -DENABLE_CHECKING:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "arm-none-eabi-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "arm-none-eabi-g++"}} -DDEFAULT_TRIPLET=arm-linux + + build.cross.release: + cmds: + - task: build.release + vars: + CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "arm-none-eabi-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "arm-none-eabi-g++"}} -DDEFAULT_TRIPLET=arm-linux + + lint: + - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/rpi3/main.c b/tests/rpi3/main.c new file mode 100644 index 00000000..0cee53ff --- /dev/null +++ b/tests/rpi3/main.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello World\n"); + return 0; +} \ No newline at end of file diff --git a/tests/rpi3/main.cpp b/tests/rpi3/main.cpp new file mode 100644 index 00000000..b94615d2 --- /dev/null +++ b/tests/rpi3/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello World!"; + return 0; +} \ No newline at end of file diff --git a/tests/rpi3/vcpkg.json b/tests/rpi3/vcpkg.json new file mode 100644 index 00000000..5aa0e59b --- /dev/null +++ b/tests/rpi3/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "example", + "version-string": "0.1.0", + "dependencies": [ + "fmt", + "ms-gsl" + ] +} diff --git a/tests/rpi4-vcpkg/.dockerignore b/tests/rpi4-vcpkg/.dockerignore new file mode 100644 index 00000000..d1638636 --- /dev/null +++ b/tests/rpi4-vcpkg/.dockerignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/tests/rpi4-vcpkg/CMakeLists.txt b/tests/rpi4-vcpkg/CMakeLists.txt new file mode 100644 index 00000000..4e37cf94 --- /dev/null +++ b/tests/rpi4-vcpkg/CMakeLists.txt @@ -0,0 +1,121 @@ +cmake_minimum_required(VERSION 3.16...3.21) + +# set a default CXX standard used by the external tools like clang-tidy, cppcheck, etc. +# You can later set fine-grained standards for each target using `target_compile_features` +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_C_STANDARD 99) + +### Add project_options +# include(FetchContent) +# FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/heads/main.zip) +# FetchContent_MakeAvailable(_project_options) +# include(${_project_options_SOURCE_DIR}/Index.cmake) +include(../../src/Index.cmake) + +# opt-in cross-compiling +option(ENABLE_CROSS_COMPILING "Detect cross compiler and setup toolchain" OFF) +if(ENABLE_CROSS_COMPILING) + enable_cross_compiler() +endif() +run_vcpkg() + +# Set the project name to your project name, my project isn't very descriptive +project( + example + VERSION 0.1.0 + LANGUAGES C CXX ASM) + +set(ENABLE_CLANG_TIDY OFF) +set(ENABLE_CPPCHECK OFF) +set(ENABLE_SANITIZER_ADDRESS OFF) +set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR OFF) +set(ENABLE_COVERAGE OFF) +set(ENABLE_INCLUDE_WHAT_YOU_USE OFF) + +option(ENABLE_CHECKING "Enable Static analyzer" OFF) +option(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE "Enable Static analyzer for include-what-you-use" OFF) +if(ENABLE_CHECKING) + set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() +if(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE) + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() + +#option(ENABLE_TESTING "Enable the tests" OFF) +option(DISABLE_SANITIZER "Disable Sanitizer" OFF) +if(ENABLE_TESTING) + if(NOT DEFINED OPT_ENABLE_COVERAGE) + set(ENABLE_COVERAGE "ENABLE_COVERAGE") + endif() + + if(NOT DISABLE_SANITIZER) + if(NOT + "${CMAKE_SYSTEM_NAME}" + STREQUAL + "Windows") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR") + else() + # or it is MSVC and has run vcvarsall + string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir) + if(MSVC AND "${index_of_vs_install_dir}" STREQUAL "-1") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + endif() + endif() + endif() +endif() + +project_options( + ENABLE_CACHE + ${ENABLE_CPPCHECK} + ${ENABLE_CLANG_TIDY} + ${ENABLE_INCLUDE_WHAT_YOU_USE} + ENABLE_VS_ANALYSIS + ${ENABLE_COVERAGE} + ${ENABLE_SANITIZER_ADDRESS} + ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} + # DISABLE_EXCEPTIONS + # DISABLE_RTTI + # Note: PCH is disabled by default in developer mode because these headers become globally included and they can mask other errors + PCH_HEADERS + # This is a list of headers to pre-compile, here are some common ones + + + + + + + + CPPCHECK_OPTIONS + --enable=style,performance,warning,portability + --inline-suppr + # We cannot act on a bug/missing feature of cppcheck + --suppress=cppcheckError + --suppress=internalAstError + # if a file does not have an internalAstError, we get an unmatchedSuppression error + --suppress=unmatchedSuppression + --suppress=passedByValue + --suppress=syntaxError + --inconclusive) + +find_package(Microsoft.GSL CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) + +add_executable(example) +target_sources(example PRIVATE main.cpp) +target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(example PRIVATE project_options project_warnings) +target_link_system_libraries( + example + PRIVATE + Microsoft.GSL::GSL + fmt::fmt-header-only) + +if(ENABLE_CROSS_COMPILING) + # custom raspberry pi 4 options + #target_compile_definitions(project_options INTERFACE -D__ARM_NEON) + target_compile_options(project_options INTERFACE -mcpu=cortex-a72) + #target_compile_options(project_options INTERFACE -march=armv8-a+fp+simd) # use mcpu ? +endif() \ No newline at end of file diff --git a/tests/rpi4-vcpkg/Taskfile.yml b/tests/rpi4-vcpkg/Taskfile.yml new file mode 100644 index 00000000..897106b7 --- /dev/null +++ b/tests/rpi4-vcpkg/Taskfile.yml @@ -0,0 +1,16 @@ +# https://taskfile.dev/#6/installation +version: 3 + +tasks: + build: + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Debug + + build.cross: + cmds: + - task: build + vars: + CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux + + lint: + - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/rpi4-vcpkg/cmake/my-toolchain.cmake b/tests/rpi4-vcpkg/cmake/my-toolchain.cmake new file mode 100644 index 00000000..fb865c50 --- /dev/null +++ b/tests/rpi4-vcpkg/cmake/my-toolchain.cmake @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/tests/rpi4-vcpkg/main.cpp b/tests/rpi4-vcpkg/main.cpp new file mode 100644 index 00000000..115ff095 --- /dev/null +++ b/tests/rpi4-vcpkg/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + fmt::print("Hello World!"); + return 0; +} \ No newline at end of file diff --git a/tests/rpi4-vcpkg/vcpkg.json b/tests/rpi4-vcpkg/vcpkg.json new file mode 100644 index 00000000..5aa0e59b --- /dev/null +++ b/tests/rpi4-vcpkg/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "example", + "version-string": "0.1.0", + "dependencies": [ + "fmt", + "ms-gsl" + ] +} diff --git a/tests/rpi4/.dockerignore b/tests/rpi4/.dockerignore new file mode 100644 index 00000000..d1638636 --- /dev/null +++ b/tests/rpi4/.dockerignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/tests/rpi4/CMakeLists.txt b/tests/rpi4/CMakeLists.txt new file mode 100644 index 00000000..91716760 --- /dev/null +++ b/tests/rpi4/CMakeLists.txt @@ -0,0 +1,112 @@ +cmake_minimum_required(VERSION 3.16...3.21) + +# set a default CXX standard used by the external tools like clang-tidy, cppcheck, etc. +# You can later set fine-grained standards for each target using `target_compile_features` +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_C_STANDARD 99) + +### Add project_options +# include(FetchContent) +# FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/heads/main.zip) +# FetchContent_MakeAvailable(_project_options) +# include(${_project_options_SOURCE_DIR}/Index.cmake) +include(../../src/Index.cmake) + +# opt-in cross-compiling +option(ENABLE_CROSS_COMPILING "Detect cross compiler and setup toolchain" OFF) +if(ENABLE_CROSS_COMPILING) + enable_cross_compiler() +endif() + +# Set the project name to your project name, my project isn't very descriptive +project( + example + VERSION 0.1.0 + LANGUAGES C CXX ASM) + +set(ENABLE_CLANG_TIDY OFF) +set(ENABLE_CPPCHECK OFF) +set(ENABLE_SANITIZER_ADDRESS OFF) +set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR OFF) +set(ENABLE_COVERAGE OFF) +set(ENABLE_INCLUDE_WHAT_YOU_USE OFF) + +option(ENABLE_CHECKING "Enable Static analyzer" OFF) +option(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE "Enable Static analyzer for include-what-you-use" OFF) +if(ENABLE_CHECKING) + set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() +if(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE) + set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") +endif() + +#option(ENABLE_TESTING "Enable the tests" OFF) +option(DISABLE_SANITIZER "Disable Sanitizer" OFF) +if(ENABLE_TESTING) + if(NOT DEFINED OPT_ENABLE_COVERAGE) + set(ENABLE_COVERAGE "ENABLE_COVERAGE") + endif() + + if(NOT DISABLE_SANITIZER) + if(NOT + "${CMAKE_SYSTEM_NAME}" + STREQUAL + "Windows") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR") + else() + # or it is MSVC and has run vcvarsall + string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir) + if(MSVC AND "${index_of_vs_install_dir}" STREQUAL "-1") + set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") + endif() + endif() + endif() +endif() + +project_options( + ENABLE_CACHE + ${ENABLE_CPPCHECK} + ${ENABLE_CLANG_TIDY} + ${ENABLE_INCLUDE_WHAT_YOU_USE} + ENABLE_VS_ANALYSIS + ${ENABLE_COVERAGE} + ${ENABLE_SANITIZER_ADDRESS} + ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} + DISABLE_EXCEPTIONS + DISABLE_RTTI + # Note: PCH is disabled by default in developer mode because these headers become globally included and they can mask other errors + PCH_HEADERS + # This is a list of headers to pre-compile, here are some common ones + + + + + + + + CPPCHECK_OPTIONS + --enable=style,performance,warning,portability + --inline-suppr + # We cannot act on a bug/missing feature of cppcheck + --suppress=cppcheckError + --suppress=internalAstError + # if a file does not have an internalAstError, we get an unmatchedSuppression error + --suppress=unmatchedSuppression + --suppress=passedByValue + --suppress=syntaxError + --inconclusive) + +add_executable(example) +target_sources(example PRIVATE main.cpp) +target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(example PRIVATE project_options project_warnings) + +if(ENABLE_CROSS_COMPILING) + # custom raspberry pi 4 options + #target_compile_definitions(project_options INTERFACE -D__ARM_NEON) + target_compile_options(project_options INTERFACE -mcpu=cortex-a72) + #target_compile_options(project_options INTERFACE "-march=armv8-a+fp+simd") # use mcpu ? +endif() \ No newline at end of file diff --git a/tests/rpi4/Taskfile.yml b/tests/rpi4/Taskfile.yml new file mode 100644 index 00000000..923bcc37 --- /dev/null +++ b/tests/rpi4/Taskfile.yml @@ -0,0 +1,32 @@ +# https://taskfile.dev/#6/installation +version: 3 + +tasks: + build: + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Debug + + build.release: + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Release + + build.cross: + cmds: + - task: build + vars: + CMAKE_ARGS: -DENABLE_CHECKING:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux + + build.cross.release: + cmds: + - task: build.release + vars: + CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux + + build.cross.custom-toolchain: + cmds: + - task: build.release + vars: + CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux -DCMAKE_TOOLCHAIN_FILE=./cmake/my-toolchain.cmake + + lint: + - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/rpi4/cmake/my-toolchain.cmake b/tests/rpi4/cmake/my-toolchain.cmake new file mode 100644 index 00000000..fb865c50 --- /dev/null +++ b/tests/rpi4/cmake/my-toolchain.cmake @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) + +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/tests/rpi4/main.cpp b/tests/rpi4/main.cpp new file mode 100644 index 00000000..b94615d2 --- /dev/null +++ b/tests/rpi4/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello World!"; + return 0; +} \ No newline at end of file diff --git a/tests/rpi4/vcpkg.json b/tests/rpi4/vcpkg.json new file mode 100644 index 00000000..5aa0e59b --- /dev/null +++ b/tests/rpi4/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "example", + "version-string": "0.1.0", + "dependencies": [ + "fmt", + "ms-gsl" + ] +} From d58152d88f9251be878cbe923fcaa80512f09fef Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 11 Jan 2023 10:45:37 +0100 Subject: [PATCH 03/15] feat: add CLANG_TIDY_EXTRA_ARGUMENTS in enable_clang_tidy --- src/Index.cmake | 3 ++- src/StaticAnalyzers.cmake | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Index.cmake b/src/Index.cmake index 531ccd5d..75529101 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -107,6 +107,7 @@ macro(project_options) GCC_WARNINGS CUDA_WARNINGS CPPCHECK_OPTIONS + CLANG_TIDY_EXTRA_ARGUMENTS PCH_HEADERS CONAN_OPTIONS) cmake_parse_arguments( @@ -219,7 +220,7 @@ macro(project_options) endif() if(${ProjectOptions_ENABLE_CLANG_TIDY}) - enable_clang_tidy() + enable_clang_tidy("${ProjectOptions_CLANG_TIDY_EXTRA_ARGUMENTS}") endif() if(${ProjectOptions_ENABLE_VS_ANALYSIS}) diff --git a/src/StaticAnalyzers.cmake b/src/StaticAnalyzers.cmake index b302f027..f1703467 100644 --- a/src/StaticAnalyzers.cmake +++ b/src/StaticAnalyzers.cmake @@ -56,7 +56,7 @@ macro(enable_cppcheck CPPCHECK_OPTIONS) endmacro() # Enable static analysis with clang-tidy -macro(enable_clang_tidy) +macro(enable_clang_tidy CLANG_TIDY_EXTRA_ARGUMENTS) find_program(CLANGTIDY clang-tidy) if(CLANGTIDY) @@ -114,6 +114,9 @@ macro(enable_clang_tidy) endif() endif() + set(CMAKE_C_CLANG_TIDY ${CMAKE_C_CLANG_TIDY} ${CLANG_TIDY_EXTRA_ARGUMENTS}) + set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY} ${CLANG_TIDY_EXTRA_ARGUMENTS}) + else() message(${WARNING_MESSAGE} "clang-tidy requested but executable not found") endif() From d57af360af904336ef2191f9d8e8c8719ab524ec Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 11 Jan 2023 10:51:25 +0100 Subject: [PATCH 04/15] wip: add target argument in clang-tidy --- Taskfile.yml | 5 ++++- src/toolchains/aarch64.toolchain.cmake | 8 ++++++++ src/toolchains/arm.toolchain.cmake | 10 +++++++++- src/toolchains/arm64.toolchain.cmake | 10 +++++++++- tests/rpi3/CMakeLists.txt | 7 +++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index dc241b02..2f85760d 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -47,7 +47,10 @@ tasks: - task: install:lint - task: minimal:lint - task: emscripten:lint - - task: rpi:lint + - task: rpi3:lint + - task: rpi4:lint + - task: rpi4-vcpkg:lint + - task: pico:lint - npx -y cspell lint --no-progress --show-suggestions clean: diff --git a/src/toolchains/aarch64.toolchain.cmake b/src/toolchains/aarch64.toolchain.cmake index 9035cb5d..73d00afc 100644 --- a/src/toolchains/aarch64.toolchain.cmake +++ b/src/toolchains/aarch64.toolchain.cmake @@ -28,3 +28,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# The target triple needs to match the prefix of the binutils exactly +# (e.g. CMake looks for arm-none-eabi-ar) +#set(CLANG_TARGET_TRIPLE ${CROSS_TRIPLET}) +#set(GCC_ARM_TOOLCHAIN_PREFIX ${CROSS_TRIPLET}) +#set(CMAKE_C_COMPILER_TARGET ${CROSS_TRIPLET}) +#set(CMAKE_CXX_COMPILER_TARGET ${CROSS_TRIPLET}) +#set(CMAKE_ASM_COMPILER_TARGET ${CROSS_TRIPLET}) diff --git a/src/toolchains/arm.toolchain.cmake b/src/toolchains/arm.toolchain.cmake index a2238f0b..99a426d7 100644 --- a/src/toolchains/arm.toolchain.cmake +++ b/src/toolchains/arm.toolchain.cmake @@ -27,4 +27,12 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) \ No newline at end of file +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# The target triple needs to match the prefix of the binutils exactly +# (e.g. CMake looks for arm-none-eabi-ar) +#set(CLANG_TARGET_TRIPLE ${CROSS_TRIPLET}) +#set(GCC_ARM_TOOLCHAIN_PREFIX ${CROSS_TRIPLET}) +#set(CMAKE_C_COMPILER_TARGET ${CROSS_TRIPLET}) +#set(CMAKE_CXX_COMPILER_TARGET ${CROSS_TRIPLET}) +#set(CMAKE_ASM_COMPILER_TARGET ${CROSS_TRIPLET}) diff --git a/src/toolchains/arm64.toolchain.cmake b/src/toolchains/arm64.toolchain.cmake index 396366d7..8caeb262 100644 --- a/src/toolchains/arm64.toolchain.cmake +++ b/src/toolchains/arm64.toolchain.cmake @@ -27,4 +27,12 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) \ No newline at end of file +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# The target triple needs to match the prefix of the binutils exactly +# (e.g. CMake looks for arm-none-eabi-ar) +#set(CLANG_TARGET_TRIPLE ${CROSS_TRIPLET}) +#set(GCC_ARM_TOOLCHAIN_PREFIX ${CROSS_TRIPLET}) +#set(CMAKE_C_COMPILER_TARGET ${CROSS_TRIPLET}) +#set(CMAKE_CXX_COMPILER_TARGET ${CROSS_TRIPLET}) +#set(CMAKE_ASM_COMPILER_TARGET ${CROSS_TRIPLET}) diff --git a/tests/rpi3/CMakeLists.txt b/tests/rpi3/CMakeLists.txt index fd58bcb7..7c31a1d3 100644 --- a/tests/rpi3/CMakeLists.txt +++ b/tests/rpi3/CMakeLists.txt @@ -66,6 +66,9 @@ if(ENABLE_TESTING) endif() endif() +if(ENABLE_CROSS_COMPILING) + set(CLANG_TIDY_EXTRA_ARGUMENTS --extra-arg=--target=${CROSS_TRIPLET}) +endif() project_options( ENABLE_CACHE ${ENABLE_CPPCHECK} @@ -87,6 +90,10 @@ project_options( + + CLANG_TIDY_EXTRA_ARGUMENTS + ${CLANG_TIDY_EXTRA_ARGUMENTS} + CPPCHECK_OPTIONS --enable=style,performance,warning,portability --inline-suppr From 2c6b50af19d02886dc80f963f655dc63885946cb Mon Sep 17 00:00:00 2001 From: abeimler Date: Mon, 16 Jan 2023 21:37:44 +0100 Subject: [PATCH 05/15] fix: clean up tasks * remove pico --- Taskfile.yml | 3 - docker-compose.yml | 15 ++-- docker/Dockerfile.aarch64 | 6 +- docker/Dockerfile.arm | 4 +- tests/pico/.dockerignore | 8 --- tests/pico/.gitignore | 7 -- tests/pico/CMakeLists.txt | 119 ------------------------------- tests/pico/LICENSE.TXT | 21 ------ tests/pico/Taskfile.yml | 10 --- tests/pico/hello_world.c | 8 --- tests/pico/pico_sdk_import.cmake | 73 ------------------- tests/pico/vcpkg.json | 8 --- tests/rpi3/Taskfile.yml | 15 ++-- tests/rpi3/vcpkg.json | 8 --- tests/rpi4-vcpkg/Taskfile.yml | 4 +- tests/rpi4/Taskfile.yml | 15 ++-- tests/rpi4/vcpkg.json | 8 --- 17 files changed, 24 insertions(+), 308 deletions(-) delete mode 100644 tests/pico/.dockerignore delete mode 100644 tests/pico/.gitignore delete mode 100644 tests/pico/CMakeLists.txt delete mode 100644 tests/pico/LICENSE.TXT delete mode 100644 tests/pico/Taskfile.yml delete mode 100644 tests/pico/hello_world.c delete mode 100644 tests/pico/pico_sdk_import.cmake delete mode 100644 tests/pico/vcpkg.json delete mode 100644 tests/rpi3/vcpkg.json delete mode 100644 tests/rpi4/vcpkg.json diff --git a/Taskfile.yml b/Taskfile.yml index 2f85760d..5106dc23 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -47,10 +47,7 @@ tasks: - task: install:lint - task: minimal:lint - task: emscripten:lint - - task: rpi3:lint - - task: rpi4:lint - task: rpi4-vcpkg:lint - - task: pico:lint - npx -y cspell lint --no-progress --show-suggestions clean: diff --git a/docker-compose.yml b/docker-compose.yml index 27f88a16..6b43e85c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -84,21 +84,21 @@ services: context: . dockerfile: ./docker/Dockerfile.arm target: build - build-rpi3-release: + build-rpi3-debug: build: context: . dockerfile: ./docker/Dockerfile.arm - target: build-release + target: build-debug build-rpi4: build: context: . dockerfile: ./docker/Dockerfile.aarch64 target: build - build-rpi4-release: + build-rpi4-debug: build: context: . dockerfile: ./docker/Dockerfile.aarch64 - target: build-release + target: build-debug test-rpi4: build: context: . @@ -113,9 +113,4 @@ services: build: context: . dockerfile: ./docker/Dockerfile.aarch64 - target: build-custom - build-pico: - build: - context: . - dockerfile: ./docker/Dockerfile.pico - target: build \ No newline at end of file + target: build-custom \ No newline at end of file diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 index 46f7bcec..ee16e82a 100644 --- a/docker/Dockerfile.aarch64 +++ b/docker/Dockerfile.aarch64 @@ -26,10 +26,10 @@ COPY . /home/project_options WORKDIR /home/project_options CMD ["/bin/bash", "-c", "task rpi4:build.cross"] -FROM setup AS build-release +FROM setup AS build-debug COPY . /home/project_options WORKDIR /home/project_options -CMD ["/bin/bash", "-c", "task rpi4:build.cross.release"] +CMD ["/bin/bash", "-c", "task rpi4:build.cross.debug"] FROM setup AS build-vcpkg COPY . /home/project_options @@ -49,4 +49,4 @@ RUN apt-get update && apt-get install -y \ COPY . /home/project_options WORKDIR /home/project_options ENV QEMU_LD_PREFIX /usr/aarch64-linux-gnu -CMD ["/bin/bash", "-c", "task rpi4:build.cross.release && qemu-aarch64 /home/project_options/tests/rpi4/build/Release/example"] +CMD ["/bin/bash", "-c", "task rpi4:build.cross && qemu-aarch64 /home/project_options/tests/rpi4/build/Release/example"] diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm index 2e581801..273e654a 100644 --- a/docker/Dockerfile.arm +++ b/docker/Dockerfile.arm @@ -27,7 +27,7 @@ WORKDIR /home/project_options CMD ["/bin/bash", "-c", "task rpi3:build.cross"] -FROM setup AS build-release +FROM setup AS build-debug COPY . /home/project_options WORKDIR /home/project_options -CMD ["/bin/bash", "-c", "task rpi3:build.cross.release"] \ No newline at end of file +CMD ["/bin/bash", "-c", "task rpi3:build.cross.debug"] \ No newline at end of file diff --git a/tests/pico/.dockerignore b/tests/pico/.dockerignore deleted file mode 100644 index 98f8675f..00000000 --- a/tests/pico/.dockerignore +++ /dev/null @@ -1,8 +0,0 @@ -build/ -.idea -.vscode -_deps -cmake-* -build -.DS_Store -*.pdf \ No newline at end of file diff --git a/tests/pico/.gitignore b/tests/pico/.gitignore deleted file mode 100644 index 9a4a7f5d..00000000 --- a/tests/pico/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.idea -.vscode -_deps -cmake-* -build -.DS_Store -*.pdf \ No newline at end of file diff --git a/tests/pico/CMakeLists.txt b/tests/pico/CMakeLists.txt deleted file mode 100644 index 71288af6..00000000 --- a/tests/pico/CMakeLists.txt +++ /dev/null @@ -1,119 +0,0 @@ -cmake_minimum_required(VERSION 3.13) - -# set a default CXX standard used by the external tools like clang-tidy, cppcheck, etc. -# You can later set fine-grained standards for each target using `target_compile_features` -#set(CMAKE_CXX_STANDARD 20) -#set(CMAKE_C_STANDARD 99) - -# initialize pico-sdk from GIT -# (note this can come from environment, CMake cache etc) -#set(PICO_SDK_FETCH_FROM_GIT on) - -# Pull in SDK (must be before project) -include(pico_sdk_import.cmake) - - -### Add project_options -# include(FetchContent) -# FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/heads/main.zip) -# FetchContent_MakeAvailable(_project_options) -# include(${_project_options_SOURCE_DIR}/Index.cmake) -include(../../src/Index.cmake) - - -#include(example_auto_set_url.cmake) -# Set the project name to your project name, my project isn't very descriptive -project( - pico - VERSION 0.1.0 - LANGUAGES C CXX ASM) - -# initialize the Raspberry Pi Pico SDK -pico_sdk_init() - -set(ENABLE_CLANG_TIDY OFF) -set(ENABLE_CPPCHECK OFF) -set(ENABLE_SANITIZER_ADDRESS OFF) -set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR OFF) -set(ENABLE_COVERAGE OFF) -set(ENABLE_INCLUDE_WHAT_YOU_USE OFF) - -option(ENABLE_CHECKING "Enable Static analyzer" OFF) -option(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE "Enable Static analyzer for include-what-you-use" OFF) -if(ENABLE_CHECKING) - set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") - set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") - set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") -endif() -if(ENABLE_CHECKING_INCLUDE_WHAT_YOU_USE) - set(ENABLE_INCLUDE_WHAT_YOU_USE "ENABLE_INCLUDE_WHAT_YOU_USE") -endif() - -#option(ENABLE_TESTING "Enable the tests" OFF) -option(DISABLE_SANITIZER "Disable Sanitizer" OFF) -if(ENABLE_TESTING) - if(NOT DEFINED OPT_ENABLE_COVERAGE) - set(ENABLE_COVERAGE "ENABLE_COVERAGE") - endif() - - if(NOT DISABLE_SANITIZER) - if(NOT - "${CMAKE_SYSTEM_NAME}" - STREQUAL - "Windows") - set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") - set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR") - else() - # or it is MSVC and has run vcvarsall - string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir) - if(MSVC AND "${index_of_vs_install_dir}" STREQUAL "-1") - set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS") - endif() - endif() - endif() -endif() - -project_options( - ENABLE_CACHE - ${ENABLE_CPPCHECK} - ${ENABLE_CLANG_TIDY} - ${ENABLE_INCLUDE_WHAT_YOU_USE} - ENABLE_VS_ANALYSIS - ${ENABLE_COVERAGE} - ${ENABLE_SANITIZER_ADDRESS} - ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR} - #DISABLE_EXCEPTIONS - #DISABLE_RTTI - # Note: PCH is disabled by default in developer mode because these headers become globally included and they can mask other errors - PCH_HEADERS - # This is a list of headers to pre-compile, here are some common ones - - - - - - - - CPPCHECK_OPTIONS - --enable=style,performance,warning,portability - --inline-suppr - # We cannot act on a bug/missing feature of cppcheck - --suppress=cppcheckError - --suppress=internalAstError - # if a file does not have an internalAstError, we get an unmatchedSuppression error - --suppress=unmatchedSuppression - --suppress=passedByValue - --suppress=syntaxError - --inconclusive) - -add_executable(hello_world - hello_world.c -) - -# Add pico_stdlib library which aggregates commonly used features -target_link_system_libraries(hello_world PRIVATE pico_stdlib) - -# create map/bin/hex/uf2 file in addition to ELF. -pico_add_extra_outputs(hello_world) - -target_link_libraries(hello_world PRIVATE project_options project_warnings) \ No newline at end of file diff --git a/tests/pico/LICENSE.TXT b/tests/pico/LICENSE.TXT deleted file mode 100644 index e8a64f19..00000000 --- a/tests/pico/LICENSE.TXT +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following - disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/tests/pico/Taskfile.yml b/tests/pico/Taskfile.yml deleted file mode 100644 index 7c68737f..00000000 --- a/tests/pico/Taskfile.yml +++ /dev/null @@ -1,10 +0,0 @@ -# https://taskfile.dev/#6/installation -version: 3 - -tasks: - build: - - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} - - cmake --build ./build --config Release - - lint: - - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/pico/hello_world.c b/tests/pico/hello_world.c deleted file mode 100644 index 42fca187..00000000 --- a/tests/pico/hello_world.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "pico/stdlib.h" - -int main() { - setup_default_uart(); - printf("Hello, world!\n"); - return 0; -} \ No newline at end of file diff --git a/tests/pico/pico_sdk_import.cmake b/tests/pico/pico_sdk_import.cmake deleted file mode 100644 index 0ba75584..00000000 --- a/tests/pico/pico_sdk_import.cmake +++ /dev/null @@ -1,73 +0,0 @@ -# This is a copy of /external/pico_sdk_import.cmake - -# This can be dropped into an external project to help locate this SDK -# It should be include()ed prior to project() - -if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) - set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) - message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") -endif () - -if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) - set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) - message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") -endif () - -if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) - set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) - message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") -endif () - -set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") -set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") -set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") - -if (NOT PICO_SDK_PATH) - if (PICO_SDK_FETCH_FROM_GIT) - include(FetchContent) - set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) - if (PICO_SDK_FETCH_FROM_GIT_PATH) - get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") - endif () - # GIT_SUBMODULES_RECURSE was added in 3.17 - if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") - FetchContent_Declare( - pico_sdk - GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk - GIT_TAG master - GIT_SUBMODULES_RECURSE FALSE - ) - else () - FetchContent_Declare( - pico_sdk - GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk - GIT_TAG master - ) - endif () - - if (NOT pico_sdk) - message("Downloading Raspberry Pi Pico SDK") - FetchContent_Populate(pico_sdk) - set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) - endif () - set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) - else () - message(FATAL_ERROR - "SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git." - ) - endif () -endif () - -get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") -if (NOT EXISTS ${PICO_SDK_PATH}) - message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") -endif () - -set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) -if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) - message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK") -endif () - -set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE) - -include(${PICO_SDK_INIT_CMAKE_FILE}) \ No newline at end of file diff --git a/tests/pico/vcpkg.json b/tests/pico/vcpkg.json deleted file mode 100644 index 5aa0e59b..00000000 --- a/tests/pico/vcpkg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "example", - "version-string": "0.1.0", - "dependencies": [ - "fmt", - "ms-gsl" - ] -} diff --git a/tests/rpi3/Taskfile.yml b/tests/rpi3/Taskfile.yml index 66e18a40..8bdc0fd8 100644 --- a/tests/rpi3/Taskfile.yml +++ b/tests/rpi3/Taskfile.yml @@ -2,25 +2,22 @@ version: 3 tasks: - build: + build.debug: - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} - cmake --build ./build --config Debug - build.release: + build: - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} - cmake --build ./build --config Release - build.cross: + build.cross.debug: cmds: - - task: build + - task: build.debug vars: CMAKE_ARGS: -DENABLE_CHECKING:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "arm-none-eabi-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "arm-none-eabi-g++"}} -DDEFAULT_TRIPLET=arm-linux - build.cross.release: + build.cross: cmds: - - task: build.release + - task: build vars: CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "arm-none-eabi-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "arm-none-eabi-g++"}} -DDEFAULT_TRIPLET=arm-linux - - lint: - - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/rpi3/vcpkg.json b/tests/rpi3/vcpkg.json deleted file mode 100644 index 5aa0e59b..00000000 --- a/tests/rpi3/vcpkg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "example", - "version-string": "0.1.0", - "dependencies": [ - "fmt", - "ms-gsl" - ] -} diff --git a/tests/rpi4-vcpkg/Taskfile.yml b/tests/rpi4-vcpkg/Taskfile.yml index 897106b7..175de702 100644 --- a/tests/rpi4-vcpkg/Taskfile.yml +++ b/tests/rpi4-vcpkg/Taskfile.yml @@ -3,8 +3,8 @@ version: 3 tasks: build: - - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} - - cmake --build ./build --config Debug + - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} + - cmake --build ./build --config Release build.cross: cmds: diff --git a/tests/rpi4/Taskfile.yml b/tests/rpi4/Taskfile.yml index 923bcc37..3732c960 100644 --- a/tests/rpi4/Taskfile.yml +++ b/tests/rpi4/Taskfile.yml @@ -2,11 +2,11 @@ version: 3 tasks: - build: + build.debug: - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Debug -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} - cmake --build ./build --config Debug - build.release: + build: - cmake . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release -G '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' {{.CMAKE_ARGS}} - cmake --build ./build --config Release @@ -14,19 +14,16 @@ tasks: cmds: - task: build vars: - CMAKE_ARGS: -DENABLE_CHECKING:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux + CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux - build.cross.release: + build.cross.debug: cmds: - - task: build.release + - task: build.debug vars: - CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux + CMAKE_ARGS: -DENABLE_CHECKING:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux build.cross.custom-toolchain: cmds: - task: build.release vars: CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux -DCMAKE_TOOLCHAIN_FILE=./cmake/my-toolchain.cmake - - lint: - - ~/vcpkg/vcpkg format-manifest ./vcpkg.json \ No newline at end of file diff --git a/tests/rpi4/vcpkg.json b/tests/rpi4/vcpkg.json deleted file mode 100644 index 5aa0e59b..00000000 --- a/tests/rpi4/vcpkg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "example", - "version-string": "0.1.0", - "dependencies": [ - "fmt", - "ms-gsl" - ] -} From 27a009d9c590f40656c882dc6028ba81fb8a0b80 Mon Sep 17 00:00:00 2001 From: abeimler Date: Mon, 16 Jan 2023 21:38:28 +0100 Subject: [PATCH 06/15] feat: add cross ARM CI --- .github/workflows/ci.cross.arm.yml | 73 +++++++++++++++++++ .../{ci.mingw.yml => ci.cross.mingw.yml} | 4 +- .github/workflows/ci.emscripten.yml | 2 +- 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.cross.arm.yml rename .github/workflows/{ci.mingw.yml => ci.cross.mingw.yml} (90%) diff --git a/.github/workflows/ci.cross.arm.yml b/.github/workflows/ci.cross.arm.yml new file mode 100644 index 00000000..72eff3a6 --- /dev/null +++ b/.github/workflows/ci.cross.arm.yml @@ -0,0 +1,73 @@ +name: ci-cross-arm +on: + pull_request: + push: + branches: + - main + - master + +jobs: + Test: + if: "!contains(github.event.head_commit.message, '[ci skip]')" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + cmake: + - true + include: + - task: rpi4:build.cross + install-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu + target: aarch64-linux-gnu + - task: rpi4-vcpkg:build.cross + install-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu + target: aarch64-linux-gnu + - task: rpi4:build.cross.custom-toolchain + insstall-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu + target: aarch64-linux-gnu + - task: rpi3:build.cross + install-cross-compiler: gcc-arm-none-eabi binutils-arm-none-eabi + target: arm-none-eabi + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/vcpkg + ./build/vcpkg_installed + ${{ env.HOME }}/.cache/vcpkg/archives + ${{ env.XDG_CACHE_HOME }}/vcpkg/archives + ${{ env.LOCALAPPDATA }}\vcpkg\archives + ${{ env.APPDATA }}\vcpkg\archives + key: ${{ runner.os }}-cross-${{ matrix.target }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}-${{ matrix.cmake }} + restore-keys: | + ${{ runner.os }}-${{ env.BUILD_TYPE }}- + + - name: Setup Cpp + uses: aminya/setup-cpp@v1 + with: + cmake: ${{ matrix.cmake }} + ninja: true + vcpkg: true + conan: true + cppcheck: true + clangtidy: true + task: true + doxygen: true + powershell: true + + - name: Setup ARM (Cross) Compiler + uses: tecolicom/actions-use-apt-tools@v1 + with: + tools: ${{ matrix.install-cross-compiler }} + + - name: Build (Task) + run: | + task ${{ matrix.task }} + env: + CMAKE_GENERATOR: ${{ matrix.cmake_generator }} diff --git a/.github/workflows/ci.mingw.yml b/.github/workflows/ci.cross.mingw.yml similarity index 90% rename from .github/workflows/ci.mingw.yml rename to .github/workflows/ci.cross.mingw.yml index 846d2a89..d001371a 100644 --- a/.github/workflows/ci.mingw.yml +++ b/.github/workflows/ci.cross.mingw.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: - - ubuntu-20.04 + - ubuntu-22.04 cmake: - true platform: @@ -41,7 +41,7 @@ jobs: ${{ env.XDG_CACHE_HOME }}/vcpkg/archives ${{ env.LOCALAPPDATA }}\vcpkg\archives ${{ env.APPDATA }}\vcpkg\archives - key: ${{ runner.os }}-mingw-${{ matrix.platform }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}-${{ matrix.cmake }} + key: ${{ runner.os }}-cross-mingw-${{ matrix.platform }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}-${{ matrix.cmake }} restore-keys: | ${{ runner.os }}-${{ env.BUILD_TYPE }}- diff --git a/.github/workflows/ci.emscripten.yml b/.github/workflows/ci.emscripten.yml index 1ac9b7dd..bdae61a4 100644 --- a/.github/workflows/ci.emscripten.yml +++ b/.github/workflows/ci.emscripten.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: - - ubuntu-20.04 + - ubuntu-22.04 cmake: - true steps: From 19e6dd98e5ed17bc1b6615e41f0ce11b32b16eaa Mon Sep 17 00:00:00 2001 From: abeimler Date: Mon, 16 Jan 2023 21:53:06 +0100 Subject: [PATCH 07/15] fix: Taskfile --- Taskfile.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 5106dc23..10420d8e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -26,9 +26,6 @@ includes: rpi4-vcpkg: taskfile: ./tests/rpi4-vcpkg/Taskfile.yml dir: ./tests/rpi4-vcpkg - pico: - taskfile: ./tests/pico/Taskfile.yml - dir: ./tests/pico vars: CWD: From ff716a5ea0bfbbfdc28419ec5dfc24acd071c4e1 Mon Sep 17 00:00:00 2001 From: abeimler Date: Mon, 16 Jan 2023 22:16:00 +0100 Subject: [PATCH 08/15] fix: cleanup pico example --- docker/Dockerfile.pico | 37 ------------------------------------- docker/Taskfile.yml | 4 ---- 2 files changed, 41 deletions(-) delete mode 100644 docker/Dockerfile.pico diff --git a/docker/Dockerfile.pico b/docker/Dockerfile.pico deleted file mode 100644 index a140c263..00000000 --- a/docker/Dockerfile.pico +++ /dev/null @@ -1,37 +0,0 @@ -FROM ubuntu:22.04 AS base - -ARG setup_cpp_linux_version="0.24.1" - -# add setup_cpp https://github.com/aminya/setup-cpp -ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux -RUN chmod +x /setup_cpp_linux - - - -FROM base AS setup - -# install cmake, ninja, and ccache -RUN /setup_cpp_linux --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true - -RUN apt-get update && apt-get install -y \ - gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib \ - && rm -rf /var/lib/apt/lists/* - -# https://github.com/raspberrypi/pico-sdk -RUN git clone https://github.com/raspberrypi/pico-sdk /home/pico-sdk -ENV PICO_SDK_PATH /home/pico-sdk -WORKDIR /home/pico-sdk -RUN git submodule update --init -WORKDIR / - -COPY ./docker/entrypoint.sh /docker-entrypoint.sh -ENTRYPOINT [ "/docker-entrypoint.sh" ] - - -FROM setup AS build -COPY . /home/project_options -RUN cp -rf /home/pico-sdk/external/pico_sdk_import.cmake /home/project_options/tests/pico/pico_sdk_import.cmake -WORKDIR /home/project_options -ENV PROJECT_DIR /home/project_options -CMD ["/bin/bash", "-c", "task pico:build"] - diff --git a/docker/Taskfile.yml b/docker/Taskfile.yml index 0facf3d7..59c95a21 100644 --- a/docker/Taskfile.yml +++ b/docker/Taskfile.yml @@ -49,7 +49,3 @@ tasks: rpi4.custom: - docker-compose up --build build-rpi4-custom - docker-compose down - - pico: - - docker-compose up --build build-pico - - docker-compose down \ No newline at end of file From 41fe69775397fae11e62424be1d6dfcac8892181 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 16 Jan 2023 23:13:22 -0800 Subject: [PATCH 09/15] chore: fix the lint issues --- .github/workflows/ci.cross.arm.yml | 2 +- cspell.config.yaml | 14 +++++++++++++- src/CrossCompiler.cmake | 2 +- tests/rpi3/CMakeLists.txt | 14 ++++++++++---- tests/rpi3/main.c | 6 +++--- tests/rpi4-vcpkg/CMakeLists.txt | 2 +- tests/rpi4-vcpkg/main.cpp | 4 ++-- tests/rpi4/CMakeLists.txt | 2 +- 8 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.cross.arm.yml b/.github/workflows/ci.cross.arm.yml index 72eff3a6..bb011018 100644 --- a/.github/workflows/ci.cross.arm.yml +++ b/.github/workflows/ci.cross.arm.yml @@ -60,7 +60,7 @@ jobs: task: true doxygen: true powershell: true - + - name: Setup ARM (Cross) Compiler uses: tecolicom/actions-use-apt-tools@v1 with: diff --git a/cspell.config.yaml b/cspell.config.yaml index fe6236bf..27316dc3 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -16,6 +16,7 @@ words: - anotherproj - applellvm - ARGN + - armv - asan - buildtools - ccache @@ -29,10 +30,10 @@ words: - CPATH - Cppcheck - cppcoreguidelines - - cppreference - cppdbg - CPPFLAGS - cpprc + - cppreference - ctest - Cuda - DCMAKE @@ -41,6 +42,7 @@ words: - DOPT - dyld - dylib + - eabi - egor-tensin - Eigen - emcc @@ -52,20 +54,29 @@ words: - fdiagnostics - ftime - gcovr + - gnueabi + - gnueabihf - Graphviz - hwrap - iwwu - kcov - LDFLAGS + - lgcc - libc - libcuda + - libg - libstdc - LPSTR - LPWSTR + - lrdimon + - lstdc + - mcpu - mdfile + - mfpu - msbuild - msvc - msys + - mthumb - multilib - municode - myapp @@ -89,6 +100,7 @@ words: - shlib - suppr - SYSROOT + - tecolicom - TOLOWER - TOUPPER - ubsan diff --git a/src/CrossCompiler.cmake b/src/CrossCompiler.cmake index 64d09213..8c7436c4 100644 --- a/src/CrossCompiler.cmake +++ b/src/CrossCompiler.cmake @@ -168,7 +168,7 @@ macro(enable_cross_compiler) set(_toolchain_file) get_toolchain_file(_toolchain_file) - if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE ${_toolchain_file}) endif() set(CROSSCOMPILING TRUE) diff --git a/tests/rpi3/CMakeLists.txt b/tests/rpi3/CMakeLists.txt index 7c31a1d3..205baa02 100644 --- a/tests/rpi3/CMakeLists.txt +++ b/tests/rpi3/CMakeLists.txt @@ -90,10 +90,8 @@ project_options( - CLANG_TIDY_EXTRA_ARGUMENTS ${CLANG_TIDY_EXTRA_ARGUMENTS} - CPPCHECK_OPTIONS --enable=style,performance,warning,portability --inline-suppr @@ -120,8 +118,16 @@ target_link_libraries(example_c PRIVATE project_options project_warnings) if(ENABLE_CROSS_COMPILING) # fix: ...arm-none-eabi/lib/libg.a(lib_a-exit.o): in function `exit': - target_link_options(example_c PRIVATE -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group) + target_link_options( + example_c + PRIVATE + -Wl,--start-group + -lgcc + -lc + -lm + -lrdimon + -Wl,--end-group) # custom raspberry pi 3 options target_compile_options(project_options INTERFACE -march=armv8-a -mfpu=neon-fp-armv8 -mthumb) -endif() \ No newline at end of file +endif() diff --git a/tests/rpi3/main.c b/tests/rpi3/main.c index 0cee53ff..764e0c1e 100644 --- a/tests/rpi3/main.c +++ b/tests/rpi3/main.c @@ -1,6 +1,6 @@ -#include +#include int main() { - printf("Hello World\n"); - return 0; + printf("Hello World\n"); + return 0; } \ No newline at end of file diff --git a/tests/rpi4-vcpkg/CMakeLists.txt b/tests/rpi4-vcpkg/CMakeLists.txt index 4e37cf94..a118abc3 100644 --- a/tests/rpi4-vcpkg/CMakeLists.txt +++ b/tests/rpi4-vcpkg/CMakeLists.txt @@ -118,4 +118,4 @@ if(ENABLE_CROSS_COMPILING) #target_compile_definitions(project_options INTERFACE -D__ARM_NEON) target_compile_options(project_options INTERFACE -mcpu=cortex-a72) #target_compile_options(project_options INTERFACE -march=armv8-a+fp+simd) # use mcpu ? -endif() \ No newline at end of file +endif() diff --git a/tests/rpi4-vcpkg/main.cpp b/tests/rpi4-vcpkg/main.cpp index 115ff095..0296dc98 100644 --- a/tests/rpi4-vcpkg/main.cpp +++ b/tests/rpi4-vcpkg/main.cpp @@ -1,6 +1,6 @@ #include int main() { - fmt::print("Hello World!"); - return 0; + fmt::print("Hello World!"); + return 0; } \ No newline at end of file diff --git a/tests/rpi4/CMakeLists.txt b/tests/rpi4/CMakeLists.txt index 91716760..3292bb7d 100644 --- a/tests/rpi4/CMakeLists.txt +++ b/tests/rpi4/CMakeLists.txt @@ -109,4 +109,4 @@ if(ENABLE_CROSS_COMPILING) #target_compile_definitions(project_options INTERFACE -D__ARM_NEON) target_compile_options(project_options INTERFACE -mcpu=cortex-a72) #target_compile_options(project_options INTERFACE "-march=armv8-a+fp+simd") # use mcpu ? -endif() \ No newline at end of file +endif() From 88778227c83d2a02f4b35af35c87f4e32833cec4 Mon Sep 17 00:00:00 2001 From: abeimler Date: Tue, 17 Jan 2023 14:48:16 +0100 Subject: [PATCH 10/15] fix: CI cross arm --- .github/workflows/ci.cross.arm.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.cross.arm.yml b/.github/workflows/ci.cross.arm.yml index bb011018..586d225c 100644 --- a/.github/workflows/ci.cross.arm.yml +++ b/.github/workflows/ci.cross.arm.yml @@ -17,6 +17,11 @@ jobs: - ubuntu-22.04 cmake: - true + task: + - rpi4:build.cross + - rpi4-vcpkg:build.cross + - rpi4:build.cross.custom-toolchain + - rpi3:build.cross include: - task: rpi4:build.cross install-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu @@ -25,7 +30,7 @@ jobs: install-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu target: aarch64-linux-gnu - task: rpi4:build.cross.custom-toolchain - insstall-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu + install-cross-compiler: g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu target: aarch64-linux-gnu - task: rpi3:build.cross install-cross-compiler: gcc-arm-none-eabi binutils-arm-none-eabi From 62f4d81247e0bc9ee60f0f4847ba55b84e3b1fe6 Mon Sep 17 00:00:00 2001 From: abeimler Date: Tue, 17 Jan 2023 14:57:29 +0100 Subject: [PATCH 11/15] fix: CI cross arm --- tests/rpi4/Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rpi4/Taskfile.yml b/tests/rpi4/Taskfile.yml index 3732c960..f55b90d4 100644 --- a/tests/rpi4/Taskfile.yml +++ b/tests/rpi4/Taskfile.yml @@ -24,6 +24,6 @@ tasks: build.cross.custom-toolchain: cmds: - - task: build.release + - task: builds vars: CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux -DCMAKE_TOOLCHAIN_FILE=./cmake/my-toolchain.cmake From f0dc4595cb17342ef657566ed8a605d594e477a4 Mon Sep 17 00:00:00 2001 From: abeimler Date: Tue, 17 Jan 2023 19:07:33 +0100 Subject: [PATCH 12/15] fix: shell scripts (newline) --- docker/.gitattributes | 2 ++ docker/Taskfile.yml | 8 ++++---- docker/entrypoint.emscripten.sh | 2 +- docker/entrypoint.sh | 2 +- tests/rpi4/Taskfile.yml | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 docker/.gitattributes mode change 100755 => 100644 docker/entrypoint.emscripten.sh mode change 100755 => 100644 docker/entrypoint.sh diff --git a/docker/.gitattributes b/docker/.gitattributes new file mode 100644 index 00000000..13120907 --- /dev/null +++ b/docker/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.sh text eol=lf \ No newline at end of file diff --git a/docker/Taskfile.yml b/docker/Taskfile.yml index 59c95a21..9a71221e 100644 --- a/docker/Taskfile.yml +++ b/docker/Taskfile.yml @@ -26,16 +26,16 @@ tasks: - docker-compose up --build build-rpi3 - docker-compose down - rpi3.release: - - docker-compose up --build build-rpi3-release + rpi3.debug: + - docker-compose up --build build-rpi3-debug - docker-compose down rpi4: - docker-compose up --build build-rpi4 - docker-compose down - rpi4.release: - - docker-compose up --build build-rpi4-release + rpi4.debug: + - docker-compose up --build build-rpi4-debug - docker-compose down rpi4.test: diff --git a/docker/entrypoint.emscripten.sh b/docker/entrypoint.emscripten.sh old mode 100755 new mode 100644 index 323a3ac6..2287a423 --- a/docker/entrypoint.emscripten.sh +++ b/docker/entrypoint.emscripten.sh @@ -6,4 +6,4 @@ source ~/.cpprc # Activate PATH and other environment variables in the current terminal source /root/emsdk/emsdk_env.sh -exec "$@" \ No newline at end of file +exec "$@" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh old mode 100755 new mode 100644 index 0631eaba..172dce81 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -3,4 +3,4 @@ set -e source ~/.cpprc -exec "$@" \ No newline at end of file +exec "$@" diff --git a/tests/rpi4/Taskfile.yml b/tests/rpi4/Taskfile.yml index f55b90d4..6c6704b5 100644 --- a/tests/rpi4/Taskfile.yml +++ b/tests/rpi4/Taskfile.yml @@ -24,6 +24,6 @@ tasks: build.cross.custom-toolchain: cmds: - - task: builds + - task: build vars: CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "gcc-aarch64-linux-gnu-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "gcc-aarch64-linux-gnu-g++"}} -DDEFAULT_TRIPLET=arm64-linux -DCMAKE_TOOLCHAIN_FILE=./cmake/my-toolchain.cmake From cea73823b278cd3ff9b11720f6a1b388045e49ed Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 18 Jan 2023 09:48:30 +0100 Subject: [PATCH 13/15] fix: docker builds * add git submodule --- docker/Dockerfile | 2 ++ docker/Dockerfile.aarch64 | 5 +++++ docker/Dockerfile.arm | 2 ++ docker/Dockerfile.emscripten | 1 + docker/Dockerfile.mingw | 4 ++++ examples/Taskfile.yml | 1 + 6 files changed, 15 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index a8dd7dfe..7446b115 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,11 +21,13 @@ ENTRYPOINT [ "/docker-entrypoint.sh" ] FROM setup AS build COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task myproj:build"] FROM setup AS test COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task myproj:test"] diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 index ee16e82a..449abb55 100644 --- a/docker/Dockerfile.aarch64 +++ b/docker/Dockerfile.aarch64 @@ -24,21 +24,25 @@ ENTRYPOINT [ "/docker-entrypoint.sh" ] FROM setup AS build COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task rpi4:build.cross"] FROM setup AS build-debug COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task rpi4:build.cross.debug"] FROM setup AS build-vcpkg COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task rpi4-vcpkg:build.cross"] FROM setup AS build-custom COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task rpi4:build.cross.custom-toolchain"] @@ -48,5 +52,6 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init ENV QEMU_LD_PREFIX /usr/aarch64-linux-gnu CMD ["/bin/bash", "-c", "task rpi4:build.cross && qemu-aarch64 /home/project_options/tests/rpi4/build/Release/example"] diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm index 273e654a..cc99b513 100644 --- a/docker/Dockerfile.arm +++ b/docker/Dockerfile.arm @@ -24,10 +24,12 @@ ENTRYPOINT [ "/docker-entrypoint.sh" ] FROM setup AS build COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task rpi3:build.cross"] FROM setup AS build-debug COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task rpi3:build.cross.debug"] \ No newline at end of file diff --git a/docker/Dockerfile.emscripten b/docker/Dockerfile.emscripten index 27f19412..bc559c87 100644 --- a/docker/Dockerfile.emscripten +++ b/docker/Dockerfile.emscripten @@ -33,4 +33,5 @@ ENTRYPOINT [ "/docker-entrypoint.sh" ] FROM setup AS build COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task emscripten:build"] diff --git a/docker/Dockerfile.mingw b/docker/Dockerfile.mingw index f3c91859..56eef1b0 100644 --- a/docker/Dockerfile.mingw +++ b/docker/Dockerfile.mingw @@ -26,22 +26,26 @@ ENTRYPOINT [ "/docker-entrypoint.sh" ] FROM setup AS build COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task myproj:build.mingw"] FROM setup AS build-minimal COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task minimal:build.mingw"] FROM setup AS build-minimal-from-env COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task minimal:build.mingw.from-env"] FROM setup AS build-minimal-from-triplet COPY . /home/project_options WORKDIR /home/project_options +RUN git submodule update --init CMD ["/bin/bash", "-c", "task minimal:build.mingw.from-triplet"] diff --git a/examples/Taskfile.yml b/examples/Taskfile.yml index 08cf88bd..9ccf87a2 100644 --- a/examples/Taskfile.yml +++ b/examples/Taskfile.yml @@ -3,6 +3,7 @@ version: 3 includes: cpp_vcpkg_project: taskfile: ./cpp_vcpkg_project/Taskfile.yml + optional: true dir: ./cpp_vcpkg_project vars: CMAKE_GENERATOR: "Ninja Multi-Config" \ No newline at end of file From 42fba373395e7e88338b0ac9b6da34ccaff1dbe2 Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 18 Jan 2023 10:16:56 +0100 Subject: [PATCH 14/15] chore: update setup-cpp in docker files --- docker/Dockerfile | 13 ++++++------- docker/Dockerfile.aarch64 | 12 ++++++------ docker/Dockerfile.arm | 12 ++++++------ docker/Dockerfile.emscripten | 12 ++++++------ docker/Dockerfile.mingw | 12 ++++++------ 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7446b115..e9a764b7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,17 +1,16 @@ FROM ubuntu:22.04 AS base -ARG setup_cpp_linux_version="0.24.1" - -# add setup_cpp https://github.com/aminya/setup-cpp -ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux -RUN chmod +x /setup_cpp_linux - +# add setup-cpp https://github.com/aminya/setup-cpp +RUN apt-get update && apt-get install -y \ + npm \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g setup-cpp FROM base AS setup ARG compiler="gcc" # install cmake, ninja, and ccache -RUN /setup_cpp_linux --compiler $compiler --llvm true --cmake true --doxygen true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true +RUN setup-cpp --compiler $compiler --llvm true --cmake true --doxygen true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true COPY ./docker/entrypoint.sh /docker-entrypoint.sh diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 index 449abb55..a16b09e5 100644 --- a/docker/Dockerfile.aarch64 +++ b/docker/Dockerfile.aarch64 @@ -1,17 +1,17 @@ FROM ubuntu:22.04 AS base -ARG setup_cpp_linux_version="0.24.1" - -# add setup_cpp https://github.com/aminya/setup-cpp -ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux -RUN chmod +x /setup_cpp_linux +# add setup-cpp https://github.com/aminya/setup-cpp +RUN apt-get update && apt-get install -y \ + npm \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g setup-cpp FROM base AS setup # install cmake, ninja, and ccache -RUN /setup_cpp_linux --clangtidy true --clangformat true --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true +RUN setup-cpp --clangtidy true --clangformat true --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true RUN apt-get update && apt-get install -y \ g++-aarch64-linux-gnu gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu \ diff --git a/docker/Dockerfile.arm b/docker/Dockerfile.arm index cc99b513..264ae86d 100644 --- a/docker/Dockerfile.arm +++ b/docker/Dockerfile.arm @@ -1,17 +1,17 @@ FROM ubuntu:22.04 AS base -ARG setup_cpp_linux_version="0.24.1" - -# add setup_cpp https://github.com/aminya/setup-cpp -ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux -RUN chmod +x /setup_cpp_linux +# add setup-cpp https://github.com/aminya/setup-cpp +RUN apt-get update && apt-get install -y \ + npm \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g setup-cpp FROM base AS setup # install cmake, ninja, and ccache -RUN /setup_cpp_linux --clangtidy true --clangformat true --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true +RUN setup-cpp --clangtidy true --clangformat true --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true RUN apt-get update && apt-get install -y \ gcc-arm-none-eabi binutils-arm-none-eabi \ diff --git a/docker/Dockerfile.emscripten b/docker/Dockerfile.emscripten index bc559c87..ebfc97ff 100644 --- a/docker/Dockerfile.emscripten +++ b/docker/Dockerfile.emscripten @@ -1,17 +1,17 @@ FROM ubuntu:22.04 AS base -ARG setup_cpp_linux_version="0.24.1" - -# add setup_cpp https://github.com/aminya/setup-cpp -ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux -RUN chmod +x /setup_cpp_linux +# add setup-cpp https://github.com/aminya/setup-cpp +RUN apt-get update && apt-get install -y \ + npm \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g setup-cpp FROM base AS setup # install cmake, ninja, and ccache -RUN /setup_cpp_linux --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true +RUN setup-cpp --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true # install emscripten diff --git a/docker/Dockerfile.mingw b/docker/Dockerfile.mingw index 56eef1b0..0e8eb058 100644 --- a/docker/Dockerfile.mingw +++ b/docker/Dockerfile.mingw @@ -1,17 +1,17 @@ FROM ubuntu:22.04 AS base -ARG setup_cpp_linux_version="0.24.1" - -# add setup_cpp https://github.com/aminya/setup-cpp -ADD https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux /setup_cpp_linux -RUN chmod +x /setup_cpp_linux +# add setup-cpp https://github.com/aminya/setup-cpp +RUN apt-get update && apt-get install -y \ + npm \ + && rm -rf /var/lib/apt/lists/* +RUN npm install -g setup-cpp FROM base AS setup # install cmake, ninja, and ccache -RUN /setup_cpp_linux --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true --powershell true +RUN setup-cpp --cmake true --ninja true --ccache true --cppcheck true --vcpkg true --conan true --task true --powershell true # TODO: install cross-compiler with setup_cpp_linux # NOTE: install mingw by hand, waiting for setup-cpp to have mingw cross-compiler support From 08b5cb6e17068957c2b3b26e5945b2938456eada Mon Sep 17 00:00:00 2001 From: abeimler Date: Wed, 18 Jan 2023 10:44:45 +0100 Subject: [PATCH 15/15] fix: CI build, change apt install packages * use awalsh128/cache-apt-pkgs-action --- .github/workflows/ci.cross.arm.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.cross.arm.yml b/.github/workflows/ci.cross.arm.yml index 586d225c..5095c91d 100644 --- a/.github/workflows/ci.cross.arm.yml +++ b/.github/workflows/ci.cross.arm.yml @@ -67,9 +67,10 @@ jobs: powershell: true - name: Setup ARM (Cross) Compiler - uses: tecolicom/actions-use-apt-tools@v1 + uses: awalsh128/cache-apt-pkgs-action@latest with: - tools: ${{ matrix.install-cross-compiler }} + packages: ${{ matrix.install-cross-compiler }} + version: 1.0 - name: Build (Task) run: |