Craziness with multiarch
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 1m18s
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 1m18s
This commit is contained in:
parent
d3ceb3f4be
commit
f45baa8362
@ -113,12 +113,21 @@ FetchContent_Declare(
|
||||
)
|
||||
FetchContent_MakeAvailable(nlohmann_json)
|
||||
|
||||
# Find zlib
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(dropshell PRIVATE
|
||||
libassert::assert
|
||||
cpptrace::cpptrace
|
||||
httplib::httplib
|
||||
nlohmann_json::nlohmann_json
|
||||
ZLIB::ZLIB
|
||||
)
|
||||
|
||||
# Set static linking flags
|
||||
set_target_properties(dropshell PROPERTIES
|
||||
LINK_FLAGS "-static-libstdc++ -static-libgcc -Wl,-Bstatic -Wl,-Bdynamic"
|
||||
)
|
||||
|
||||
# Install targets
|
||||
|
70
source/Dockerfile.multiarch
Normal file
70
source/Dockerfile.multiarch
Normal file
@ -0,0 +1,70 @@
|
||||
# syntax=docker/dockerfile:1.4
|
||||
FROM --platform=$BUILDPLATFORM alpine:3.19 AS deps
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
build-base \
|
||||
cmake \
|
||||
git \
|
||||
linux-headers \
|
||||
musl-dev \
|
||||
zlib-dev \
|
||||
bzip2-dev \
|
||||
xz-dev \
|
||||
zstd-dev \
|
||||
curl \
|
||||
bash \
|
||||
gcc \
|
||||
g++ \
|
||||
libstdc++ \
|
||||
libstdc++-dev \
|
||||
ccache \
|
||||
ninja
|
||||
|
||||
FROM deps AS build
|
||||
|
||||
ARG TARGETARCH
|
||||
WORKDIR /source
|
||||
COPY . .
|
||||
|
||||
# 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 "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 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
|
||||
|
||||
# Final stage: copy out the binary
|
||||
FROM scratch AS export-stage
|
||||
ARG TARGETARCH
|
||||
COPY --from=build /build/build_${TARGETARCH}/dropshell /dropshell
|
@ -6,8 +6,7 @@ set -e
|
||||
# src/utils/createagent.cpp
|
||||
#
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# check if dehydrate is installed
|
||||
if ! command -v dehydrate &> /dev/null; then
|
||||
echo "dehydrate could not be found - installing"
|
||||
|
@ -7,53 +7,42 @@
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
OUTPUT_DIR="$SCRIPT_DIR/output"
|
||||
DOCKERFILE="$SCRIPT_DIR/Dockerfile.multiarch"
|
||||
|
||||
rm -f $SCRIPT_DIR/build_amd64/dropshell $SCRIPT_DIR/build_arm64/dropshell $SCRIPT_DIR/output/dropshell.amd64 $SCRIPT_DIR/output/dropshell.arm64
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
# Determine number of CPU cores for parallel build
|
||||
if command -v nproc >/dev/null 2>&1; then
|
||||
JOBS=$(nproc)
|
||||
else
|
||||
JOBS=4 # fallback default
|
||||
fi
|
||||
|
||||
PREV_PWD=$PWD
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
# Build for amd64 (musl)
|
||||
echo "Building for amd64 (musl)..."
|
||||
cmake -B build_amd64 -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER=x86_64-linux-musl-gcc \
|
||||
-DCMAKE_CXX_COMPILER=x86_64-linux-musl-g++ \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-static" \
|
||||
-DCMAKE_CXX_FLAGS="-march=x86-64" .
|
||||
cmake --build build_amd64 --target dropshell --config Release -j"$JOBS"
|
||||
mkdir -p output
|
||||
cp build_amd64/dropshell output/dropshell.amd64
|
||||
|
||||
# Build for arm64 (musl)
|
||||
echo "Building for arm64 (musl)..."
|
||||
cmake -B build_arm64 -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER=aarch64-linux-musl-gcc \
|
||||
-DCMAKE_CXX_COMPILER=aarch64-linux-musl-g++ \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-static" \
|
||||
-DCMAKE_CXX_FLAGS="-march=armv8-a" \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=aarch64 .
|
||||
cmake --build build_arm64 --target dropshell --config Release -j"$JOBS"
|
||||
mkdir -p output
|
||||
cp build_arm64/dropshell output/dropshell.arm64
|
||||
|
||||
if [ ! -f output/dropshell.amd64 ]; then
|
||||
echo "output/dropshell.amd64 not found!" >&2
|
||||
# Ensure buildx is available
|
||||
if ! docker buildx version &>/dev/null; then
|
||||
echo "Docker Buildx is required. Please install Docker Buildx." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f output/dropshell.arm64 ]; then
|
||||
echo "output/dropshell.arm64 not found!" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Build for x86_64
|
||||
DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64 \
|
||||
-f "$DOCKERFILE" \
|
||||
--output type=local,dest="$OUTPUT_DIR/amd64_tmp" \
|
||||
--cache-from type=local,src=/tmp/dropshell-cache \
|
||||
--cache-to type=local,dest=/tmp/dropshell-cache,mode=max \
|
||||
"$SCRIPT_DIR"
|
||||
|
||||
mv "$OUTPUT_DIR/amd64_tmp/dropshell" "$OUTPUT_DIR/dropshell.amd64"
|
||||
rm -rf "$OUTPUT_DIR/amd64_tmp"
|
||||
|
||||
echo "Built output/dropshell.amd64"
|
||||
|
||||
# Build for aarch64
|
||||
DOCKER_BUILDKIT=1 docker buildx build --platform linux/arm64 \
|
||||
-f "$DOCKERFILE" \
|
||||
--output type=local,dest="$OUTPUT_DIR/arm64_tmp" \
|
||||
--cache-from type=local,src=/tmp/dropshell-cache \
|
||||
--cache-to type=local,dest=/tmp/dropshell-cache,mode=max \
|
||||
"$SCRIPT_DIR"
|
||||
|
||||
mv "$OUTPUT_DIR/arm64_tmp/dropshell" "$OUTPUT_DIR/dropshell.arm64"
|
||||
rm -rf "$OUTPUT_DIR/arm64_tmp"
|
||||
|
||||
echo "Built output/dropshell.arm64"
|
||||
|
||||
echo "Builds complete:"
|
||||
ls -lh output/dropshell.*
|
||||
|
||||
cd $PREV_PWD
|
||||
ls -lh "$OUTPUT_DIR"/dropshell.*
|
Loading…
x
Reference in New Issue
Block a user