Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linux build support #619

Merged
merged 5 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
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