Skip to content

Commit

Permalink
Add CI on Github Actions for Windows
Browse files Browse the repository at this point in the history
msys2 clang and llvm-mingw cross
  • Loading branch information
Andarwinux committed May 29, 2024
1 parent 9326ba7 commit eeeb8cf
Show file tree
Hide file tree
Showing 2 changed files with 258 additions and 0 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@

name: "MSYS2 Build & Test"

on:
# allow direct trigger
workflow_dispatch:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
COMMON_CMAKE_FLAGS: >
-DSLEEF_SHOW_CONFIG=1
-DSLEEF_BUILD_GNUABI_LIBS=ON
-DSLEEF_BUILD_DFT=ON
-DSLEEF_BUILD_QUAD=ON
-DSLEEF_BUILD_SCALAR_LIB=ON
-DSLEEF_BUILD_STATIC_TEST_BINS=ON
-DSLEEF_ENFORCE_TESTER=ON
-DSLEEF_ENFORCE_TESTER3=ON
jobs:
build-msys2:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
sys:
- clang64
#- mingw64
#- ucrt64
defaults:
run:
shell: msys2 {0}
name: build-msys2-${{ matrix.sys }}
steps:
- name: Disable autocrlf
shell: pwsh
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
git
pacboy: >-
cmake:p
ninja:p
cc:p
pkgconf:p
mpfr:p
openssl:p
- uses: actions/[email protected]
with:
persist-credentials: false

- name: Build msys2
shell: msys2 {0}
run: |
EXTRA_CMAKE_FLAGS="-DSLEEF_ENFORCE_SSE2=ON -DSLEEF_ENFORCE_SSE4=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX2=ON -DSLEEF_ENFORCE_AVX512F=ON -DSLEEF_ENFORCE_FMA4=ON"
cmake -S . -B _build-msys2 -GNinja \
-DCMAKE_INSTALL_PREFIX=$(pwd)/_install-msys2 \
${COMMON_CMAKE_FLAGS} \
${EXTRA_CMAKE_FLAGS} \
-DOPENSSL_EXTRA_LIBRARIES="-lws2_32 -lcrypt32"
cmake --build _build-msys2
cmake --install _build-msys2
- name: Upload build-msys2-${{ matrix.sys }} artifacts
uses: actions/upload-artifact@v3
with:
name: build-msys2-${{ matrix.sys }}
path: |
_build-*
_install-*
if: always()

test-msys2:
runs-on: windows-latest
needs: [build-msys2]
strategy:
fail-fast: false
matrix:
sys:
- clang64
#- mingw64
#- ucrt64
defaults:
run:
shell: msys2 {0}
name: test-msys2-${{ matrix.sys }}
steps:
- name: Disable autocrlf
shell: pwsh
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
git
pacboy: >-
cmake:p
ninja:p
cc:p
pkgconf:p
mpfr:p
openssl:p
- uses: actions/[email protected]
with:
persist-credentials: false

- name: Print host CPU info
run: |
wget -qO- https://download.sysinternals.com/files/Coreinfo.zip | bsdtar -xf-
./Coreinfo64.exe -accepteula
- name: Download build-msys2-${{ matrix.sys }} artifacts
uses: actions/download-artifact@v3
with:
name: build-msys2-${{ matrix.sys }}

- name: Test msys2
env:
CTEST_OUTPUT_ON_FAILURE: "TRUE"
run: |
cd _build-msys2
ctest -j$(nproc)
- name: Upload test-msys2 artifacts
uses: actions/upload-artifact@v3
with:
name: test-msys2
path: |
_build-msys2/Testing
if: always()
108 changes: 108 additions & 0 deletions .github/workflows/build-cross-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

name: "LLVM-MinGW Cross Build"

on:
# allow direct trigger
workflow_dispatch:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
COMMON_CMAKE_FLAGS: >
-DSLEEF_BUILD_TESTS=OFF
-DSLEEF_SHOW_CONFIG=1
-DSLEEF_BUILD_GNUABI_LIBS=ON
-DSLEEF_BUILD_INLINE_HEADERS=ON
-DSLEEF_BUILD_DFT=ON
-DSLEEF_BUILD_QUAD=ON
-DSLEEF_BUILD_SCALAR_LIB=ON
-DSLEEF_BUILD_STATIC_TEST_BINS=ON
jobs:
build-llvm-mingw:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [aarch64, x86_64]

name: build-${{ matrix.arch }}
steps:
- uses: actions/[email protected]
with:
persist-credentials: false

- name: Install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install -y -qq build-essential curl ninja-build libgmp-dev libmpfr-dev debootstrap 7zip
- name: Download llvm-mingw
uses: robinraju/release-downloader@main
with:
repository: "mstorsjo/llvm-mingw"
latest: true
extract: false
fileName: "llvm-mingw-*-ucrt-ubuntu-*-x86_64.tar.xz"

- name: Install llvm-mingw
run: |
tar -xaf llvm-mingw-*.tar.xz && rm llvm-mingw-*.tar.xz
mv llvm-mingw-* llvm-mingw
echo ORIGIN_PATH="$PATH" >> $GITHUB_ENV
echo PATH="$PWD/llvm-mingw/bin:$PATH" >> $GITHUB_ENV
- name: Build native
shell: bash -ex -o pipefail {0}
run: |
EXTRA_CMAKE_FLAGS="-DSLEEF_ENFORCE_SSE2=ON -DSLEEF_ENFORCE_SSE4=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX2=ON -DSLEEF_ENFORCE_AVX512F=ON -DSLEEF_ENFORCE_FMA4=ON"
PATH=$ORIGIN_PATH
cmake -S . -B _build-native -GNinja \
-DCMAKE_INSTALL_PREFIX=$(pwd)/_install-native \
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/toolchains/native-llvm.cmake \
${COMMON_CMAKE_FLAGS} \
${EXTRA_CMAKE_FLAGS}
cmake --build _build-native
cmake --install _build-native
- name: Fix _build-native permissions
run: |
chmod +x _build-native/bin/*
- name: Build llvm-mingw-${{ matrix.arch }}
shell: bash -ex -o pipefail {0}
run: |
EXTRA_CMAKE_FLAGS=""
if [[ ${{ matrix.arch }} = "aarch64" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS}"
elif [[ ${{ matrix.arch }} = "x86_64" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_SSE2=ON -DSLEEF_ENFORCE_SSE4=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX2=ON -DSLEEF_ENFORCE_AVX512F=ON -DSLEEF_ENFORCE_FMA4=ON"
fi
cmake -S . -B _build-${{ matrix.arch }} -GNinja \
-DCMAKE_INSTALL_PREFIX="$(pwd)/_install-${{ matrix.arch }}" \
-DCMAKE_SYSROOT="$(pwd)/llvm-mingw/${{ matrix.arch }}-w64-mingw32" \
-DNATIVE_BUILD_DIR="$(pwd)/_build-native" \
${COMMON_CMAKE_FLAGS} \
-DCMAKE_C_COMPILER=${{ matrix.arch }}-w64-mingw32-clang \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \
${EXTRA_CMAKE_FLAGS}
cmake --build _build-${{ matrix.arch }}
cmake --install _build-${{ matrix.arch }}
- name: Upload build-${{ matrix.arch }}-llvm-mingw artifacts
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.arch }}-llvm-mingw
path: |
_build-${{ matrix.arch }}
_install-${{ matrix.arch }}
if: always()

0 comments on commit eeeb8cf

Please sign in to comment.