diff --git a/Dockerfile b/Dockerfile.dropshell-build similarity index 74% rename from Dockerfile rename to Dockerfile.dropshell-build index ffa772e..c90b346 100644 --- a/Dockerfile +++ b/Dockerfile.dropshell-build @@ -1,8 +1,6 @@ FROM --platform=$BUILDPLATFORM alpine:latest AS builder -# Add build arguments for platform -ARG TARGETPLATFORM -ARG BUILDPLATFORM +ARG PROJECT # Install build dependencies RUN apk add --no-cache \ @@ -16,7 +14,8 @@ RUN apk add --no-cache \ g++ \ ninja \ linux-headers \ - mold + mold \ + zlib-static # Set working directory WORKDIR /build @@ -29,11 +28,17 @@ RUN mkdir -p build_static && \ cmake -G Ninja -B build_static -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXE_LINKER_FLAGS="-static" \ -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \ + -DZLIB_BUILD_SHARED=OFF \ + -DZLIB_BUILD_STATIC=ON \ -DBUILD_SHARED_LIBS=OFF \ + -DPROJECT_NAME="${PROJECT}" \ ${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE} RUN cmake --build build_static # Final stage that only contains the binary -FROM scratch AS $PROJECT -COPY --from=builder /build/build_static/$PROJECT /$PROJECT +FROM scratch AS project + +ARG PROJECT + +COPY --from=builder /build/build_static/${PROJECT} /${PROJECT} diff --git a/build.sh b/build.sh index 67e8be8..e72c0a1 100755 --- a/build.sh +++ b/build.sh @@ -3,9 +3,19 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +PROJECT="ipdemo" # Define your project name here -rm -rf "${SCRIPT_DIR}/src/build" -rm -rf "${SCRIPT_DIR}/src/build.*" +mkdir -p "${SCRIPT_DIR}/output" -docker build -t gitea.jde.nz/public/dropshell-build:test -f "${SCRIPT_DIR}/Dockerfile" "${SCRIPT_DIR}" +export CMAKE_BUILD_TYPE="Release" + +rm -rf "${SCRIPT_DIR}/output" +mkdir -p "${SCRIPT_DIR}/output" + +docker build \ + -t "gitea.jde.nz/public/${PROJECT}-build:latest" \ + -f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \ + --build-arg PROJECT="${PROJECT}" \ + --output "${SCRIPT_DIR}/output" \ + "${SCRIPT_DIR}/${PROJECT}" diff --git a/ipdemo/CMakeLists.txt b/ipdemo/CMakeLists.txt index 09a6a91..3dd6fe7 100644 --- a/ipdemo/CMakeLists.txt +++ b/ipdemo/CMakeLists.txt @@ -6,8 +6,12 @@ execute_process( ) cmake_minimum_required(VERSION 3.10) -get_filename_component(PROJECT_EXE_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME) -project(${PROJECT_EXE_NAME} VERSION ${PROJECT_VERSION} LANGUAGES CXX) +if(NOT DEFINED PROJECT_NAME) + message(FATAL_ERROR "PROJECT_NAME is not defined. Pass it via -DPROJECT_NAME=") +endif() + +project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES CXX) +set(PROJECT_EXE_NAME ${PROJECT_NAME}) # Force static linking globally set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") @@ -64,6 +68,32 @@ target_include_directories(${PROJECT_EXE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) + +# Configure libassert +include(FetchContent) +FetchContent_Declare( + libassert + GIT_REPOSITORY https://github.com/jeremy-rifkin/libassert.git + GIT_TAG v2.1.5 +) +FetchContent_MakeAvailable(libassert) + +# Add cpptrace +FetchContent_Declare( + cpptrace + GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git + GIT_TAG v0.8.3 +) +FetchContent_MakeAvailable(cpptrace) + +# Add nlohmann/json +FetchContent_Declare( + nlohmann_json + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG v3.12.0 +) +FetchContent_MakeAvailable(nlohmann_json) + # Link libraries target_link_libraries(${PROJECT_EXE_NAME} PRIVATE libassert::assert diff --git a/musl/aarch64-linux-musl-cross.tgz b/musl/aarch64-linux-musl-cross.tgz deleted file mode 100644 index e689db7..0000000 Binary files a/musl/aarch64-linux-musl-cross.tgz and /dev/null differ diff --git a/musl/aarch64-linux-musl-native.tgz b/musl/aarch64-linux-musl-native.tgz deleted file mode 100644 index 6709fd5..0000000 Binary files a/musl/aarch64-linux-musl-native.tgz and /dev/null differ diff --git a/musl/i686-linux-musl-native.tgz b/musl/i686-linux-musl-native.tgz deleted file mode 100644 index aca3e49..0000000 Binary files a/musl/i686-linux-musl-native.tgz and /dev/null differ diff --git a/musl/upload.sh b/musl/upload.sh deleted file mode 100755 index 90e5418..0000000 --- a/musl/upload.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -euo pipefail -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" - -function upload_file() { - local file="$1" - local server="getbin.xyz" - local tag="latest" - local name; - name=$(basename "${file}") - - # upload the file to the server - echo "Uploading ${file} to the server" - sos upload "${server}" "${file}" "${name}:${tag}" -} - - -if ! command -v sos &> /dev/null ; then - echo "sos could not be found" - exit 1 -fi - -# find all .tgz in this directory -for file in "${SCRIPT_DIR}"/*.tgz; do - # upload the file to the server - echo "Uploading ${file} to the server" - upload_file "${file}" -done diff --git a/musl/x86_64-linux-musl-cross.tgz b/musl/x86_64-linux-musl-cross.tgz deleted file mode 100644 index 8040dac..0000000 Binary files a/musl/x86_64-linux-musl-cross.tgz and /dev/null differ diff --git a/musl/x86_64-linux-musl-native.tgz b/musl/x86_64-linux-musl-native.tgz deleted file mode 100644 index f2e321c..0000000 Binary files a/musl/x86_64-linux-musl-native.tgz and /dev/null differ diff --git a/musl/x86_64-w64-mingw32-cross.tgz b/musl/x86_64-w64-mingw32-cross.tgz deleted file mode 100644 index c87842a..0000000 Binary files a/musl/x86_64-w64-mingw32-cross.tgz and /dev/null differ diff --git a/publish.sh b/publish.sh index 76ea0c8..69f31c5 100755 --- a/publish.sh +++ b/publish.sh @@ -7,26 +7,12 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # download the sos binary SOS="${SCRIPT_DIR}/temp/sos" mkdir -p "${SCRIPT_DIR}/temp" +trap 'rm -rf "${SCRIPT_DIR}/temp"' EXIT curl -L -o "${SOS}" https://getbin.xyz/sos chmod +x "${SOS}" - # upload the dropshell-build script -"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/src/dropshell-build" "dropshell-build:latest" +"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/Dockerfile.dropshell-build" "Dockerfile.dropshell-build:latest" -# upload the install requirements script -"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/src/dropshell-build-install-requirements" "dropshell-build-install-requirements:latest" - - -# tag and push the dropshell-build image -echo "Tagging and pushing the dropshell-build image" - -docker tag gitea.jde.nz/public/dropshell-build:test gitea.jde.nz/public/dropshell-build:latest - -docker push gitea.jde.nz/public/dropshell-build:latest - - -# clean up -rm -rf "${SCRIPT_DIR}/temp" echo "Done" \ No newline at end of file diff --git a/test.sh b/test.sh index 89b38a5..c41a1e8 100755 --- a/test.sh +++ b/test.sh @@ -4,13 +4,13 @@ set -euo pipefail SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -echo "Testing dropshell-build" +echo "Testing" -rm -rf "${SCRIPT_DIR}/ipdemo/build" +"${SCRIPT_DIR}/build.sh" -DROPSHELL_BUILD_TAG="test" "${SCRIPT_DIR}/src/dropshell-build" -r -m "${SCRIPT_DIR}/ipdemo" +[ -f "${SCRIPT_DIR}/output/ipdemo" ] || { echo "ipdemo binary not found"; exit 1; } -"${SCRIPT_DIR}/ipdemo/output/ipdemo.x86_64" +"${SCRIPT_DIR}/output/ipdemo"