Bug fixing

This commit is contained in:
Your Name
2025-05-25 13:51:17 +12:00
parent 0adc14ca7e
commit 7f35bbeb01
5 changed files with 67 additions and 29 deletions

View File

@@ -6,7 +6,8 @@ set -e
# DIRECTORIES
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CACHE_DIR="${SCRIPT_DIR}/cache"
EXE_DIR="${SCRIPT_DIR}/exe"
EXE_DIR="${SCRIPT_DIR}/output"
PROJECTNAME="simple_object_storage"
rm -f ${EXE_DIR}/*
@@ -29,31 +30,31 @@ function die() {
exit 1
}
function build() {
ARCH=$1
function build_amd64() {
# 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 simple_object_storage --config Release -j"$JOBS"
mkdir -p ${EXE_DIR}
cp build_amd64/${PROJECTNAME} ${EXE_DIR}/${PROJECTNAME}.amd64
}
BUILD_NAME="build-${ARCH}"
BUILD_DIR="${SCRIPT_DIR}/${BUILD_NAME}"
mkdir -p ${BUILD_DIR}
DOCKCROSS_SCRIPT="${CACHE_DIR}/dockcross-${ARCH}"
if [ ! -f "${DOCKCROSS_SCRIPT}" ]; then
echo "Downloading dockcross-${ARCH}"
docker run --rm "dockcross/${ARCH}-full" > "${DOCKCROSS_SCRIPT}"
chmod +x "${DOCKCROSS_SCRIPT}"
fi
echo "Building $ARCH executable"
cd "${SCRIPT_DIR}"
"${DOCKCROSS_SCRIPT}" bash -c "cd ${BUILD_NAME} && cmake .. && make -j$(nproc)"
if [ ! -f ${BUILD_DIR}/simple_object_storage ]; then
die "Failed to build $ARCH executable"
fi
echo "Copying $ARCH executable to $EXE_DIR/simple_object_storage-$ARCH"
cp ${BUILD_DIR}/simple_object_storage $EXE_DIR/simple_object_storage-$ARCH
function build_arm64() {
# 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 simple_object_storage --config Release -j"$JOBS"
mkdir -p ${EXE_DIR}
cp build_arm64/${PROJECTNAME} ${EXE_DIR}/${PROJECTNAME}.arm64
}
#--------------------------------
@@ -72,14 +73,13 @@ fi
if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "arm64" ]; then
title "Building linux-arm64 executable"
build linux-arm64 || die "Failed to build linux-arm64 executable"
build_arm64 || die "Failed to build linux-arm64 executable"
echo "arm64 executable: ./simple_object_storage-linux-arm64"
fi
if [ "$BUILDSTR" = "all" ] || [ "$BUILDSTR" = "amd64" ]; then
title "Building linux-x86_64 executable"
build linux-x86_64 || die "Failed to build linux-x86_64 executable"
mv ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64
build_amd64 || die "Failed to build linux-x86_64 executable"
echo "amd64 executable: ./simple_object_storage-linux-amd64"
fi