diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 506e48e..3abe60d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,9 @@ env: jobs: build-linux-x86_64: name: Build Linux (GCC x86_64) - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + container: + image: alpine:3.17 env: LLVM_MAJOR: 15 @@ -26,34 +28,20 @@ jobs: - name: Install dependencies run: | - sudo apt-get -y update - sudo apt-get -y install cmake ninja-build llvm-$LLVM_MAJOR-dev libclang-$LLVM_MAJOR-dev clang-$LLVM_MAJOR zlib1g-dev - - # setup buildcache - curl -LSfs https://github.com/mbitsnbites/buildcache/releases/download/$BUILDCACHE_VERSION/buildcache-linux.tar.gz | tar xz -C "$RUNNER_WORKSPACE" - echo "$RUNNER_WORKSPACE"/buildcache/bin >> $GITHUB_PATH - - - name: Restore buildcache - uses: actions/cache@v2 - with: - path: ${{env.BUILDCACHE_DIR}} - key: buildcache-ubuntu-20.04-x86_64 + apk add --no-cache git cmake ninja clang-dev clang-static llvm-dev llvm-static musl-dev \ + gcc g++ libxml2-dev libxml2-static zlib-dev zlib-static - name: Configure CMake run: | cmake -B build . -GNinja \ -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \ - -DATDNA_DYNAMIC_LLVM=OFF \ - -DClang_DIR:PATH=/usr/lib/cmake/clang-$LLVM_MAJOR \ - -DCMAKE_C_COMPILER_LAUNCHER:STRING=buildcache \ - -DCMAKE_CXX_COMPILER_LAUNCHER:STRING=buildcache + -DATDNA_DYNAMIC_LLVM:BOOL=OFF \ + -DATDNA_STATIC:BOOL=ON \ + -DCMAKE_CXX_FLAGS:STRING="-I/usr/lib/llvm15/include -Dstat64=stat" - name: Build run: cmake --build build --target package --verbose - - name: Print buildcache stats - run: buildcache -s - - name: Test working-directory: build run: ./atdna-test @@ -82,18 +70,19 @@ jobs: name: Build & test with: arch: aarch64 - distro: ubuntu20.04 + base_image: --platform=linux/arm64/v8 alpine:3.17 githubToken: ${{github.token}} dockerRunArgs: | --volume "${PWD}:/workspace" install: | - apt-get -y update - apt-get -y install build-essential cmake ninja-build llvm-$LLVM_MAJOR-dev libclang-$LLVM_MAJOR-dev clang-$LLVM_MAJOR zlib1g-dev + apk add --no-cache git cmake ninja clang-dev clang-static llvm-dev llvm-static musl-dev \ + gcc g++ libxml2-dev libxml2-static zlib-dev zlib-static run: | cmake -B build . -GNinja \ -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \ -DATDNA_DYNAMIC_LLVM:BOOL=OFF \ - -DClang_DIR:PATH=/usr/lib/cmake/clang-$LLVM_MAJOR + -DATDNA_STATIC:BOOL=ON \ + -DCMAKE_CXX_FLAGS:STRING="-I/usr/lib/llvm15/include -Dstat64=stat" cmake --build build --target package --verbose build/atdna-test diff --git a/CMakeLists.txt b/CMakeLists.txt index 354bddc..8444742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,11 @@ endif() project(athena VERSION ${ATHENA_VERSION} LANGUAGES C CXX) +if (ATDNA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + add_link_options(-static) +endif () + if (MSVC) # Shaddup MSVC add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1 diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index af2e83a..e1e6084 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -73,6 +73,13 @@ else() list(TRANSFORM target_dependencies REPLACE ".*diaguids.*" "${DIASDK_GUIDS_LIBRARY}") set_property(TARGET LLVMDebugInfoPDB PROPERTY INTERFACE_LINK_LIBRARIES "${target_dependencies}") endif () + + # Allow static linking against zstd + if (ATDNA_STATIC) + get_target_property(target_dependencies LLVMSupport INTERFACE_LINK_LIBRARIES) + list(TRANSFORM target_dependencies REPLACE "zstd::libzstd_shared" "zstd::libzstd_static") + set_property(TARGET LLVMSupport PROPERTY INTERFACE_LINK_LIBRARIES "${target_dependencies}") + endif () endif() # Offer the user the choice of overriding the installation directories