LOL Zig
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 1m43s

This commit is contained in:
Your Name
2025-05-25 23:04:39 +12:00
parent 3b51a511a6
commit 08794e6480
3 changed files with 62 additions and 107 deletions

View File

@@ -1,82 +1,20 @@
# syntax=docker/dockerfile:1.4
FROM --platform=$BUILDPLATFORM alpine:3.19 AS deps
FROM alpine AS compiler
# Install build dependencies
RUN apk add --no-cache \
build-base \
cmake \
git \
linux-headers \
musl-dev \
zlib \
zlib-dev \
zlib-static \
bzip2-static \
xz-static \
zstd-static \
curl \
bash \
gcc \
g++ \
libstdc++ \
ccache \
ninja \
pkgconfig
ARG VERSION=0.13.0
ARG OPTIONS=-Doptimize=ReleaseSafe
FROM deps AS build
RUN apk update && apk add curl tar xz
ARG TARGETARCH
WORKDIR /source
COPY . .
# zig-linux-aarch64-0.10.1.tar.xz
# ziglang.org/download/<ver>/zig-linux-<architecture>-<ver>.tar.xz
# Create and run build script
RUN printf '#!/bin/bash\n\
set -e\n\
echo "Setting up build directory..."\n\
mkdir -p /build/ccache\n\
mkdir -p /build/build_${TARGETARCH}\n\
\n\
echo "Checking static libraries..."\n\
ls -la /usr/lib/libz.a /usr/lib/libstdc++.a /usr/lib/libc.a || true\n\
\n\
echo "Setting up ccache..."\n\
export CCACHE_DIR=/build/ccache\n\
export CCACHE_MAXSIZE=2G\n\
export PATH="/usr/lib/ccache/bin:$PATH"\n\
\n\
echo "Running CMake configuration..."\n\
cd /build/build_${TARGETARCH}\n\
cmake /source -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
-DZLIB_INCLUDE_DIR=/usr/include \
-DZLIB_USE_STATIC_LIBS=TRUE \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-Bstatic -lz -lstdc++ -static-libgcc" \
-DCMAKE_C_FLAGS="-fPIC" \
-DCMAKE_CXX_FLAGS="-fPIC" \
-DCMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=".a" 2>&1 | tee cmake.log\n\
\n\
echo "Starting build..."\n\
ninja -v -j$(nproc) 2>&1 | tee build.log\n\
\n\
echo "Build complete. Checking for binary..."\n\
if [ ! -f dropshell ]; then\n\
echo "Build failed. Directory contents:"\n\
ls -la\n\
echo "CMake log:"\n\
cat cmake.log\n\
echo "Build log:"\n\
cat build.log\n\
exit 1\n\
fi\n\
\n\
echo "ccache stats:"\n\
ccache -s\n' > /source/docker_build.sh && chmod +x /source/docker_build.sh && /source/docker_build.sh
RUN curl https://ziglang.org/download/$VERSION/zig-linux-$(uname -m)-$VERSION.tar.xz -O && \
tar -xf *.tar.xz && \
mv zig-linux-$(uname -m)-$VERSION /compiler
# Final stage: copy out the binary
FROM scratch AS export-stage
ARG TARGETARCH
COPY --from=build /build/build_${TARGETARCH}/dropshell /dropshell
WORKDIR /build
COPY . /build
RUN /compiler/zig build $OPTIONS
FROM scratch AS output
COPY --from=compiler /build/zig-out/bin /bin