diff --git a/.gitignore b/.gitignore index dd5bfda..d3bef0b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ CMakeFiles/ cmake_install.cmake Makefile *.cmake +cache/ +exe/ # Compiled Object files *.slo @@ -31,9 +33,7 @@ Makefile *.lib # Executables -simple_object_storage -simple_object_storage-x86_64 -simple_object_storage-arm64 +simple_object_storage-* # IDE specific files .vscode/ diff --git a/compile.sh b/compile.sh index 4ea0ac5..907cd66 100755 --- a/compile.sh +++ b/compile.sh @@ -28,23 +28,10 @@ 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 + BUILD_DIR="${SCRIPT_DIR}/build-${ARCH}" mkdir -p ${BUILD_DIR} DOCKCROSS_SCRIPT="${CACHE_DIR}/dockcross-${ARCH}" @@ -57,14 +44,14 @@ function build() { echo "Building $ARCH executable" cd "${SCRIPT_DIR}" - "${DOCKCROSS_SCRIPT}" bash -c "cd build && cmake .. && make -j$(nproc)" + "${DOCKCROSS_SCRIPT}" bash -c "cd ${BUILD_DIR} && cmake .. && make -j$(nproc)" - if [ ! -f build/simple_object_storage ]; then + 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/simple_object_storage $EXE_DIR/simple_object_storage-$ARCH + cp ${BUILD_DIR}/simple_object_storage $EXE_DIR/simple_object_storage-$ARCH } #-------------------------------- @@ -72,8 +59,6 @@ function build() { #-------------------------------- cd $SCRIPT_DIR -clean_cache - mkdir -p ${CACHE_DIR} mkdir -p ${EXE_DIR} @@ -89,13 +74,5 @@ echo "Compile completed successfully!" echo "amd64 executable: ./simple_object_storage-linux-amd64" echo "arm64 executable: ./simple_object_storage-linux-arm64" -echo "Setting up Docker BuildX" -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!" +