diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bbbdbb9a..2368e123 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,17 +51,40 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + - os: macos-latest + - os: windows-latest + - os: windows-latest + target: x86_64-pc-windows-gnu defaults: run: working-directory: rust + shell: bash steps: - uses: actions/checkout@v2 with: submodules: recursive + - run: rustup target add ${{ matrix.target }} + if: matrix.target != '' + - run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV + if: matrix.target != '' + - name: Upgrade MinGW package + # In https://github.com/bytecodealliance/wasmtime/pull/4003 we discovered that the ittapi C + # code uses the uncommon `strnlen_s` function. On older versions of MinGW (GitHub runners + # currently come with v8.1.0 pre-installed), this function was not available. Since v8.1.0, + # other versions have been published; this re-installs MinGW with a recent version which + # includes `strnlen_s`. This block can be removed if/when MinGW is upgraded in all Windows + # GitHub runners: https://github.com/actions/virtual-environments/issues/5530. + if: matrix.target == 'x86_64-pc-windows-gnu' + run: | + choco uninstall mingw + choco install mingw --version 11.2.0 --force - name: Build Rust crate run: cargo build - name: Test Rust crate run: cargo test - name: Check crates are publishable - run: scripts/verify-publish.sh + # The Windows CI transforms the `c-library` symlink into a real directory, modifying the Git + # state, so we ignore these changes with `--allow-dirty` here. + run: scripts/verify-publish.sh --allow-dirty diff --git a/rust/ittapi-sys/build.rs b/rust/ittapi-sys/build.rs index eab9068e..c20049f1 100644 --- a/rust/ittapi-sys/build.rs +++ b/rust/ittapi-sys/build.rs @@ -1,5 +1,5 @@ //! Build the `ittapi` C library in the parent directory. The `cc` configuration here should match -//! that of the parent directories `CMakeLists.txt` (TODO: keep these in sync, see [#36]). +//! that of the parent directory's `CMakeLists.txt` (TODO: keep these in sync, see [#36]). //! //! [#36]: https://github.com/intel/ittapi/issues/36 diff --git a/rust/scripts/verify-publish.sh b/rust/scripts/verify-publish.sh index c15130ef..cdbc07d0 100755 --- a/rust/scripts/verify-publish.sh +++ b/rust/scripts/verify-publish.sh @@ -2,6 +2,8 @@ # Check that the Rust crates can all be packaged up for publication. This cannot use use `cargo # publish --dry-run` because of the dependency between ittapi and ittapi-sys. set -e + +SCRIPT_ARGS=${@:1} SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) pushd $SCRIPT_DIR @@ -19,7 +21,7 @@ directory = "vendor" EOT # Package up ittapi-sys and place it in the vendor directory. -cargo package --manifest-path ../ittapi-sys/Cargo.toml +cargo package --manifest-path ../ittapi-sys/Cargo.toml $SCRIPT_ARGS pushd vendor tar xf ../../target/package/ittapi-sys-0.*.crate ITTAPI_SYS_DIR=$(echo ittapi-sys-0.*) @@ -27,5 +29,5 @@ echo '{"files":{}}' > $ITTAPI_SYS_DIR/.cargo-checksum.json popd # Package up ittapi. -cargo package --manifest-path ../ittapi/Cargo.toml +cargo package --manifest-path ../ittapi/Cargo.toml $SCRIPT_ARGS popd