diff --git a/Dockerfile.ci-setup-cpp b/Dockerfile.ci-setup-cpp index 9963ab9..3eea004 100644 --- a/Dockerfile.ci-setup-cpp +++ b/Dockerfile.ci-setup-cpp @@ -38,7 +38,7 @@ RUN chmod +x /setup_cpp_linux RUN /setup_cpp_linux --compiler llvm --gcc true --make true --cmake true --ninja true --ccache true --doxygen true --gcovr true --cppcheck true --clangtidy true --clangformat true --conan true --task true RUN rm -rf /tmp/* RUN echo 'source /root/.cpprc' >> /root/.bash_profile -#RUN cp /root/.cpprc /root/.bashrc +RUN cp /root/.cpprc /root/.bashrc # Install more tools from standard repos RUN apt-get update -y && \ @@ -80,7 +80,7 @@ ARG setup_env_script_args="" ENV SETUP_ENV_SCRIPT $setup_env_script ENV SETUP_ENV_SCRIPT_ARGS $setup_env_script_args RUN echo 'source "$SETUP_ENV_SCRIPT $SETUP_ENV_SCRIPT_ARGS"' >> /root/.bash_profile -RUN bash -c 'source $setup_env_script $setup_env_script_args' +RUN . $setup_env_script $setup_env_script_args # setup project env WORKDIR /home/project diff --git a/README.md b/README.md index d665c41..ec0c1b2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Simple C++ Builder with compilers, buildtools and dependency manager. ## Features - Pre-installed Compilers and Tools -- Ready to use build scripts ([docker-build.sh](https://github.com/abeimler/simple-cppbuilder/blob/main/scripts/docker-build.sh) and [docker-test.sh](https://github.com/abeimler/simple-cppbuilder/blob/main/scripts/docker-test.sh)) +- Ready to use ~~build scripts ([docker-build.sh](https://github.com/abeimler/simple-cppbuilder/blob/main/scripts/docker-build.sh) and [docker-test.sh](https://github.com/abeimler/simple-cppbuilder/blob/main/scripts/docker-test.sh))~~ [Taskfiles](https://github.com/abeimler/simple-cppbuilder/blob/main/taskfiles/TaskfileDefault.sh) ## What's included @@ -32,11 +32,11 @@ You can find a full C++ project example [here](https://github.com/abeimler/simpl ## build stage FROM abeimler/simple-cppbuilder as build COPY . . -CMD ["./docker-build.sh"] +CMD ["task", "-t", "/home/taskfiles/Taskfile.yml", "build"] ## test stage FROM build as test -CMD ["./docker-test.sh"] +CMD ["task", "-t", "/home/taskfiles/Taskfile.yml", "test"] ``` 2. Build and run the Docker image: @@ -141,7 +141,7 @@ RUN pacman-db-upgrade && pacman -S --noconfirm \ # build stage FROM base as build COPY . . -CMD ["./docker-build.sh"] +CMD ["task", "-t", "/home/taskfiles/Taskfile.yml", "build"] ``` ### Dockerfile using AUR @@ -206,18 +206,43 @@ services: $ docker-compose up --build ``` -### Use your custom build script +### ~~Use your custom build script~~ Better use a [Taskfile](https://taskfile.dev/usage/) -#### `my-build.sh` +#### ~~`my-build.sh`~~ -```bash -#!/bin/bash +#### `Taskfile.yml` -mkdir build -cd build -cmake -G "Ninja" -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=arm -DCMAKE_C_COMPILER=clang -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_TARGET=arm-linux-gnueabihf .. +```yml +--- +version: "3" + +vars: + PROJECT_DIR: '{{.PROJECT_DIR | default "."}}' + TARGET: '{{.TARGET | default "all"}}' + CMAKE_GENERATOR: '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}' + BUILD_TYPE: '{{.BUILD_TYPE | default "Release"}}' + +tasks: + configure: + dir: '{{.PROJECT_DIR}}' + cmds: + - > + cmake -B build -S . -G "{{.CMAKE_GENERATOR}}" \ + -DCMAKE_BUILD_TYPE="{{.BUILD_TYPE}}" \ + {{.CMAKE_ARGS}} + + build: + dir: '{{.PROJECT_DIR}}' + cmds: + - task: configure + - 'cmake --build build --target "{{.TARGET}}"' + + test: + dir: '{{.PROJECT_DIR}}' + cmds: + - task: build + - ctest --build-test --test-dir build -make my-app -j 4 ``` #### `Dockerfile` @@ -229,7 +254,8 @@ FROM abeimler/simple-cppbuilder as base # build stage FROM base as build COPY . . -CMD ["./my-build.sh"] +#CMD ["./my-build.sh"] +CMD ["task", "build"] ``` #### `docker-compose.yml` @@ -365,5 +391,6 @@ As for any pre-built image usage, it is the image user's responsibility to ensur - [simple-cppbuilder DockerHub](https://hub.docker.com/r/abeimler/simple-cppbuilder) - [simple-cppbuilder GitHub](https://github.com/abeimler/simple-cppbuilder) - [cpp_starter_project](https://github.com/lefticus/cpp_starter_project) +- [cpp_vcpkg_project](https://github.com/abeimler/cpp_vcpkg_project/tree/v2) - [cppdock](https://github.com/ricejasonf/cppdock) - Icon made by [me](https://hub.docker.com/u/abeimler) using C++-Icon made by [Freepik](https://www.freepik.com) from [Flaticon](https://www.flaticon.com/) diff --git a/taskfiles/docker/Build.yml b/taskfiles/docker/Build.yml index 5322a81..858f828 100644 --- a/taskfiles/docker/Build.yml +++ b/taskfiles/docker/Build.yml @@ -284,8 +284,7 @@ tasks: #- docker build --force-rm=true -f ./Dockerfile.gcc --build-arg gcc_version=5 -t abeimler/simple-cppbuilder:gcc-5 . #- docker build --force-rm=true -f ./Dockerfile.gcc --build-arg gcc_version=49 -t abeimler/simple-cppbuilder:gcc-4.9 . - - all: + default: - task: base - task: base:libs - task: ci diff --git a/taskfiles/docker/Test.yml b/taskfiles/docker/Test.yml index fb5885f..ea056a9 100644 --- a/taskfiles/docker/Test.yml +++ b/taskfiles/docker/Test.yml @@ -73,4 +73,18 @@ tasks: gcc: - container-structure-test test --image abeimler/simple-cppbuilder:gcc-10 --config tests/gcc10-test.yaml - - container-structure-test test --image abeimler/simple-cppbuilder:gcc-9 --config tests/gcc9-test.yaml \ No newline at end of file + - container-structure-test test --image abeimler/simple-cppbuilder:gcc-9 --config tests/gcc9-test.yaml + + default: + - task: base + - task: clang + - task: single + #- task: cpp_starter_project + - task: ci + - task: emscripten + - task: mingw + #- task: android + #- task: arm:rpi + #- task: rpi + #- task: mingw:mxe + #- task: gcc \ No newline at end of file