From b2d0a65dd5570b76170c6a99e1062e1d8c6077c1 Mon Sep 17 00:00:00 2001 From: Dirk Vanden Boer Date: Fri, 30 Aug 2024 11:27:37 +0200 Subject: [PATCH] Support musl docker build --- .dockerignore | 9 +++++++++ build.py | 2 ++ dist/CMakeLists.txt | 1 + docker/MuslStaticBuild.Dockerfile | 10 ++++++++++ justfile | 11 +++++++++++ 5 files changed, 33 insertions(+) create mode 100644 .dockerignore create mode 100644 docker/MuslStaticBuild.Dockerfile create mode 100644 justfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7f393b8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +/build/ +/docker/ +/deps/vcpkg/buildtrees +/deps/vcpkg/packages +/vcpkgs* +/.git +/.cache +.DS_Store +justfile \ No newline at end of file diff --git a/build.py b/build.py index 31fc709..2a7cb6f 100755 --- a/build.py +++ b/build.py @@ -52,6 +52,7 @@ targets=["package"], build_config=args.build_config, run_tests_after_build=args.run_tests, + git_hash=args.git_hash, ) else: vcpkg.build_project( @@ -62,6 +63,7 @@ build_name=build_dir, build_config=args.build_config, run_tests_after_build=args.run_tests, + git_hash=args.git_hash, ) except KeyboardInterrupt: print("\nInterrupted") diff --git a/dist/CMakeLists.txt b/dist/CMakeLists.txt index 1e4c576..2fc6b49 100644 --- a/dist/CMakeLists.txt +++ b/dist/CMakeLists.txt @@ -8,6 +8,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "E-MAP emission mapper") set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME}) set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages") set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}) set(CPACK_SOURCE_GENERATOR "TGZ;TZ") set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}) diff --git a/docker/MuslStaticBuild.Dockerfile b/docker/MuslStaticBuild.Dockerfile new file mode 100644 index 0000000..6e851ff --- /dev/null +++ b/docker/MuslStaticBuild.Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:3.20.2 AS builder + +ARG GIT_HASH=dev +WORKDIR /project +RUN apk add bash linux-headers gcc g++ curl zip unzip tar git python3 cmake ninja-is-really-ninja make automake autoconf autoconf-archive libtool pkgconfig +RUN echo insecure >> $HOME/.curlrc + +COPY . . +RUN python3 bootstrap.py --triplet=x64-linux-static +RUN python3 build.py --triplet=x64-linux-static --dist --git-hash=${GIT_HASH} diff --git a/justfile b/justfile new file mode 100644 index 0000000..fb98e42 --- /dev/null +++ b/justfile @@ -0,0 +1,11 @@ +git_hash := `git rev-parse HEAD` + +cleangitcondition: + git diff --exit-code + +buildmusl: + echo "Building static musl binary: {{git_hash}}" + docker build --build-arg="GIT_HASH={{git_hash}}" -f ./docker/MuslStaticBuild.Dockerfile -t emapmuslbuild . + docker create --name extract emapmuslbuild + docker cp extract:/project/build/emap-release-x64-linux-static-Release-dist/packages ./build + docker rm extract