diff --git a/packages/Dockerfile b/packages/Dockerfile new file mode 100644 index 0000000..b51cce8 --- /dev/null +++ b/packages/Dockerfile @@ -0,0 +1,26 @@ +FROM ubuntu:22.04 + +# Set up architectures first +RUN dpkg --add-architecture arm64 && \ + sed -i 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list && \ + echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse" >> /etc/apt/sources.list && \ + echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ + echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list && \ + echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list + +# Install build dependencies for both architectures +RUN apt-get update && \ + apt-get install -y \ + cmake \ + make \ + g++ \ + musl-tools \ + g++-aarch64-linux-gnu \ + crossbuild-essential-arm64 \ + libtbb-dev \ + libxxhash-dev \ + libtbb-dev:arm64 \ + libxxhash-dev:arm64 && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /src \ No newline at end of file diff --git a/packages/build_executables.sh b/packages/build_executables.sh index 11c2c0a..b021586 100755 --- a/packages/build_executables.sh +++ b/packages/build_executables.sh @@ -1,6 +1,42 @@ -# This script uses debian docker containers (not the host!) to do the following: -# 1. builds two executables from ../CMakeLists.txt (a C++ project) -# a) dropshell-x86_64, using musl and static linking -# b) dropshell-arm64, using musl and static linking +# 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. +# The executables are copied to ./output, with the ownership changed to current user. + +#!/bin/bash +set -e + +# Create output directory if it doesn't exist +mkdir -p output + +# Build Docker image if it doesn't exist +if ! docker image inspect dropshell-builder:latest >/dev/null 2>&1; then + echo "Building builder image..." + docker build -t dropshell-builder:latest . +fi + +# Build x86_64 executable +docker run --rm -v "$(pwd)/..:/src" dropshell-builder:latest bash -c ' + rm -rf build && \ + mkdir -p build && \ + cd build && \ + cmake -DCMAKE_BUILD_TYPE=Release .. && \ + make && \ + cp dropshell ../packages/output/dropshell-x86_64 +' + +# Build arm64 executable +docker run --rm -v "$(pwd)/..:/src" dropshell-builder:latest bash -c ' + rm -rf build && \ + mkdir -p build && \ + cd build && \ + cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ + -DCMAKE_BUILD_TYPE=Release .. && \ + make && \ + cp dropshell ../packages/output/dropshell-arm64 +' + +# Change ownership to current user +chown $(id -u):$(id -g) output/dropshell-* diff --git a/packages/output/dropshell-arm64 b/packages/output/dropshell-arm64 new file mode 100755 index 0000000..6161e8d Binary files /dev/null and b/packages/output/dropshell-arm64 differ diff --git a/packages/output/dropshell-x86_64 b/packages/output/dropshell-x86_64 new file mode 100755 index 0000000..151ef1f Binary files /dev/null and b/packages/output/dropshell-x86_64 differ