Skip to content

Commit

Permalink
Add linux build support (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Mar 18, 2021
1 parent 6116e05 commit 198621c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ env:

jobs:
test:
runs-on: windows-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [stable]
matrix:
include:
- os: windows-latest
rust: stable
other: x86_64-pc-windows-msvc
- os: ubuntu-latest
rust: stable
other: i686-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -24,9 +30,14 @@ jobs:
override: true
components: rustfmt

- name: tests
- name: build
run: cargo build
if: matrix.os == 'ubuntu-latest'

- name: test
run: cargo test --all
if: matrix.os == 'windows-latest'

- name: fmt
run: cargo fmt --all -- --check
if: matrix.rust == 'stable'
if: matrix.os == 'windows-latest'
20 changes: 14 additions & 6 deletions crates/gen/src/types/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,21 @@ impl Function {
link = "onecoreuap";
}

quote! {
pub unsafe fn #name<#constraints>(#params) #return_type {
#[link(name = #link)]
extern "system" {
pub fn #name(#(#abi_params),*) #abi_return_type;
if cfg!(windows) {

This comment has been minimized.

Copy link
@abbec

abbec Mar 23, 2021

This actually breaks cross-compilation since when building for Windows on Linux, this is not true (the build scripts run on the host). Better to check for target.

This comment has been minimized.

Copy link
@abbec

abbec Mar 23, 2021

Or something like that

quote! {
pub unsafe fn #name<#constraints>(#params) #return_type {
#[link(name = #link)]
extern "system" {
pub fn #name(#(#abi_params),*) #abi_return_type;
}
#name(#(#args),*)
}
}
} else {
quote! {
pub unsafe fn #name<#constraints>(#params) #return_type {
panic!("Unsupported target OS");
}
#name(#(#args),*)
}
}
}
Expand Down

0 comments on commit 198621c

Please sign in to comment.