# This script uses a pre-built docker container to build two executables: # 1. dropshell-x86_64, using musl and static linking # 2. dropshell-arm64, using musl and static linking # The executables are copied to ./output, with the ownership changed to current user. #!/bin/bash set -e # Get current user's UID and GID USER_ID=$(id -u) GROUP_ID=$(id -g) # Create output directory if it doesn't exist mkdir -p output # Build Docker image echo "Building builder image..." docker build -t dropshell-builder:latest . echo "Building x86_64 executable..." # Build x86_64 executable docker run --rm -v "$(pwd)/..:/src" -u root dropshell-builder:latest bash -c ' \ rm -rf build && \ mkdir -p build && \ cd build && \ cp ../packages/CMakeLists.txt.static ../CMakeLists.txt && \ MUSL_GPP=$(which musl-g++) && \ cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_COMPILER=${MUSL_GPP} \ -DCMAKE_CXX_FLAGS="-static" .. && \ make && \ cp dropshell ../packages/output/dropshell-x86_64 && \ chown '"$USER_ID:$GROUP_ID"' ../packages/output/dropshell-x86_64 && \ rm -rf build \ ' echo "Building arm64 executable..." # Build arm64 executable docker run --rm -v "$(pwd)/..:/src" -u root dropshell-builder:latest bash -c ' \ rm -rf build && \ mkdir -p build && \ cd build && \ cp ../packages/CMakeLists.txt.static ../CMakeLists.txt && \ MUSL_GPP=$(which aarch64-linux-musl-g++) && \ cmake -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_COMPILER=${MUSL_GPP} \ -DCMAKE_CXX_FLAGS="-static" .. && \ make && \ cp dropshell ../packages/output/dropshell-arm64 && \ chown '"$USER_ID:$GROUP_ID"' ../packages/output/dropshell-arm64 && \ rm -rf build \ '