From 94c4b5fa0f92d20f0422ea636e49739e80f58746 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 18 Mar 2021 13:22:53 -0700 Subject: [PATCH 1/5] build --- .github/workflows/build.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c419d7b4bf..dee5a4431e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 From 407b0e60e0e3e79560e133cce8c39840189ca401 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 18 Mar 2021 14:06:03 -0700 Subject: [PATCH 2/5] target os --- crates/gen/src/types/function.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/gen/src/types/function.rs b/crates/gen/src/types/function.rs index 8b0074036d..9705ce2b63 100644 --- a/crates/gen/src/types/function.rs +++ b/crates/gen/src/types/function.rs @@ -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),*) } } } From d7dfc1d8edde9f408c3ef160cfb625c8a8bbc3d1 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 18 Mar 2021 14:14:28 -0700 Subject: [PATCH 3/5] clock --- examples/clock/src/main.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index e946dd9d29..c55d3b935e 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -730,9 +730,31 @@ fn create_swapchain(device: &ID3D11Device, window: HWND) -> Result isize; - fn GetWindowLongPtrA(window: HWND, index: i32) -> isize; +#[allow(non_snake_case)] +unsafe fn SetWindowLongPtrA(window: HWND, index: i32, value: isize) -> isize { + if cfg!(windows) { + #[link(name = "user32")] + extern "system" { + fn SetWindowLongPtrA(window: HWND, index: i32, value: isize) -> isize; + } + + SetWindowLongPtrA(window, index, value) + } else { + panic!("Unsupported target OS"); + } +} + +#[allow(non_snake_case)] +unsafe fn GetWindowLongPtrA(window: HWND, index: i32) -> isize { + if cfg!(windows) { + #[link(name = "user32")] + extern "system" { + fn GetWindowLongPtrA(window: HWND, index: i32) -> isize; + } + + GetWindowLongPtrA(window, index) + } else { + panic!("Unsupported target OS"); + } } From 3b9eca02fdde7bab4b514eb629c248d7c09e6702 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 18 Mar 2021 14:23:12 -0700 Subject: [PATCH 4/5] build --- .github/workflows/build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dee5a4431e..6dfa7781dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,9 +30,14 @@ jobs: override: true components: rustfmt + - name: build + run: cargo build + if: matrix.os == 'ubuntu-latest' + - name: tests 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' From f5c5ee3375e8664545311425420a13321a6dc9cf Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 18 Mar 2021 14:26:36 -0700 Subject: [PATCH 5/5] clock --- .github/workflows/build.yml | 2 +- examples/clock/src/main.rs | 30 ++++-------------------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6dfa7781dd..a8b5b85653 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: run: cargo build if: matrix.os == 'ubuntu-latest' - - name: tests + - name: test run: cargo test --all if: matrix.os == 'windows-latest' diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index c55d3b935e..e946dd9d29 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -730,31 +730,9 @@ fn create_swapchain(device: &ID3D11Device, window: HWND) -> Result isize; -#[allow(non_snake_case)] -unsafe fn SetWindowLongPtrA(window: HWND, index: i32, value: isize) -> isize { - if cfg!(windows) { - #[link(name = "user32")] - extern "system" { - fn SetWindowLongPtrA(window: HWND, index: i32, value: isize) -> isize; - } - - SetWindowLongPtrA(window, index, value) - } else { - panic!("Unsupported target OS"); - } -} - -#[allow(non_snake_case)] -unsafe fn GetWindowLongPtrA(window: HWND, index: i32) -> isize { - if cfg!(windows) { - #[link(name = "user32")] - extern "system" { - fn GetWindowLongPtrA(window: HWND, index: i32) -> isize; - } - - GetWindowLongPtrA(window, index) - } else { - panic!("Unsupported target OS"); - } + fn GetWindowLongPtrA(window: HWND, index: i32) -> isize; }