Skip to content

Commit

Permalink
Add test matrix for linux-gnu
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwe committed Sep 17, 2023
1 parent a499172 commit 97c03c1
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 4 additions & 0 deletions .github/scripts/toolchains/i686-unknown-linux-gnu-clang.cmake
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 3 additions & 0 deletions .github/scripts/toolchains/i686-unknown-linux-gnu-gcc.cmake
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 3 additions & 0 deletions .github/scripts/toolchains/x86_64-pc-windows-gnu-clang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER_TARGET "x86_64-pc-win32-gnu")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Assumption: This is the native host target.
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
3 changes: 3 additions & 0 deletions .github/scripts/toolchains/x86_64-unknown-linux-gnu-gcc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Assumption: This is the native host target.
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
58 changes: 58 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,64 @@ jobs:
working-directory: build
run: ctest --output-on-failure --build-config Debug -j 3

linux: # todo: could probably be merged into one action with windows-gnu
name: Test Linux
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
arch:
- x86_64
- i686
- aarch64
compiler:
- gcc
generator:
- "Ninja"
- "Unix Makefiles"
include:
- cmake: 3.22.6
- rust: 1.54.0
# 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.
- arch: x86_64
compiler: clang

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}}-unknown-linux-gnu
- name: Install Cross Compiler
shell: bash
run: |
if [[ "${{ matrix.arch }}" != 'x86_64' ]]; then
echo "::group::apt-install"
sudo apt-get update
sudo apt-get install -y "g++-${{matrix.arch}}-linux-gnu"
echo "::endgroup::"
fi
if: ${{ 'Linux' == runner.os }}
- name: New configure
run: cmake -S. -Bbuild -G "${{ matrix.generator }}" "-DRust_TOOLCHAIN=${{steps.install_rust.outputs.name}}" --preset "${{ matrix.arch }}-unknown-linux-gnu-${{ 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 }}
Expand Down
51 changes: 51 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@
"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": "vs-platform-arm64",
"hidden": true,
Expand Down Expand Up @@ -236,6 +257,36 @@
{
"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"
}
]
}

0 comments on commit 97c03c1

Please sign in to comment.