Skip to content

Commit a130174

Browse files
authored
feat(docker): Add CMAKE_FRESH_PRESET arg for --fresh cmake config (#151)
Adds a CMAKE_FRESH_PRESET build argument to the Dockerfile. When set to a non-empty value (e.g., 'true'), this appends '--fresh' to the initial 'cmake --preset' command, helping to resolve potential CMake cache issues during the Docker build. Updated README.md with explanation and usage example.
1 parent 6071fe1 commit a130174

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/engine/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ ENV GETML_VERSION=$VERSION
107107
ARG ENGINE_PRESET="release"
108108
ARG ENGINE_REPO_SOURCE
109109
ARG ENGINE_DIR
110+
ARG CMAKE_FRESH_PRESET=""
110111
ENV ENGINE_BUILD_PATH="$ENGINE_DIR/build/release-build"
111112

112113
COPY $ENGINE_REPO_SOURCE $ENGINE_DIR
@@ -119,7 +120,7 @@ RUN --mount=type=cache,target=$CCACHE_PATH,id="$CCACHE_PATH-$CACHE_ID" \
119120
if [ -n "$NJOBS" ]; then export CMAKE_BUILD_PARALLEL_LEVEL="$NJOBS"; fi \
120121
&& source scl_source enable gcc-toolset-14 \
121122
&& ccache --zero-stats \
122-
&& cmake --preset ${ENGINE_PRESET} -D CMAKE_UNITY_BUILD=ON -D CMAKE_UNITY_BUILD_BATCH_SIZE=0 \
123+
&& cmake --preset ${ENGINE_PRESET} -D CMAKE_UNITY_BUILD=ON -D CMAKE_UNITY_BUILD_BATCH_SIZE=0 ${CMAKE_FRESH_PRESET:+ --fresh} \
123124
&& cmake --build --preset ${ENGINE_PRESET} \
124125
&& ccache --show-stats -v -v
125126

src/engine/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,18 @@ $ docker build \
285285
.
286286
```
287287

288+
Sometimes the cmake cache is not updated correctly. In that case, use the `CMAKE_FRESH_PRESET` flag to force a fresh preset.
289+
290+
```bash
291+
$ docker build \
292+
-f Dockerfile \
293+
--target package \
294+
--build-arg VERSION=1.5.0 \
295+
--build-arg CMAKE_FRESH_PRESET=true \
296+
--output type=local,dest=$(pwd)/build-docker \
297+
.
298+
```
299+
288300

289301
### Quick check of Docker built engine
290302

0 commit comments

Comments
 (0)