Skip to content

Commit 7c0bf01

Browse files
committed
Squashed 'corrosion/' content from commit 3500297
git-subtree-dir: corrosion git-subtree-split: 35002975fa98464b9714161b35afb99047a29ce5
0 parents  commit 7c0bf01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4425
-0
lines changed

.github/workflows/test.yaml

Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- '*'
9+
defaults:
10+
run:
11+
shell: bash
12+
jobs:
13+
test:
14+
name: Test Corrosion
15+
runs-on: ${{ matrix.os }}
16+
continue-on-error: ${{ matrix.rust == 'nightly' }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os:
21+
- windows-2019 # windows-latest is currently not having a supported MSVC compiler
22+
- ubuntu-latest
23+
- macos-10.15
24+
arch:
25+
- x86_64
26+
- i686
27+
- aarch64
28+
- powerpc64le
29+
abi:
30+
- gnu
31+
- darwin
32+
- msvc
33+
cmake:
34+
- 3.15.7
35+
- 3.19.0
36+
rust:
37+
- 1.44.1 # Earliest targeted version
38+
- 1.45.0 # Earliest version compatible with Windows GNU
39+
- stable
40+
- nightly
41+
generator:
42+
- default # This is just whatever the platform default is
43+
- ninja
44+
include:
45+
- os: macos-latest
46+
arch: x86_64
47+
abi: darwin
48+
cmake: 3.19.0
49+
rust: 1.44.1
50+
generator: default
51+
- os: macos-latest
52+
arch: x86_64
53+
abi: darwin
54+
cmake: 3.19.0
55+
rust: stable
56+
generator: ninja
57+
exclude:
58+
59+
# You cannot build with GNU using Visual Studio on Windows
60+
- os: windows-2019
61+
abi: gnu
62+
generator: default # Default generator is Visual Studio
63+
64+
# ARCH
65+
- os: windows-2019
66+
arch: i686
67+
abi: gnu
68+
- os: windows-2019
69+
arch: aarch64
70+
abi: gnu
71+
- os: windows-2019
72+
arch: i686
73+
generator: ninja
74+
- os: windows-2019
75+
arch: aarch64
76+
generator: ninja
77+
- os: windows-2019
78+
arch: powerpc64le
79+
- os: macos-10.15
80+
arch: i686
81+
- os: macos-10.15
82+
arch: aarch64
83+
- os: macos-10.15
84+
arch: powerpc64le
85+
86+
# ABI
87+
- os: ubuntu-latest
88+
abi: msvc
89+
- os: ubuntu-latest
90+
abi: darwin
91+
- os: windows-2019
92+
abi: darwin
93+
- os: macos-10.15
94+
abi: msvc
95+
- os: macos-10.15
96+
abi: gnu
97+
98+
# Rust
99+
# Build each set only with the earliest compatible versioned Rust
100+
- os: macos-10.15
101+
rust: 1.45.0
102+
- os: ubuntu-latest
103+
rust: 1.45.0
104+
- os: windows-2019
105+
abi: msvc
106+
rust: 1.45.0
107+
# Prior to 1.45.0, -nostdlib is erroneously passed to g++ when for the *-pc-windows-gnu
108+
# target. See: https://github.com/rust-lang/rust/pull/71769
109+
- os: windows-2019
110+
abi: gnu
111+
rust: 1.44.1
112+
113+
steps:
114+
- name: Determine Rust OS
115+
id: determine_rust_os
116+
run: |
117+
if [ "${{ runner.os }}" == "Windows" ]; then
118+
echo "::set-output name=os::pc-windows"
119+
echo "::set-output name=host_abi::msvc"
120+
elif [ "${{ runner.os }}" == "Linux" ]; then
121+
echo "::set-output name=os::unknown-linux"
122+
echo "::set-output name=host_abi::gnu"
123+
elif [ "${{ runner.os }}" == "macOS" ]; then
124+
echo "::set-output name=os::apple"
125+
echo "::set-output name=host_abi::darwin"
126+
fi
127+
- name: Pick Compiler
128+
id: pick_compiler
129+
run: |
130+
if [ "${{ matrix.abi }}" == "gnu" ]; then
131+
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
132+
echo "::set-output name=c_compiler::-DCMAKE_C_COMPILER=${{matrix.arch}}-linux-gnu-gcc"
133+
echo "::set-output name=cxx_compiler::-DCMAKE_CXX_COMPILER=${{matrix.arch}}-linux-gnu-g++"
134+
echo "::set-output name=system_name::-DCMAKE_SYSTEM_NAME=Linux"
135+
else
136+
echo "::set-output name=c_compiler::-DCMAKE_C_COMPILER=gcc"
137+
echo "::set-output name=cxx_compiler::-DCMAKE_CXX_COMPILER=g++"
138+
fi
139+
elif [ "${{ matrix.abi }}" == "darwin" ]; then
140+
echo "::set-output name=c_compiler::-DCMAKE_C_COMPILER=clang"
141+
echo "::set-output name=cxx_compiler::-DCMAKE_CXX_COMPILER=clang++"
142+
elif [ "${{ matrix.abi }}" == "msvc" ]; then
143+
echo "::set-output name=c_compiler::-DCMAKE_C_COMPILER=cl"
144+
echo "::set-output name=cxx_compiler::-DCMAKE_CXX_COMPILER=cl"
145+
fi
146+
- name: Pick Generator
147+
id: pick_generator
148+
run: |
149+
if [ "${{ matrix.generator }}" == "ninja" ]; then
150+
echo "::set-output name=generator::-GNinja"
151+
elif [ "${{ matrix.abi }}" == "default" ]; then
152+
echo "::set-output name=generator::"
153+
fi
154+
- name: CMake Build Flags
155+
id: cmake_build_flags
156+
run: |
157+
echo "::set-output name=cmake_build_flags::--verbose"
158+
- name: Arch Flags
159+
id: arch_flags
160+
run: | # Cross-compiling is currently only supported on Windows+MSVC with the default generator
161+
if [ "${{ runner.os }}" == "Windows" ]; then
162+
if [ "${{matrix.generator}}" == "default" ]; then
163+
if [ "${{ matrix.arch }}" == "x86_64" ]; then
164+
echo "::set-output name=msvc::amd64"
165+
echo "::set-output name=cmake::-Ax64"
166+
elif [ "${{ matrix.arch }}" == "i686" ]; then
167+
echo "::set-output name=msvc::amd64_x86"
168+
echo "::set-output name=cmake::-AWin32"
169+
elif [ "${{ matrix.arch }}" == "aarch64" ]; then
170+
echo "::set-output name=msvc::amd64_arm64"
171+
echo "::set-output name=cmake::-AARM64"
172+
fi
173+
elif [ "${{matrix.generator}}" == "ninja" ]; then
174+
# We don't do cross-compiling builds with Ninja
175+
echo "::set-output name=msvc::amd64"
176+
fi
177+
elif [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
178+
echo "::set-output name=cmake::-DRust_CARGO_TARGET=${{matrix.arch}}-${{steps.determine_rust_os.outputs.os}}-${{matrix.abi}}"
179+
fi
180+
- name: Setup MSVC Development Environment
181+
uses: ilammy/[email protected]
182+
with:
183+
arch: ${{ steps.arch_flags.outputs.msvc }}
184+
if: ${{ 'msvc' == matrix.abi }}
185+
- uses: actions/checkout@v2
186+
- name: Install CMake
187+
uses: corrosion-rs/[email protected]
188+
with:
189+
cmake: ${{matrix.cmake}}
190+
ninja: 1.10.0
191+
- name: Install Rust
192+
uses: actions-rs/toolchain@v1
193+
with:
194+
toolchain: ${{matrix.rust}}
195+
target: ${{matrix.arch}}-${{steps.determine_rust_os.outputs.os}}-${{matrix.abi}}
196+
- name: Install Cross Compiler
197+
run: |
198+
sudo apt-get update
199+
sudo apt-get install -y g++-$(echo "${{matrix.arch}}" | tr _ -)-linux-gnu
200+
if: ${{ 'ubuntu-latest' == matrix.os }}
201+
- name: CMake Version
202+
run: cmake --version
203+
- name: Rust Version
204+
run: rustc +${{matrix.rust}} --version
205+
- name: Configure
206+
run: >
207+
cmake
208+
-S.
209+
-Bbuild
210+
-DCORROSION_VERBOSE_OUTPUT=ON
211+
${{ steps.arch_flags.outputs.cmake }}
212+
${{ steps.pick_compiler.outputs.c_compiler }}
213+
${{ steps.pick_compiler.outputs.cxx_compiler }}
214+
${{ steps.pick_compiler.outputs.system_name }}
215+
${{ steps.pick_generator.outputs.generator }}
216+
-DRust_TOOLCHAIN="${{matrix.rust}}"
217+
- name: Run Config Tests (x86_64 Only)
218+
run: |
219+
cd build
220+
cmake \
221+
--build . ${{steps.cmake_build_flags.outputs.cmake_build_flags}} \
222+
--target test-install
223+
ctest --verbose --build-config Debug
224+
if: ${{ 'x86_64' == matrix.arch && !('windows-2019' == matrix.os && 'gnu' == matrix.abi) }}
225+
- name: Build C++ program linking Rust
226+
run: |
227+
cmake \
228+
--build build ${{steps.cmake_build_flags.outputs.cmake_build_flags}} \
229+
--target cpp-exe
230+
- name: Build Rust program linking C++
231+
run: |
232+
cmake \
233+
--build build ${{steps.cmake_build_flags.outputs.cmake_build_flags}} \
234+
--target cargo-build_rust-exe
235+
- name: Build Rust cdylib and link against C++
236+
run: |
237+
cmake \
238+
--build build ${{steps.cmake_build_flags.outputs.cmake_build_flags}} \
239+
--target my_program
240+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.abi == 'gnu' }}
241+
- name: Build host program in cross-compile setup
242+
run: |
243+
cmake \
244+
--build build ${{steps.cmake_build_flags.outputs.cmake_build_flags}} \
245+
--target cargo-build_rust-host-program
246+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.abi == 'gnu' && matrix.cmake == '3.19.0' }}
247+
- name: Run host program in cross-compile setup
248+
run: |
249+
./build/test/hostbuild/rust-host-program
250+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.abi == 'gnu' && matrix.cmake == '3.19.0' }}
251+
install:
252+
name: Test Corrosion as a Library
253+
runs-on: ${{ matrix.os }}
254+
strategy:
255+
fail-fast: false
256+
matrix:
257+
os:
258+
- windows-2019
259+
- ubuntu-latest
260+
- macos-10.15
261+
method:
262+
- subdirectory
263+
- install
264+
steps:
265+
- name: Check tests external
266+
id: check_external
267+
run: |
268+
if [ "${{ matrix.method }}" == "subdirectory" ]; then
269+
echo "::set-output name=find::OFF"
270+
elif [ "${{ matrix.method }}" == "install" ]; then
271+
echo "::set-output name=find::ON"
272+
fi
273+
- uses: actions/checkout@v2
274+
- name: Install CMake
275+
uses: corrosion-rs/[email protected]
276+
with:
277+
cmake: 3.18.0
278+
ninja: 1.10.0
279+
- name: Install Rust
280+
uses: actions-rs/toolchain@v1
281+
with:
282+
toolchain: 1.44.1
283+
default: true
284+
- name: CMake Version
285+
run: cmake --version
286+
- name: Rust Version
287+
run: rustc --version
288+
- name: Install Corrosion
289+
run: >
290+
cmake
291+
-S.
292+
-Bbuild-corrosion
293+
-DCORROSION_VERBOSE_OUTPUT=ON
294+
-DCORROSION_BUILD_TESTS=OFF
295+
-DCMAKE_BUILD_TYPE=Release
296+
-DCMAKE_INSTALL_PREFIX=install-corrosion
297+
298+
cmake --build build-corrosion --config Release
299+
300+
cmake --install build-corrosion --config Release
301+
if: ${{ matrix.method == 'install' }}
302+
- name: Configure Tests
303+
run: >
304+
cmake
305+
-Stest
306+
-Bbuild-tests
307+
-DCORROSION_TESTS_FIND_CORROSION=${{steps.check_external.outputs.find}}
308+
-DCMAKE_PREFIX_PATH="$PWD/install-corrosion"
309+
- name: Build Tests
310+
run: cmake --build build-tests
311+

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
**/target/
3+
**/*.rs.bk
4+
build*/
5+
install*/
6+
.vscode

0 commit comments

Comments
 (0)