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:
@ -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.*
|
Reference in New Issue
Block a user