diff --git a/.github/actions/setup_test/action.yaml b/.github/actions/setup_test/action.yaml deleted file mode 100644 index 4406e886..00000000 --- a/.github/actions/setup_test/action.yaml +++ /dev/null @@ -1,184 +0,0 @@ -name: Setup Corrosion Tests -description: "Internal helper action to setup the Environment for Corrosions tests" -inputs: - target_arch: - required: true - description: CMake target architecture - abi: - required: false - description: msvc, gnu or darwin - default: default - cmake: - required: true - description: Cmake version - rust: - required: true - description: Rust version - generator: - required: true - description: CMake Generator (e.g Ninja) - build_dir: - required: true - description: Path of the CMake build directory - configure_params: - required: false - description: Additional parameters to pass to CMake configure step - install_path: - required: false - description: CMake install prefix - default: "" - compiler: - required: false - description: Compiler to use. Valid options are clang, gcc, cl, default, or an empty string. - default: "default" - -runs: - using: composite - steps: - - name: Cache Cargo registry - id: cache-registry - uses: actions/cache@v3 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry - - name: Determine Rust OS - id: determine_rust_os - shell: bash - run: | - if [ "${{ runner.os }}" == "Windows" ]; then - echo "os=pc-windows" >> $GITHUB_OUTPUT - echo "host_abi=msvc" >> $GITHUB_OUTPUT - elif [ "${{ runner.os }}" == "Linux" ]; then - echo "os=unknown-linux" >> $GITHUB_OUTPUT - echo "host_abi=gnu" >> $GITHUB_OUTPUT - elif [ "${{ runner.os }}" == "macOS" ]; then - echo "os=apple" >> $GITHUB_OUTPUT - echo "host_abi=darwin" >> $GITHUB_OUTPUT - fi - - name: Determine Rust ABI - id: determine_abi - shell: bash - run: | - if [[ ! ( -z "${{ inputs.abi }}" || "${{ inputs.abi }}" == "default" ) ]]; then - echo "abi=${{ inputs.abi }}" >> $GITHUB_OUTPUT - elif [ "${{ runner.os }}" == "Linux" ]; then - echo "abi=gnu" >> $GITHUB_OUTPUT - elif [ "${{ runner.os }}" == "macOS" ]; then - echo "abi=darwin" >> $GITHUB_OUTPUT - else - echo "abi=msvc" >> $GITHUB_OUTPUT - fi - - name: Determine if Cross-compiling - id: determine_cross_compile - shell: bash - run: | - # For now it is safe to assume that all github runners are x86_64 - if [[ "${{ inputs.target_arch }}" != "x86_64" ]]; then - echo "Cross-Compiling to ${{ inputs.target_arch }}" - if [[ "${{ runner.os }}" == "macOS" ]]; then - echo "system_name=-DCMAKE_SYSTEM_NAME=Darwin" >> $GITHUB_OUTPUT - else - # Either `Linux` or `Windows` - echo "system_name=-DCMAKE_SYSTEM_NAME=${{ runner.os }}" >> $GITHUB_OUTPUT - fi - fi - - name: Pick Compiler - id: pick_compiler - shell: bash - run: > - ./.github/scripts/determine_compiler.sh - "${{ inputs.compiler }}" - "${{ runner.os }}" - "${{ steps.determine_abi.outputs.abi }}" - "${{steps.determine_cross_compile.outputs.system_name}}" - "${{inputs.target_arch}}" - - name: Pick Generator - id: pick_generator - shell: bash - run: | - if [ "${{ inputs.generator }}" == "ninja" ]; then - echo "generator=-GNinja" >> $GITHUB_OUTPUT - elif [ "${{ inputs.generator }}" == "ninja-multiconfig" ];then - echo "generator=-GNinja Multi-Config" >> $GITHUB_OUTPUT - fi - - name: Arch Flags - id: arch_flags - shell: bash - run: | # Cross-compiling is currently only supported on Windows+MSVC with the default generator - if [ "${{ runner.os }}" == "Windows" ]; then - if [ "${{inputs.generator}}" == "default" ]; then - if [ "${{ inputs.target_arch }}" == "x86_64" ]; then - echo "msvc=amd64" >> $GITHUB_OUTPUT - echo "cmake=-Ax64" >> $GITHUB_OUTPUT - elif [ "${{ inputs.target_arch }}" == "i686" ]; then - echo "msvc=amd64_x86" >> $GITHUB_OUTPUT - echo "cmake=-AWin32" >> $GITHUB_OUTPUT - elif [ "${{ inputs.target_arch }}" == "aarch64" ]; then - echo "msvc=amd64_arm64" >> $GITHUB_OUTPUT - echo "cmake=-AARM64" >> $GITHUB_OUTPUT - fi - elif [ "${{inputs.generator}}" == "ninja" ]; then - # We don't do cross-compiling builds with Ninja - # Todo: Why not (cross-compile)? - echo "msvc=amd64" >> $GITHUB_OUTPUT - fi - elif [ "${{ runner.os }}" == "Linux" ]; then - echo "cmake=-DRust_CARGO_TARGET=${{inputs.target_arch}}-${{steps.determine_rust_os.outputs.os}}-${{steps.determine_abi.outputs.abi}}" >> $GITHUB_OUTPUT - fi - - name: Determine Install Prefix - id: install_prefix - shell: bash - run: | - if [ ! -z "${{ inputs.install_path }}" ]; then - echo "install_path=-DCMAKE_INSTALL_PREFIX=${{ inputs.install_path }}" >> $GITHUB_OUTPUT - fi - - name: Setup MSVC Development Environment - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: ${{ steps.arch_flags.outputs.msvc }} - if: ${{ 'msvc' == steps.determine_abi.outputs.abi }} - - name: Install CMake - uses: corrosion-rs/install-cmake@v2 - with: - cmake: ${{inputs.cmake}} - ninja: 1.10.0 - - name: Install Rust - id: install_rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{inputs.rust}} - targets: ${{inputs.target_arch}}-${{steps.determine_rust_os.outputs.os}}-${{steps.determine_abi.outputs.abi}} - - name: Install Cross Compiler - shell: bash - run: | - if [[ "${{ inputs.target_arch }}" != 'x86_64' ]]; then - echo "::group::apt-install" - sudo apt-get update - sudo apt-get install -y g++-$(echo "${{inputs.target_arch}}" | tr _ -)-linux-gnu - echo "::endgroup::" - fi - if: ${{ 'Linux' == runner.os }} - - name: Determine Configure Shell - id: configure_shell - shell: bash - run: | - if [ "${{ runner.os }}" == "Windows" ]; then - echo "shell=pwsh" >> $GITHUB_OUTPUT - else - echo "shell=bash" >> $GITHUB_OUTPUT - fi - - name: Configure - shell: ${{steps.configure_shell.outputs.shell}} - run: > - cmake - "-S." - "-B${{inputs.build_dir}}" - "-DCORROSION_VERBOSE_OUTPUT=ON" - "${{steps.arch_flags.outputs.cmake}}" - "${{steps.pick_compiler.outputs.c_compiler}}" - "${{steps.pick_compiler.outputs.cxx_compiler}}" - "${{steps.determine_cross_compile.outputs.system_name}}" - "${{steps.pick_generator.outputs.generator}}" - ${{steps.install_prefix.outputs.install_path}} - "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" - ${{ inputs.configure_params }} diff --git a/.github/scripts/toolchains/aarch64-apple-darwin-clang.cmake b/.github/scripts/toolchains/aarch64-apple-darwin-clang.cmake new file mode 100644 index 00000000..f66343d0 --- /dev/null +++ b/.github/scripts/toolchains/aarch64-apple-darwin-clang.cmake @@ -0,0 +1,7 @@ +set(CMAKE_C_COMPILER "clang") +set(CMAKE_CXX_COMPILER "clang++") +set(CMAKE_C_COMPILER_TARGET "aarch64-apple-darwin") +set(CMAKE_CXX_COMPILER_TARGET "aarch64-apple-darwin") +set(CMAKE_SYSTEM_NAME "Darwin") +set(CMAKE_SYSTEM_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) +set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "") diff --git a/.github/scripts/toolchains/aarch64-unknown-linux-gnu-clang.cmake b/.github/scripts/toolchains/aarch64-unknown-linux-gnu-clang.cmake new file mode 100644 index 00000000..901de713 --- /dev/null +++ b/.github/scripts/toolchains/aarch64-unknown-linux-gnu-clang.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_COMPILER "clang") +set(CMAKE_CXX_COMPILER "clang++") +set(CMAKE_C_COMPILER_TARGET "aarch64-linux-gnu") +set(CMAKE_CXX_COMPILER_TARGET "aarch64-linux-gnu") diff --git a/.github/scripts/toolchains/aarch64-unknown-linux-gnu-gcc.cmake b/.github/scripts/toolchains/aarch64-unknown-linux-gnu-gcc.cmake new file mode 100644 index 00000000..8b5a7e40 --- /dev/null +++ b/.github/scripts/toolchains/aarch64-unknown-linux-gnu-gcc.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc") +set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") +set(CMAKE_SYSTEM_NAME "Linux") diff --git a/.github/scripts/toolchains/i686-unknown-linux-gnu-clang.cmake b/.github/scripts/toolchains/i686-unknown-linux-gnu-clang.cmake new file mode 100644 index 00000000..1e9575b4 --- /dev/null +++ b/.github/scripts/toolchains/i686-unknown-linux-gnu-clang.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_COMPILER "clang") +set(CMAKE_CXX_COMPILER "clang++") +set(CMAKE_C_COMPILER_TARGET "i686-pc-linux-gnu") +set(CMAKE_CXX_COMPILER_TARGET "i686-pc-linux-gnu") diff --git a/.github/scripts/toolchains/i686-unknown-linux-gnu-gcc.cmake b/.github/scripts/toolchains/i686-unknown-linux-gnu-gcc.cmake new file mode 100644 index 00000000..2871ad5b --- /dev/null +++ b/.github/scripts/toolchains/i686-unknown-linux-gnu-gcc.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER "i686-linux-gnu-gcc") +set(CMAKE_CXX_COMPILER "i686-linux-gnu-g++") +set(CMAKE_SYSTEM_NAME "Linux") diff --git a/.github/scripts/toolchains/x86_64-pc-windows-gnu-clang.cmake b/.github/scripts/toolchains/x86_64-pc-windows-gnu-clang.cmake new file mode 100644 index 00000000..29080cd1 --- /dev/null +++ b/.github/scripts/toolchains/x86_64-pc-windows-gnu-clang.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER "clang") +set(CMAKE_CXX_COMPILER "clang++") +set(CMAKE_C_COMPILER_TARGET "x86_64-pc-win32-gnu") diff --git a/.github/scripts/toolchains/x86_64-unknown-linux-gnu-clang.cmake b/.github/scripts/toolchains/x86_64-unknown-linux-gnu-clang.cmake new file mode 100644 index 00000000..2c2d0fa8 --- /dev/null +++ b/.github/scripts/toolchains/x86_64-unknown-linux-gnu-clang.cmake @@ -0,0 +1,3 @@ +# Assumption: This is the native host target. +set(CMAKE_C_COMPILER "clang") +set(CMAKE_CXX_COMPILER "clang++") diff --git a/.github/scripts/toolchains/x86_64-unknown-linux-gnu-gcc.cmake b/.github/scripts/toolchains/x86_64-unknown-linux-gnu-gcc.cmake new file mode 100644 index 00000000..82e15f7e --- /dev/null +++ b/.github/scripts/toolchains/x86_64-unknown-linux-gnu-gcc.cmake @@ -0,0 +1,3 @@ +# Assumption: This is the native host target. +set(CMAKE_C_COMPILER "gcc") +set(CMAKE_CXX_COMPILER "g++") diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml new file mode 100644 index 00000000..3a952b2b --- /dev/null +++ b/.github/workflows/linux.yaml @@ -0,0 +1,58 @@ +# Workflow file for Linux hosts +name: Corrosion on Linux +on: + workflow_call: + inputs: + ubuntu_version: + required: false + type: string + default: "latest" + cmake: + required: false + type: string + default: "3.22.6" + generator: + required: true + type: string + c_compiler: + required: true + type: string + rust: + required: false + type: string + default: 1.46.0 + target_arch: + required: false + type: string + default: x86_64 + +jobs: + linux: + name: Test Linux + runs-on: ubuntu-${{ inputs.ubuntu_version }} + steps: + - uses: actions/checkout@v4 + - name: Install CMake + uses: corrosion-rs/install-cmake@v2 + with: + cmake: ${{ inputs.cmake }} + ninja: 1.10.0 + - name: Install Rust + id: install_rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{inputs.rust}} + targets: ${{inputs.target_arch}}-unknown-linux-gnu + - name: Install Cross Compiler + shell: bash + run: | + echo "::group::apt-install" + sudo apt-get update + sudo apt-get install -y "g++-${{inputs.target_arch}}-linux-gnu" + echo "::endgroup::" + if: ${{ 'Linux' == runner.os && inputs.target_arch != 'x86_64' }} + - name: Configure Corrosion + run: cmake -S. -Bbuild -G "${{ inputs.generator }}" "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "${{ inputs.target_arch }}-unknown-linux-gnu-${{ inputs.c_compiler }}" + - name: Run Tests + working-directory: build + run: ctest --output-on-failure --build-config Debug -j 3 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 05b5a743..7eb15268 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,172 +9,223 @@ on: - 'stable/**' jobs: - test: - name: Test Corrosion + visual_studio_base: + name: Test Visual Studio (base) + uses: ./.github/workflows/visual_studio.yaml + with: + vs_version: "2022" + rust: 1.46.0 + + visual_studio_stage2: + name: Test Visual Studio + uses: ./.github/workflows/visual_studio.yaml + needs: + - visual_studio_base + strategy: + matrix: + vs_version: + - "2019" + - "2022" + arch: + - x86_64 + - i686 + - aarch64 + rust: + - "1.54.0" + include: + - arch: x86_64 + vs_version: 2022 + rust: stable + - arch: x86_64 + vs_version: 2022 + rust: nightly + with: + vs_version: "${{ matrix.vs_version}}" + rust: 1.54.0 + target_arch: "${{ matrix.arch}}" + + windows_ninja_cl: + name: Test Windows Ninja MSVC runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.rust == 'nightly' }} + needs: + - visual_studio_base strategy: fail-fast: false matrix: os: - windows-2022 - - ubuntu-latest - - macos-13 arch: - x86_64 - i686 - aarch64 - - powerpc64le - abi: - - gnu - - darwin - - msvc - cmake: - - 3.22.6 - rust: - - "stable" - generator: - - default # This is just whatever the platform default is - - ninja - compiler: [default] + compiler: + - cl + - clang-cl include: - - rust: nightly - cmake: 3.22.6 - generator: ninja - arch: x86_64 - abi: msvc - os: windows-2022 - - rust: nightly - cmake: 3.22.6 - generator: ninja - arch: x86_64 - abi: gnu - os: ubuntu-latest - - rust: nightly - cmake: 3.22.6 - generator: ninja - arch: x86_64 - abi: darwin - os: macos-13 - - rust: 1.54 - cmake: 3.22.6 - generator: ninja - arch: x86_64 - abi: msvc - os: windows-2019 - compiler: clang - - os: ubuntu-latest - arch: x86_64 - abi: gnu + - os: windows-2022 + vs_version: vs-2022 cmake: 3.22.6 - rust: 1.54 - generator: ninja-multiconfig - + - rust: 1.54.0 + # Add variable mapping for ilammy/msvc-dev-cmd action + - arch: x86_64 + msvc_dev_arch: amd64 + - arch: i686 + msvc_dev_arch: amd64_x86 + - arch: aarch64 + msvc_dev_arch: amd64_arm64 exclude: - - # We have a separate test Matrix for the Visual Studio Generator - - os: windows-2022 - generator: default # Default generator is Visual Studio - - # ARCH - - os: windows-2022 + # Not sure what parameters CMake needs when cross-compiling with clang-cl, so exclude for now + - compiler: clang-cl arch: i686 - abi: gnu - - os: windows-2022 + - compiler: clang-cl arch: aarch64 - abi: gnu - - os: windows-2022 - arch: i686 - generator: ninja - - os: windows-2022 - arch: aarch64 - generator: ninja - - os: windows-2022 - arch: powerpc64le - - os: macos-13 - arch: i686 - - os: macos-13 - arch: aarch64 - - os: macos-13 - arch: powerpc64le - - # ABI - - os: ubuntu-latest - abi: msvc - - os: ubuntu-latest - abi: darwin - - os: windows-2022 - abi: darwin - - os: macos-13 - abi: msvc - - os: macos-13 - abi: gnu steps: - uses: actions/checkout@v4 - - name: Setup Environment and Configure CMake - uses: "./.github/actions/setup_test" + - name: Install CMake + uses: corrosion-rs/install-cmake@v2 + with: + cmake: ${{ matrix.cmake }} + ninja: 1.10.0 + - name: Install Rust + id: install_rust + uses: dtolnay/rust-toolchain@master with: - target_arch: ${{matrix.arch}} - abi: ${{matrix.abi}} - cmake: ${{matrix.cmake}} - rust: ${{matrix.rust}} - generator: ${{matrix.generator}} - build_dir: build - compiler: ${{matrix.compiler}} + toolchain: ${{matrix.rust}} + targets: ${{matrix.arch}}-pc-windows-msvc + - name: Setup MSVC Development Environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.msvc_dev_arch }} + - name: Configure + run: cmake -S. -Bbuild "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "ninja-${{ matrix.arch }}-pc-windows-msvc-${{ matrix.compiler }}" - name: Run Tests - id: run_tests working-directory: build run: ctest --output-on-failure --build-config Debug -j 3 - test_msvc: - name: Test MSVC Generator + windows_gnu: + name: Test Windows GNU runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: - - windows-2019 - windows-2022 + arch: + - x86_64 + # - i686 + # - aarch64 + compiler: + - gcc # Clang only has experimental support for Cygwin / MinGW, so we don't test it + generator: + - ninja + - make + include: + - cmake: 3.22.6 + - rust: 1.54.0 + + steps: + - uses: actions/checkout@v4 + - name: Install CMake + uses: corrosion-rs/install-cmake@v2 + with: + cmake: ${{ matrix.cmake }} + ninja: 1.10.0 + - name: Install Rust + id: install_rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{matrix.rust}} + targets: ${{matrix.arch}}-pc-windows-gnu + - name: Configure + run: cmake -S. -Bbuild "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "${{ matrix.generator }}-${{ matrix.arch }}-pc-windows-gnu-${{ matrix.compiler }}" + - name: Run Tests + working-directory: build + run: ctest --output-on-failure --build-config Debug -j 3 + + + linux_base: + name: Test Linux (base) + uses: ./.github/workflows/linux.yaml + with: + c_compiler: "gcc" + generator: "Ninja" + + linux_stage2: + name: Test Linux + needs: + - linux_base + uses: ./.github/workflows/linux.yaml + with: + target_arch: "${{ matrix.arch }}" + c_compiler: "${{ matrix.compiler }}" + generator: "${{ matrix.generator }}" + strategy: + fail-fast: false + matrix: arch: - x86_64 - i686 - aarch64 + compiler: + - gcc + generator: + - "Ninja" + - "Unix Makefiles" include: - - rust: 1.54.0 - # Override rust version for x86_64 + # rustc doesn't support cross-compiling with clang out of the box, since + # clang requires a --target parameter. Corrosion currently can only pass + # this for the top-level crate, so linking of cdylibs that are built as + # dependencies of this crate will fail if they exist. + # Solutions would be to make cross-compiling with clang work out-of-the-box + # in rustc, or working around it in corrosion by adding a linker-wrapper. + # For this reason we only test clang with the host target for now. - arch: x86_64 - rust: 1.46.0 - - os: windows-2019 - cmake: 3.22.6 - - os: windows-2022 - cmake: 3.22.6 + compiler: clang + generator: "Ninja" + - arch: x86_64 + generator: "Ninja Multi-Config" + compiler: gcc + + darwin: + name: Test MacOS + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + arch: + - x86_64 + - aarch64 + compiler: + - clang + generator: + - "Ninja" + - "Xcode" + include: + - os: macos-latest + - cmake: 3.22.6 + - rust: 1.54.0 steps: - uses: actions/checkout@v4 - # The initial configure for MSVC is quite slow, so we cache the build directory - # (including the build directories of the tests) since reconfiguring is - # significantly faster. - - name: Cache MSVC build directory - id: cache-msvc-builddir - uses: actions/cache@v3 + - name: Install CMake + uses: corrosion-rs/install-cmake@v2 with: - path: build - key: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.rust }}-msvc-build - - name: Setup Environment and Configure CMake - uses: "./.github/actions/setup_test" + cmake: ${{ matrix.cmake }} + ninja: 1.10.0 + - name: Install Rust + id: install_rust + uses: dtolnay/rust-toolchain@master with: - target_arch: ${{matrix.arch}} - abi: msvc - cmake: ${{matrix.cmake}} - rust: ${{matrix.rust}} - generator: default - build_dir: build - configure_params: "-DCORROSION_TESTS_KEEP_BUILDDIRS=ON" + toolchain: ${{matrix.rust}} + targets: ${{matrix.arch}}-apple-darwin + - name: Configure + run: cmake -S. -Bbuild -G "${{ matrix.generator }}" "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "${{ matrix.arch }}-apple-darwin-${{ matrix.compiler }}" - name: Run Tests working-directory: build run: ctest --output-on-failure --build-config Debug -j 3 + test_cxxbridge: name: Test cxxbridge integration runs-on: ${{ matrix.os }} @@ -186,35 +237,46 @@ jobs: - ubuntu-latest - macos-13 include: - - abi: default - # - os: windows-2019 - # abi: gnu + # Should be in sync with the `cxx` version the Carg.lock of the cxxbridge tests, + # otherwise the caching will not work and the cmd will be built from source. + - cxxbridge_version: "1.0.86" steps: - uses: actions/checkout@v4 - uses: actions/cache@v3 id: cache_cxxbridge with: path: "~/.cargo/bin/cxxbridge*" - key: ${{ runner.os }}-cxxbridge_1_0_86 + key: ${{ runner.os }}-cxxbridge_${{ matrix.cxxbridge_version }} - name: Install cxxbridge if: steps.cache_cxxbridge.outputs.cache-hit != 'true' - run: cargo install cxxbridge-cmd@1.0.86 + run: cargo install cxxbridge-cmd@${{ matrix.cxxbridge_version }} - name: Install lld run: sudo apt update && sudo apt install -y lld if: ${{ 'Linux' == runner.os }} - - name: Setup Environment and Configure CMake - uses: "./.github/actions/setup_test" + - name: Setup MSVC Development Environment + uses: ilammy/msvc-dev-cmd@v1 + if: runner.os == 'Windows' + - name: Install CMake + uses: corrosion-rs/install-cmake@v2 with: - target_arch: x86_64 cmake: 3.22.6 - rust: stable minus 2 releases - abi: ${{ matrix.abi }} - generator: ninja - build_dir: build - configure_params: -DCORROSION_TESTS_CXXBRIDGE=ON + ninja: 1.10.0 + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable minus 2 releases + - name: Configure + run: > + cmake + -S. + -Bbuild + -GNinja + -DCORROSION_VERBOSE_OUTPUT=ON + -DCORROSION_TESTS_CXXBRIDGE=ON - name: Run Tests working-directory: build run: ctest --output-on-failure --build-config Debug -j 3 -R "^cxxbridge" + install: name: Test Corrosion as a Library runs-on: ${{ matrix.os }} @@ -222,15 +284,14 @@ jobs: fail-fast: false matrix: os: - - windows-2019 + - windows-2022 - ubuntu-latest - macos-13 include: - - rust: 1.46.0 - - os: macos-13 - rust: 1.54.0 # On MacOS-12 linking fails before Rust 1.54 + - rust: 1.54.0 + steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup MSVC Development Environment uses: ilammy/msvc-dev-cmd@v1 if: runner.os == 'Windows' @@ -243,26 +304,8 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} - - name: CMake Version - run: cmake --version - - name: Rust Version - run: rustc --version - - name: Test Corrosion as subdirectory - run: > - cmake - -S. - -Bbuild - -GNinja - -DCORROSION_VERBOSE_OUTPUT=ON - -DCORROSION_TESTS_INSTALL_CORROSION=OFF - && - cd build - && - ctest --output-on-failure -C Debug -j 3 - name: Test Corrosion as installed module run: > - cmake -E remove_directory build - && cmake -S. -Bbuild @@ -281,8 +324,11 @@ jobs: name: bors-ci-status if: ${{ always() }} needs: - - test - - test_msvc + - visual_studio_stage2 + - windows_ninja_cl + - windows_gnu + - linux_stage2 + - darwin - test_cxxbridge - install runs-on: ubuntu-latest diff --git a/.github/workflows/visual_studio.yaml b/.github/workflows/visual_studio.yaml new file mode 100644 index 00000000..e3e04c5b --- /dev/null +++ b/.github/workflows/visual_studio.yaml @@ -0,0 +1,53 @@ +name: Corrosion with Visual Studio + +on: + workflow_call: + inputs: + vs_version: + required: true + type: string + default: 2022 + cmake: + required: false + type: string + default: "3.22.6" + rust: + required: false + type: string + default: 1.46.0 + target_arch: + required: false + type: string + default: x86_64 + +jobs: + visual_studio: + name: Test Visual Studio ${{ inputs.vs_version }} + runs-on: "windows-${{ inputs.vs_version }}" + steps: + - uses: actions/checkout@v4 + - name: Install CMake + uses: corrosion-rs/install-cmake@v2 + with: + cmake: ${{ inputs.cmake }} + ninja: 1.10.0 + - name: Install Rust + id: install_rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{inputs.rust}} + targets: ${{inputs.target_arch}}-pc-windows-msvc + # The initial configure for MSVC is quite slow, so we cache the build directory + # (including the build directories of the tests) since reconfiguring is + # significantly faster. + - name: Cache MSVC build directory + id: cache-msvc-builddir + uses: actions/cache@v3 + with: + path: build + key: ${{ inputs.os }}-${{ inputs.target_arch }}-${{ inputs.rust }}-msvc-${{ inputs.vs_version}}-build + - name: Configure + run: cmake -S. -Bbuild -DCORROSION_TESTS_KEEP_BUILDDIRS=ON "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "vs-${{ inputs.vs_version }}-${{ inputs.target_arch }}" + - name: Run Tests + working-directory: build + run: ctest --output-on-failure --build-config Debug -j 3 diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..d014dad8 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,315 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 22, + "patch": 0 + }, + "configurePresets": [ + { + "name": "ninja", + "hidden": true, + "generator": "Ninja" + }, + { + "name": "ninja-mc", + "hidden": true, + "generator": "Ninja Multi-Config" + }, + { + "name": "make", + "hidden": true, + "generator": "Unix Makefiles" + }, + { + "name": "vs-2019", + "hidden": true, + "generator": "Visual Studio 16 2019" + }, + { + "name": "vs-2022", + "hidden": true, + "generator": "Visual Studio 17 2022" + }, + { + "name": "windows-only", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "windows-10-cross", + "hidden": true, + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "Windows", + "CMAKE_SYSTEM_VERSION": "10.0" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "x86_64-pc-windows-msvc", + "hidden": true, + "inherits": ["windows-only"], + "cacheVariables": { + "Rust_CARGO_TARGET": "x86_64-pc-windows-msvc" + } + }, + { + "name": "i686-pc-windows-msvc", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "i686-pc-windows-msvc" + } + }, + { + "name": "aarch64-pc-windows-msvc", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "aarch64-pc-windows-msvc" + } + }, + { + "name": "x86_64-pc-windows-gnu", + "hidden": true, + "inherits": ["windows-only"], + "cacheVariables": { + "Rust_CARGO_TARGET": "x86_64-pc-windows-gnu" + } + }, + { + "name": "i686-pc-windows-gnu", + "hidden": true, + "inherits": ["windows-only"], + "cacheVariables": { + "Rust_CARGO_TARGET": "i686-pc-windows-gnu" + } + }, + { + "name": "aarch64-pc-windows-gnu", + "hidden": true, + "inherits": ["windows-only"], + "cacheVariables": { + "Rust_CARGO_TARGET": "aarch64-pc-windows-gnu" + } + }, + { + "name": "x86_64-unknown-linux-gnu", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "x86_64-unknown-linux-gnu" + } + }, + { + "name": "i686-unknown-linux-gnu", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "i686-unknown-linux-gnu" + } + }, + { + "name": "aarch64-unknown-linux-gnu", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "aarch64-unknown-linux-gnu" + } + }, + { + "name": "x86_64-apple-darwin", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "x86_64-apple-darwin" + } + }, + { + "name": "aarch64-apple-darwin", + "hidden": true, + "cacheVariables": { + "Rust_CARGO_TARGET": "aarch64-apple-darwin" + } + }, + { + "name": "vs-platform-arm64", + "hidden": true, + "inherits": ["aarch64-pc-windows-msvc","windows-10-cross"], + "architecture": { + "value": "ARM64" + } + }, + { + "name": "vs-platform-x64", + "hidden": true, + "inherits": ["x86_64-pc-windows-msvc"], + "architecture": { + "value": "x64" + } + }, + { + "name": "vs-platform-i686", + "hidden": true, + "inherits": ["i686-pc-windows-msvc", "windows-10-cross"], + "architecture": { + "value": "Win32" + } + }, + { + "name": "vs-2019-x86_64", + "inherits": ["vs-platform-x64", "vs-2019"] + }, + { + "name": "vs-2022-x86_64", + "inherits": ["vs-platform-x64", "vs-2022"] + }, + { + "name": "vs-2019-i686", + "inherits": ["vs-platform-i686", "vs-2019"] + }, + { + "name": "vs-2022-i686", + "inherits": ["vs-platform-i686", "vs-2022"] + }, + { + "name": "vs-2019-aarch64", + "inherits": ["vs-platform-arm64", "vs-2019"] + }, + { + "name": "vs-2022-aarch64", + "inherits": ["vs-platform-arm64", "vs-2022"] + }, + { + "name": "clang", + "hidden": true, + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + } + }, + { + "name": "gcc", + "hidden": true, + "cacheVariables": { + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++" + } + }, + { + "name": "clang-cl", + "hidden": true, + "inherits": ["windows-only"], + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl" + } + }, + { + "name": "cl", + "hidden": true, + "inherits": ["windows-only"], + "cacheVariables": { + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl" + } + }, + { + "name": "ninja-x86_64-pc-windows-msvc-cl", + "inherits": ["ninja", "x86_64-pc-windows-msvc", "cl"] + }, + { + "name": "ninja-x86_64-pc-windows-msvc-clang-cl", + "inherits": ["ninja", "x86_64-pc-windows-msvc", "clang-cl"] + }, + { + "name": "ninja-i686-pc-windows-msvc-cl", + "inherits": ["ninja", "i686-pc-windows-msvc", "cl", "windows-10-cross"] + }, + { + "name": "ninja-i686-pc-windows-msvc-clang-cl", + "inherits": ["ninja", "i686-pc-windows-msvc", "clang-cl", "windows-10-cross"] + }, + { + "name": "ninja-aarch64-pc-windows-msvc-cl", + "inherits": ["ninja", "aarch64-pc-windows-msvc", "cl", "windows-10-cross"] + }, + { + "name": "ninja-aarch64-pc-windows-msvc-clang-cl", + "inherits": ["ninja", "aarch64-pc-windows-msvc", "clang-cl", "windows-10-cross"] + }, + { + "name": "ninja-x86_64-pc-windows-gnu-clang", + "inherits": ["ninja", "x86_64-pc-windows-gnu", "clang"] + }, + { + "name": "make-x86_64-pc-windows-gnu-clang", + "inherits": ["make", "x86_64-pc-windows-gnu", "clang"] + }, + { + "name": "ninja-x86_64-pc-windows-gnu-gcc", + "inherits": ["ninja", "x86_64-pc-windows-gnu", "gcc", "windows-only"] + }, + { + "name": "make-x86_64-pc-windows-gnu-gcc", + "inherits": ["make", "x86_64-pc-windows-gnu", "gcc", "windows-only"] + }, + { + "name": "ninja-i686-pc-windows-gnu-clang", + "inherits": ["ninja", "i686-pc-windows-gnu", "clang", "windows-10-cross"] + }, + { + "name": "make-i686-pc-windows-gnu-clang", + "inherits": ["make", "i686-pc-windows-gnu", "clang", "windows-10-cross"] + }, + { + "name": "ninja-aarch64-pc-windows-gnu-clang", + "inherits": ["ninja", "aarch64-pc-windows-gnu", "clang", "windows-10-cross"] + }, + { + "name": "make-aarch64-pc-windows-gnu-clang", + "inherits": ["make", "aarch64-pc-windows-gnu", "clang", "windows-10-cross"] + }, + { + "name": "x86_64-unknown-linux-gnu-clang", + "inherits": ["x86_64-unknown-linux-gnu"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + }, + { + "name": "x86_64-unknown-linux-gnu-gcc", + "inherits": ["x86_64-unknown-linux-gnu"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + }, + { + "name": "i686-unknown-linux-gnu-clang", + "inherits": ["i686-unknown-linux-gnu"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + }, + { + "name": "i686-unknown-linux-gnu-gcc", + "inherits": ["i686-unknown-linux-gnu"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + }, + { + "name": "aarch64-unknown-linux-gnu-clang", + "inherits": ["aarch64-unknown-linux-gnu"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + }, + { + "name": "aarch64-unknown-linux-gnu-gcc", + "inherits": ["aarch64-unknown-linux-gnu"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + }, + { + "name": "x86_64-apple-darwin-clang", + "inherits": ["x86_64-apple-darwin", "clang"] + }, + { + "name": "aarch64-apple-darwin-clang", + "inherits": ["aarch64-apple-darwin"], + "toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake" + } + ] +}