Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
abeimler committed Nov 2, 2022
2 parents bb0f42a + 02aefe9 commit 98d667d
Show file tree
Hide file tree
Showing 28 changed files with 185 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ ENV TOOLCHAIN_FILE "/home/project/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV CHAINLOAD_TOOLCHAIN_FILE $cmake_toolchain_file
ENV CMAKE_ARGS ""

RUN mkdir build
RUN mkdir build
4 changes: 2 additions & 2 deletions Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN python -m pip install --upgrade pip setuptools && \
conan --version
# Install more pip tools
RUN python -m pip install --upgrade pip setuptools && \
python -m pip install cogapp coverage
python -m pip install cogapp coverage cmake-format cmakelint

# thx to https://github.com/lefticus/cpp_starter_project/pull/121

Expand All @@ -60,4 +60,4 @@ ENV MAKE "make"

# setup project env
ENV PROJECT_DIR /home/project
WORKDIR /home/project
WORKDIR /home/project
13 changes: 8 additions & 5 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN python3 -m pip install --upgrade pip setuptools && \
conan --version
# Install more pip tools
RUN python3 -m pip install --upgrade pip setuptools && \
python3 -m pip install cogapp coverage
python3 -m pip install cogapp coverage cmake-format cmakelint

# thx to https://github.com/lefticus/cpp_starter_project/pull/121

Expand Down Expand Up @@ -82,11 +82,10 @@ ENV CMAKE_ARGS ""

# install CodeCov
WORKDIR /home/codecov
RUN curl -Os https://uploader.codecov.io/latest/linux/codecov
RUN curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
RUN curl -Os https://uploader.codecov.io/latest/alpine/codecov
RUN curl -Os https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM
RUN curl -Os https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig
ADD https://uploader.codecov.io/latest/alpine/codecov codecov
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM codecov.SHA256SUM
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig codecov.SHA256SUM.sig
RUN gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
RUN shasum -a 256 -c codecov.SHA256SUM
RUN chmod +x codecov
Expand All @@ -110,3 +109,7 @@ ENV TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build

COPY ./scripts/docker-entrypoint.ci.sh /docker-entrypoint.sh
ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh"]
CMD ["/bin/bash"]
29 changes: 13 additions & 16 deletions Dockerfile.ci-setup-cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ RUN apt-get update -y -qq && \

# install CodeCov
WORKDIR /home/codecov
RUN curl -Os https://uploader.codecov.io/latest/linux/codecov
RUN curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
RUN curl -Os https://uploader.codecov.io/latest/alpine/codecov
RUN curl -Os https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM
RUN curl -Os https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig
ADD https://uploader.codecov.io/latest/alpine/codecov codecov
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM codecov.SHA256SUM
ADD https://uploader.codecov.io/latest/alpine/codecov.SHA256SUM.sig codecov.SHA256SUM.sig
RUN gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
RUN shasum -a 256 -c codecov.SHA256SUM
RUN chmod +x codecov
ENV CODECOV "/home/codecov/codecov"

# download setup_cpp
ARG setup_cpp_linux_version="0.20.1"
ARG setup_cpp_linux_version="0.21.0"
ARG setup_cpp_linux_download_url="https://github.com/aminya/setup-cpp/releases/download/v${setup_cpp_linux_version}/setup_cpp_linux"
# add setup_cpp
RUN wget --no-verbose ${setup_cpp_linux_download_url} -O /setup_cpp_linux
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
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
RUN rm -rf /tmp/*
RUN cp /root/.cpprc /root/.bashrc
#RUN cp /root/.cpprc /root/.bashrc

# Install more tools from standard repos
RUN apt-get update -y && \
Expand All @@ -50,7 +49,7 @@ RUN apt-get update -y && \

# Install more pip tools
RUN python3 -m pip install --upgrade pip setuptools && \
python3 -m pip install cogapp coverage
python3 -m pip install cogapp coverage cmake-format cmakelint

## Cleanup cached apt data we don't need anymore
RUN apt-get autoremove -y && apt-get clean && \
Expand Down Expand Up @@ -79,8 +78,9 @@ ENV MAKE "/root/ninja/ninja"
WORKDIR /home/project
RUN bash -c 'source ~/.cpprc'

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
COPY ./scripts/docker-entrypoint.setup-cpp.sh /docker-entrypoint.sh
ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh"]
CMD ["/bin/bash"]



Expand Down Expand Up @@ -115,18 +115,15 @@ ENV CMAKE_ARGS ""
ENV VCPKG_DISABLE_METRICS 1
RUN /setup_cpp_linux --vcpkg true
ENV VCPKG_ROOT "/root/vcpkg"

RUN /root/vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"

# setup project env
ENV PROJECT_DIR /home/project
WORKDIR /home/project
COPY ./scripts/docker-build.setup-cpp.sh ./docker-build.sh
COPY ./scripts/docker-test.setup-cpp.sh ./docker-test.sh
COPY ./scripts/docker-test-coverage.sh ./docker-test-coverage.sh
COPY ./scripts/docker-test-coverage.setup-cpp.sh ./docker-test-coverage.sh
RUN mkdir build

ENV SETUP_ENV_SCRIPT ~/.cpprc
RUN bash -c 'source ~/.cpprc'
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
RUN bash -c 'source ~/.cpprc'
12 changes: 8 additions & 4 deletions Dockerfile.ci-windows
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ RUN apt-get update -y && \

# install powershell
ENV PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache
RUN curl -sSL https://github.com/PowerShell/PowerShell/releases/download/v7.2.5/powershell-lts_7.2.5-1.deb_amd64.deb -o /tmp/powershell.deb && \
apt-get update -y && apt-get install -y /tmp/powershell.deb && \
ADD https://github.com/PowerShell/PowerShell/releases/download/v7.2.5/powershell-lts_7.2.5-1.deb_amd64.deb /tmp/powershell.deb
RUN apt-get update -y && apt-get install -y /tmp/powershell.deb && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
rm /tmp/powershell.deb
ENV POWERSHELL_TELEMETRY_OPTOUT 1
Expand All @@ -54,7 +54,7 @@ RUN python3 -m pip install --upgrade pip setuptools && \
conan --version
# Install more pip tools
RUN python3 -m pip install --upgrade pip setuptools && \
python3 -m pip install cogapp coverage
python3 -m pip install cogapp coverage cmake-format cmakelint

# thx to https://github.com/lefticus/cpp_starter_project/pull/121

Expand Down Expand Up @@ -136,4 +136,8 @@ COPY ./scripts/docker-build.ci-mingw.sh ./docker-build.sh

ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build
RUN mkdir build

COPY ./scripts/docker-entrypoint.ci.sh /docker-entrypoint.sh
ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh"]
CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ RUN . $setup_env_script

ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build
RUN mkdir build
1 change: 0 additions & 1 deletion Dockerfile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ COPY ./cmake ./cmake
COPY ./scripts/docker-build.setup-env.sh ./docker-build.sh
COPY ./scripts/docker-test.setup-env.sh ./docker-test.sh


ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build
2 changes: 1 addition & 1 deletion Dockerfile.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ENV MAKE "make"
# install vcpkg
ENV VCPKG_DISABLE_METRICS 1
RUN git clone --depth 1 https://github.com/Microsoft/vcpkg.git /home/project/vcpkg
RUN /home/project/vcpkg/vcpkg/bootstrap-vcpkg.sh -disableMetrics
RUN /home/project/vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_ROOT "/home/project/vcpkg"

ENV VCPKG_TOOLCHAIN_FILE "$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.mxe
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ COPY ./scripts/docker-build.mxe.sh ./docker-build.sh

ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build
RUN mkdir build
2 changes: 1 addition & 1 deletion Dockerfile.rpi
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ ENV TOOLCHAIN_FILE "/home/project/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV CHAINLOAD_TOOLCHAIN_FILE $cmake_toolchain_file
ENV CMAKE_ARGS ""

RUN mkdir build
RUN mkdir build
2 changes: 1 addition & 1 deletion Dockerfile.rpi-without-tools
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ ENV TOOLCHAIN_FILE "/home/project/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV CHAINLOAD_TOOLCHAIN_FILE $cmake_toolchain_file
ENV CMAKE_ARGS ""

RUN mkdir build
RUN mkdir build
73 changes: 70 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Based on [archlinux:base-devel](https://hub.docker.com/_/archlinux) with [yay](h

You can find a full C++ project example [here](https://github.com/abeimler/simple-cppbuilder/tree/main/examples/example).

### Create a `Dockerfile` in your C++ project
### Add Docker into your C++ Project

1. Create a `Dockerfile` in your C++ project

```Dockerfile
## build stage
Expand All @@ -37,7 +39,7 @@ FROM build as test
CMD ["./docker-test.sh"]
```

You can then build and run the Docker image:
2. Build and run the Docker image:

```bash
$ docker build -t my-cpp-project .
Expand Down Expand Up @@ -66,7 +68,7 @@ Default image with gcc, buildtools, [conan](https://conan.io/) installed and [vc

Default image with clang compiler.

#### `:gcc10`, `:gcc9`
#### `:gcc10`, `:gcc9` (outdated)

Default image with gcc compiler.

Expand Down Expand Up @@ -284,6 +286,71 @@ CMake Toolchain File `-DCMAKE_TOOLCHAIN_FILE`, default `./vcpkg/scripts/buildsys
Custom CMake Arguments, e.g. `-DENABLE_TESTING:BOOL=ON -DOPT_ENABLE_COVERAGE:BOOL=ON -DENABLE_DEVELOPER_MODE:BOOL=OFF`.


## More Environment Variables

Here are some Environment Variables you can use in your build script, such as paths, scripts and programs.

### `MAKE`

`make` or `ninja`.

### `PROJECT_DIR`

Project-Home folder, `/home/project`.

### `VCPKG_ROOT`

Path to vcpkg, `/home/project/vcpkg`.

### `VCPKG_TOOLCHAIN_FILE`

vcpkg Toolchain, `/home/project/vcpkg/scripts/buildsystems/vcpkg.cmake`.


### `CODECOV`

Path to [codedov uploader](https://about.codecov.io/blog/introducing-codecovs-new-uploader/), `/home/codecov/codecov`.

_(Used in CI/CD images)_


### `VCPKG_DEFAULT_HOST_TRIPLET`, `VCPKG_DEFAULT_TRIPLET`

vcpkg target- and host-triplet.

_(Used in cross-compiler images)_

### `VCPKG_CHAINLOAD_TOOLCHAIN_FILE`

alternate CMake toolchain (for vcpkg)

_(Used in cross-compiler images)_

### `CROSS_TOOLCHAIN`

Path to CMake Toolchain, `/home/cmake/x86_64-w64-mingw32.toolchain.cmake`.

_(Used in cross-compiler images)_

### `SETUP_ENV_SCRIPT`

source or setup-environment-script for cross compiler tools, `/usr/lib/emsdk/emsdk_env.sh` or ` ~/.cpprc`, ...

_(Used in cross-compiler images)_

### `EM_CACHE`, `EM_CONFIG`, `EMSCRIPTEN_PATH`, `EMSDK`, `EMSDK_PATH`

Paths for emscripten, emsdk and configs.

* `EM_CACHE`: `/usr/lib/emsdk/upstream/emscripten/cache`
* `EM_CONFIG`: `/usr/lib/emsdk/.emscripten`
* `EMSCRIPTEN_PATH`: `/usr/lib/emscripten`
* `EMSDK`: `/usr/lib/emsdk`
* `EMSDK_PATH`: `/usr/lib/emsdk`

_(Used in emscripten images)_


## License

View [license information](https://github.com/abeimler/simple-cppbuilder/blob/main/LICENSE) for this image.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.6.0
9 changes: 5 additions & 4 deletions build-images.all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

./build-images.android.sh
./build-images.android-21.sh
./build-images.android-24.sh

./build-images.arm.crosstool.sh
./build-images.rpi.sh
#./build-images.arm.crosstool.sh
#./build-images.rpi.sh

./build-images.gcc.sh
./build-images.mingw.mxe.sh
#./build-images.gcc.sh
#./build-images.mingw.mxe.sh
4 changes: 4 additions & 0 deletions build-images.mingw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ docker build --force-rm=true -f ./Dockerfile.cross \
--build-arg setup_env_script="mingw-env" \
--build-arg cmake_toolchain_file="/usr/share/mingw/toolchain-x86_64-w64-mingw32.cmake" \
--build-arg docker_build_script="docker-build.mingw.sh" \
--build-arg docker_test_script="docker-test.mingw.sh" \
--build-arg docker_entrypoint="docker-entrypoint.mingw.sh" \
-t abeimler/simple-cppbuilder:x64-mingw-w64 .

docker build --force-rm=true -f ./Dockerfile.cross \
Expand All @@ -28,5 +30,7 @@ docker build --force-rm=true -f ./Dockerfile.cross \
--build-arg setup_env_script="mingw-env" \
--build-arg cmake_toolchain_file="/usr/share/mingw/toolchain-i686-w64-mingw32.cmake" \
--build-arg docker_build_script="docker-build.mingw.sh" \
--build-arg docker_test_script="docker-test.mingw.sh" \
--build-arg docker_entrypoint="docker-entrypoint.mingw.sh" \
-t abeimler/simple-cppbuilder:x86-mingw-w64 .

2 changes: 2 additions & 0 deletions scripts/docker-build.android.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source $SETUP_ENV_SCRIPT

set -euo pipefail

${CROSS_CMAKE} -B build -S . -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \
Expand Down
7 changes: 4 additions & 3 deletions scripts/docker-build.cross.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

source $SETUP_ENV_SCRIPT
. $SETUP_ENV_SCRIPT

set -euo pipefail

Expand All @@ -11,4 +11,5 @@ ${CROSS_CMAKE} -B build -S . -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE="${BUILD

# @FIXME: "CMake Error: Unknown argument --build" with ${CROSS_CMAKE} ... use ninja, ${CROSS_MAKE} = ninja
#cmake -B build --build build --target "${TARGET}"
cd build && ${CROSS_MAKE} "${TARGET}"
cd build
${CROSS_MAKE} "${TARGET}"
2 changes: 2 additions & 0 deletions scripts/docker-build.crosstool-ng.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source $SETUP_ENV_SCRIPT

set -euo pipefail

${CROSS_CMAKE} -B build -S . -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \
Expand Down
7 changes: 4 additions & 3 deletions scripts/docker-build.mingw.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

source $SETUP_ENV_SCRIPT $CROSS_TRIPLET
. $SETUP_ENV_SCRIPT $CROSS_TRIPLET

set -euo pipefail

Expand All @@ -14,4 +14,5 @@ ${CROSS_CMAKE} \

# @FIXME: "CMake Error: Unknown argument --build" with ${CROSS_CMAKE} ... use ninja, ${CROSS_MAKE} = ninja
#cmake -B build --build build --target "${TARGET}"
cd build && ${CROSS_MAKE} "${TARGET}"
cd build
${CROSS_MAKE} "${TARGET}"
Loading

0 comments on commit 98d667d

Please sign in to comment.