Skip to content

Commit

Permalink
using matrix in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamonDinoia committed Jul 18, 2024
1 parent 326a427 commit 179b75b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 40 deletions.
66 changes: 26 additions & 40 deletions .github/workflows/cmake_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,50 @@ on:
types: [published]

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate matrix
id: generate_matrix
run: |
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
MATRIX=$(python3 ${{ github.workspace }}/.github/workflows/generate_cmake_matrix.py)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
cmake-ci:
runs-on: ${{ matrix.os }}
needs: prepare
strategy:
fail-fast: false
matrix:
os:
- windows-2022
- ubuntu-22.04
- macos-13
compiler:
- llvm
- gcc-12
# you can specify the version after `-` like `llvm-13.0.0`.
generator:
- "Ninja"
build_type:
- Release
finufft_static_linking:
- ON
include:
- os: "windows-2022"
compiler: "msvc"
generator: "Ninja"
build_type: "Release"
finufft_static_linking: "OFF"
exclude:
- os: "windows-2022"
compiler: "gcc-12"
generator: "Ninja"
build_type: "Release"
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v4

- name: Unlink gcc
if: runner.os == 'macOS'
run: |
brew unlink gcc
continue-on-error: true

- name: Checkout code
uses: actions/checkout@v4
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
cmake: false
ninja: false
vcpkg: false
cppcheck: false
clangtidy: false

- name: Install macOS dependencies
- name: Set min macOS version and install fftw
if: runner.os == 'macOS'
run: |
brew install fftw
- name: Install fftw
if: runner.os == 'linux'
run: |
sudo apt update
sudo apt install -y libfftw3-dev
- name: Configure Cmake
run: |
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DFINUFFT_BUILD_TESTS=ON -DFINUFFT_STATIC_LINKING=${{matrix.finufft_static_linking}}
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DFINUFFT_BUILD_TESTS=ON -DFINUFFT_STATIC_LINKING=${{matrix.finufft_static_linking}}
- name: Build
run: |
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/generate_cmake_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import json

matrix = {
"include": []
}

python_versions = ["3.8", "3.11"]
build_type = ["Release", "Debug"]
static_linking = ["On", "Off"]
combinations = {
"ubuntu-22.04": {
"compiler": ["llvm", "gcc"],
"arch_flags": ["-march=native", "-march=x86-64"]
},
"windows-2022": {
"compiler": ["msvc", "llvm"],
"arch_flags": ["/arch:AVX2", "/arch:SSE2"]
},
"macos-13": {
"compiler": ["llvm", "gcc-14"],
"arch_flags": ["-march=native", "-march=x86-64"]
}
}

for platform in combinations.keys():
for python_version in python_versions:
for compiler in combinations[platform]["compiler"]:
for arch_flag in combinations[platform]["arch_flags"]:
for linking in static_linking:
for build in build_type:
matrix["include"].append({
"os": platform,
"python-version": python_version,
"compiler": compiler,
"arch_flags": arch_flag,
"finufft_static_linking": linking,
"build_type": build
})
json_str = json.dumps(matrix, ensure_ascii=False)
print(json_str)

0 comments on commit 179b75b

Please sign in to comment.