diff --git a/test/build.sh b/test/build.sh index 1fb5082..d8c118f 100755 --- a/test/build.sh +++ b/test/build.sh @@ -3,8 +3,19 @@ # Create volume if it doesn't exist docker volume create cppbuild-cache +# Directory to copy the executable to OUTDIR="output" +# Build command to run in the container +BUILD_COMMAND="mkdir -p /app/build && \ + cd /app/build && \ + cmake -G Ninja /app/src && \ + ninja -j$(nproc) && \ + mkdir /app/src/$OUTDIR && \ + cp /app/build/ipdemo /app/src/$OUTDIR/ipdemo && \ + chown -R $(id -u):$(id -g) /app/src/$OUTDIR" + +# Run the build in the container docker run --rm \ -v cppbuild-cache:/app/build \ -v $(pwd):/app/src \ @@ -16,14 +27,9 @@ docker run --rm \ -e CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) \ -e NINJA_STATUS="[%f/%t] " \ cpp-httplib-builder:latest \ - -c "mkdir -p /app/build && \ - cd /app/build && \ - cmake -G Ninja /app/src && \ - ninja -j$(nproc) && \ - mkdir /app/src/$OUTDIR && \ - cp /app/build/ipdemo /app/src/$OUTDIR/ipdemo && \ - chown -R $(id -u):$(id -g) /app/src/$OUTDIR" + -c "$BUILD_COMMAND" +# Run the executable if it exists if [ -f $OUTDIR/ipdemo ]; then $OUTDIR/ipdemo fi