.
This commit is contained in:
58
build.sh
58
build.sh
@@ -28,64 +28,22 @@ function die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
function clean() {
|
||||
echo "Cleaning build directories"
|
||||
rm -rf build
|
||||
rm -f cmake_install.cmake
|
||||
rm -f CMakeCache.txt
|
||||
rm -rf CMakeFiles
|
||||
}
|
||||
|
||||
function clean_cache() {
|
||||
echo "Cleaning cache directories"
|
||||
rm -rf ${CACHE_DIR}
|
||||
}
|
||||
|
||||
function build() {
|
||||
ARCH=$1
|
||||
|
||||
clean
|
||||
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 && cmake .. && make -j$(nproc)"
|
||||
|
||||
if [ ! -f build/simple_object_storage ]; then
|
||||
die "Failed to build $ARCH executable"
|
||||
fi
|
||||
|
||||
echo "Copying $ARCH executable to $EXE_DIR/simple_object_storage-$ARCH"
|
||||
cp build/simple_object_storage $EXE_DIR/simple_object_storage-$ARCH
|
||||
}
|
||||
|
||||
#--------------------------------
|
||||
# MAIN
|
||||
#--------------------------------
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
clean_cache
|
||||
if [ ! -f ${EXE_DIR}/simple_object_storage-linux-x86_64 ]; then
|
||||
die "x86_64 executable not found"
|
||||
fi
|
||||
|
||||
mkdir -p ${CACHE_DIR}
|
||||
mkdir -p ${EXE_DIR}
|
||||
if [ ! -f ${EXE_DIR}/simple_object_storage-linux-arm64 ]; then
|
||||
die "arm64 executable not found"
|
||||
fi
|
||||
|
||||
title "Building linux-arm64 executable"
|
||||
build linux-arm64 || die "Failed to build linux-arm64 executable"
|
||||
|
||||
title "Building linux-x86_64 executable"
|
||||
build linux-x86_64 || die "Failed to build linux-x86_64 executable"
|
||||
# use Docker architecture style
|
||||
cp ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64
|
||||
|
||||
echo "Compile completed successfully!"
|
||||
echo "amd64 executable: ./simple_object_storage-linux-amd64"
|
||||
echo "arm64 executable: ./simple_object_storage-linux-arm64"
|
||||
|
||||
@@ -95,7 +53,5 @@ docker buildx create --name mybuilder --use || true
|
||||
echo "Building multi-platform Docker image"
|
||||
docker buildx build --load -t simple-object-storage:latest --platform linux/amd64,linux/arm64 .
|
||||
|
||||
clean
|
||||
clean_cache
|
||||
|
||||
echo "Build completed successfully!"
|
||||
|
||||
|
@@ -67,11 +67,9 @@ build linux-arm64 || die "Failed to build linux-arm64 executable"
|
||||
|
||||
title "Building linux-x86_64 executable"
|
||||
build linux-x86_64 || die "Failed to build linux-x86_64 executable"
|
||||
# use Docker architecture style
|
||||
cp ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64
|
||||
|
||||
echo "Compile completed successfully!"
|
||||
echo "amd64 executable: ./simple_object_storage-linux-amd64"
|
||||
echo "x86_64 executable: ./simple_object_storage-linux-x86_64"
|
||||
echo "arm64 executable: ./simple_object_storage-linux-arm64"
|
||||
|
||||
echo "Build completed successfully!"
|
||||
|
Reference in New Issue
Block a user