From 34ef1157a65987d53a18a32dbdd04046c263f7e5 Mon Sep 17 00:00:00 2001 From: WillLillis Date: Mon, 20 Jan 2025 21:56:00 -0500 Subject: [PATCH] feat(ci): build libraries on windows x64 with mingw --- .github/workflows/build.yml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b39e329..3381196a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -139,6 +139,62 @@ jobs: [[ -n $runner ]] && printf 'CROSS_RUNNER=%s\n' "$runner" >> $GITHUB_ENV fi + # TODO: Remove RUSTFLAGS="--cap-lints allow" once we use a wasmtime release that addresses + # the `mismatched-lifetime-syntaxes` lint + - name: Build wasmtime library (Windows x64 MSYS2) + if: ${{ !matrix.use-cross && contains(matrix.features, 'wasm') && matrix.platform == 'windows-x64' }} + run: | + mkdir -p target + WASMTIME_VERSION=$(cargo metadata --format-version=1 --locked --features wasm | \ + jq -r '.packages[] | select(.name == "wasmtime-c-api-impl") | .version') + curl -LSs "$WASMTIME_REPO/archive/refs/tags/v${WASMTIME_VERSION}.tar.gz" | tar xzf - -C target + cd target/wasmtime-${WASMTIME_VERSION} + cmake -S crates/c-api -B target/c-api \ + -DCMAKE_INSTALL_PREFIX="$PWD/artifacts" \ + -DWASMTIME_DISABLE_ALL_FEATURES=ON \ + -DWASMTIME_FEATURE_CRANELIFT=ON \ + -DWASMTIME_TARGET='x86_64-pc-windows-gnu' + cmake --build target/c-api && cmake --install target/c-api + printf 'CMAKE_PREFIX_PATH=%s\n' "$PWD/artifacts" >> $GITHUB_ENV + env: + WASMTIME_REPO: https://github.com/bytecodealliance/wasmtime + RUSTFLAGS: "--cap-lints allow" + + - name: Install MinGW and Clang (Windows x64 MSYS2) + if: ${{ matrix.platform == 'windows-x64' }} + uses: msys2/setup-msys2@v2 + with: + update: true + install: | + mingw-w64-x86_64-toolchain + mingw-w64-x86_64-clang + mingw-w64-x86_64-make + mingw-w64-x86_64-cmake + + - name: Build C library (Windows x64 MSYS2 CMake) + if: ${{ matrix.platform == 'windows-x64' }} + shell: msys2 {0} + run: | + cmake -G Ninja -S lib -B build/static \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ + -DTREE_SITTER_FEATURE_WASM=$WASM \ + -DCMAKE_C_COMPILER=clang + cmake --build build/static + rm -rf build/static + + cmake -G Ninja -S lib -B build/shared \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ + -DTREE_SITTER_FEATURE_WASM=$WASM \ + -DCMAKE_C_COMPILER=clang + cmake --build build/shared + rm -rf build/shared + env: + WASM: ${{ contains(matrix.features, 'wasm') && 'ON' || 'OFF' }} + # TODO: Remove RUSTFLAGS="--cap-lints allow" once we use a wasmtime release that addresses # the `mismatched-lifetime-syntaxes` lint - name: Build wasmtime library