Skip to content

Commit

Permalink
Switch the build system to CMake
Browse files Browse the repository at this point in the history
By popular request, use CMake instead of a plain Makefile.

Some parts of this commit are based on the pull request
ebiggers#101, which was written by
Benjamin Sergeant <[email protected]> and
SpaceIm <[email protected]>.
  • Loading branch information
ebiggers committed Sep 29, 2022
1 parent 18d6cc2 commit 03fba38
Show file tree
Hide file tree
Showing 32 changed files with 620 additions and 982 deletions.
6 changes: 4 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ task:
matrix:
- image_family: freebsd-12-3
- image_family: freebsd-13-0
install_script: pkg install -y gmake
install_script: pkg install -y cmake
script:
- gmake check
- cmake -B build -DLIBDEFLATE_BUILD_TESTS=1
- cmake --build build
- ctest --test-dir build
104 changes: 0 additions & 104 deletions .github/workflows/android.yml

This file was deleted.

74 changes: 60 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: CI
on: [pull_request]
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS

jobs:
x86_64-build-and-test:
Expand All @@ -13,6 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.compiler }}
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v2
- name: Install dependencies
Expand All @@ -28,6 +27,8 @@ jobs:
arch: [armv6, armv7, aarch64, s390x, ppc64le]
compiler: [gcc, clang]
runs-on: ubuntu-latest
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v2
- uses: uraimo/[email protected]
Expand All @@ -37,7 +38,7 @@ jobs:
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y build-essential clang llvm libz-dev valgrind
apt-get install -y build-essential cmake clang llvm libz-dev valgrind
run: |
# Valgrind and ASAN crash on at least s390x, ppc64le, and aarch64
# here. (It's probably something related to the QEMU user-mode
Expand All @@ -52,9 +53,11 @@ jobs:
export SKIP_FREESTANDING=1
;;
aarch64)
# "ldd: exited with unknown exit code (139)"
if [ ${{ matrix.compiler }} = clang ]; then
# "ldd: exited with unknown exit code (139)"
export SKIP_SHARED_LIB=1
# "archive has no index; run ranlib to add one"
export SKIP_CFI=1
fi
;;
esac
Expand All @@ -65,9 +68,13 @@ jobs:
macos-build-and-test:
name: Build and test (macOS)
runs-on: macos-latest
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v2
- run: make all check
- run: cmake -B build -DLIBDEFLATE_BUILD_TESTS=1
- run: cmake --build build --verbose
- run: ctest --test-dir build

windows-msys2-build-and-test:
name: Build and test (Windows, MSYS2, ${{matrix.sys}})
Expand All @@ -80,22 +87,32 @@ jobs:
defaults:
run:
shell: msys2 {0}
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
update: true
install: make mingw-w64-${{matrix.env}}-cc mingw-w64-${{matrix.env}}-zlib
- run: make all check
install: >
make
mingw-w64-${{matrix.env}}-cc
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-ninja
mingw-w64-${{matrix.env}}-zlib
- run: cmake -B build -G Ninja -DLIBDEFLATE_BUILD_TESTS=1
- run: cmake --build build --verbose
- run: ctest --test-dir build

windows-msvc-build:
name: Build (Windows, Visual Studio)
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1
- run: nmake /f Makefile.msc
- uses: microsoft/[email protected]
- run: cmake -B build -G "Visual Studio 17 2022"
- run: cmake --build build --verbose

run-clang-static-analyzer:
name: Run clang static analyzer
Expand All @@ -106,8 +123,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y clang-tools
- name: Run clang static analyzer
run: make scan-build
- run: scan-build cmake -B build -DLIBDEFLATE_BUILD_TESTS=1
- run: scan-build cmake --build build --verbose

run-shellcheck:
name: Run shellcheck
Expand All @@ -119,18 +136,47 @@ jobs:
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Run shellcheck
run: make shellcheck
run: shellcheck scripts/*.sh

cross-compile-for-windows:
name: Cross compile for Windows
runs-on: ubuntu-latest
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libz-mingw-w64-dev
# Unfortunately Ubuntu doesn't have {i686,x86_64}-w64-mingw32-cmake like
# some distros have, so we have to provide our own toolchain files here.
- name: 32-bit build
run: make CC=i686-w64-mingw32-gcc all test_programs
run: |
scripts/cmake-helper.sh -DLIBDEFLATE_BUILD_TESTS=1 \
-DCMAKE_TOOLCHAIN_FILE=scripts/toolchain-i686-w64-mingw32.cmake
cmake --build build --verbose
- name: 64-bit build
run: make CC=x86_64-w64-mingw32-gcc all test_programs
run: |
scripts/cmake-helper.sh -DLIBDEFLATE_BUILD_TESTS=1 \
-DCMAKE_TOOLCHAIN_FILE=scripts/toolchain-x86_64-w64-mingw32.cmake
cmake --build build --verbose
cross-compile-for-android:
name: Cross compile for ${{matrix.abi}} Android on ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macos-latest]
abi: [armeabi-v7a, arm64-v8a, x86, x86_64]
runs-on: ${{matrix.os}}
env:
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS
steps:
- uses: actions/checkout@v2
- run: |
scripts/cmake-helper.sh \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_LATEST_HOME"/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=${{matrix.abi}} \
-DANDROID_PLATFORM=28 \
-DLIBDEFLATE_BUILD_TESTS=1
cmake --build build --verbose
22 changes: 2 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
*.a
*.def
*.dll
*.dllobj
*.dylib
*.exe
*.exp
*.lib
*.o
*.obj
*.so
*.so.*
/.build-config
/programs/config.h
/benchmark
/checksum
/gzip
/gunzip
/test_*
tags
/build*
cscope*
tags
Loading

0 comments on commit 03fba38

Please sign in to comment.