Skip to content

Commit 198621c

Browse files
authored
Add linux build support (#619)
1 parent 6116e05 commit 198621c

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ env:
1111

1212
jobs:
1313
test:
14-
runs-on: windows-latest
14+
runs-on: ${{ matrix.os }}
1515
strategy:
16-
matrix:
17-
rust: [stable]
16+
matrix:
17+
include:
18+
- os: windows-latest
19+
rust: stable
20+
other: x86_64-pc-windows-msvc
21+
- os: ubuntu-latest
22+
rust: stable
23+
other: i686-unknown-linux-gnu
1824
steps:
1925
- uses: actions/checkout@v2
2026
- uses: actions-rs/toolchain@v1
@@ -24,9 +30,14 @@ jobs:
2430
override: true
2531
components: rustfmt
2632

27-
- name: tests
33+
- name: build
34+
run: cargo build
35+
if: matrix.os == 'ubuntu-latest'
36+
37+
- name: test
2838
run: cargo test --all
39+
if: matrix.os == 'windows-latest'
2940

3041
- name: fmt
3142
run: cargo fmt --all -- --check
32-
if: matrix.rust == 'stable'
43+
if: matrix.os == 'windows-latest'

crates/gen/src/types/function.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,21 @@ impl Function {
5050
link = "onecoreuap";
5151
}
5252

53-
quote! {
54-
pub unsafe fn #name<#constraints>(#params) #return_type {
55-
#[link(name = #link)]
56-
extern "system" {
57-
pub fn #name(#(#abi_params),*) #abi_return_type;
53+
if cfg!(windows) {
54+
quote! {
55+
pub unsafe fn #name<#constraints>(#params) #return_type {
56+
#[link(name = #link)]
57+
extern "system" {
58+
pub fn #name(#(#abi_params),*) #abi_return_type;
59+
}
60+
#name(#(#args),*)
61+
}
62+
}
63+
} else {
64+
quote! {
65+
pub unsafe fn #name<#constraints>(#params) #return_type {
66+
panic!("Unsupported target OS");
5867
}
59-
#name(#(#args),*)
6068
}
6169
}
6270
}

0 commit comments

Comments
 (0)