Skip to content

Commit

Permalink
Linux build support (#2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Jan 18, 2023
1 parent 17a5f00 commit 2266e23
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
cargo clippy -p test_reserved &&
cargo clippy -p test_resources &&
cargo clippy -p test_return_struct &&
cargo clippy -p test_simple_component &&
cargo clippy -p test_string_param &&
cargo clippy -p test_structs &&
cargo clippy -p test_sys &&
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: linux

on:
pull_request:
push:
branches:
- master

env:
RUSTFLAGS: -Dwarnings

jobs:
cargo_windows:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update toolchain
run: rustup update --no-self-update stable && rustup default stable
- name: Run cargo build
run: cargo build -p test_simple_component --target x86_64-unknown-linux-gnu
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ jobs:
cargo test --target ${{ matrix.target }} -p test_enums &&
cargo test --target ${{ matrix.target }} -p test_error &&
cargo test --target ${{ matrix.target }} -p test_event &&
cargo clean &&
cargo test --target ${{ matrix.target }} -p test_extensions &&
cargo clean &&
cargo test --target ${{ matrix.target }} -p test_handles &&
cargo test --target ${{ matrix.target }} -p test_helpers &&
cargo test --target ${{ matrix.target }} -p test_implement &&
Expand All @@ -151,6 +151,7 @@ jobs:
cargo test --target ${{ matrix.target }} -p test_reserved &&
cargo test --target ${{ matrix.target }} -p test_resources &&
cargo test --target ${{ matrix.target }} -p test_return_struct &&
cargo test --target ${{ matrix.target }} -p test_simple_component &&
cargo test --target ${{ matrix.target }} -p test_string_param &&
cargo test --target ${{ matrix.target }} -p test_structs &&
cargo test --target ${{ matrix.target }} -p test_sys &&
Expand Down
13 changes: 12 additions & 1 deletion crates/libs/windows/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ macro_rules! link {
)
}

#[cfg(not(windows_raw_dylib))]
#[cfg(all(windows, not(windows_raw_dylib)))]
#[macro_export]
#[doc(hidden)]
macro_rules! link {
Expand All @@ -156,4 +156,15 @@ macro_rules! link {
)
}

#[cfg(all(not(windows), not(windows_raw_dylib)))]
#[macro_export]
#[doc(hidden)]
macro_rules! link {
($library:literal $abi:literal fn $name:ident($($arg:ident: $argty:ty),*)->$ret:ty) => (
extern $abi {
pub fn $name($($arg: $argty),*) -> $ret;
}
)
}

pub use crate::link;
2 changes: 1 addition & 1 deletion crates/tests/component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl IActivationFactory_Impl for ClassFactory {
}

#[no_mangle]
unsafe extern "stdcall" fn DllGetActivationFactory(name: ManuallyDrop<HSTRING>, result: *mut *mut std::ffi::c_void) -> HRESULT {
unsafe extern "system" fn DllGetActivationFactory(name: ManuallyDrop<HSTRING>, result: *mut *mut std::ffi::c_void) -> HRESULT {
let factory: Option<IActivationFactory> = match name.unwrap().to_string().as_str() {
"test_component.Class" => Some(ClassFactory.into()),
_ => None,
Expand Down
13 changes: 13 additions & 0 deletions crates/tests/simple_component/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "test_simple_component"
version = "0.0.0"
edition = "2018"

[lib]
crate-type = ["cdylib"]

[dependencies.windows]
path = "../../libs/windows"
features = [
"Win32_Foundation",
]
7 changes: 7 additions & 0 deletions crates/tests/simple_component/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use windows::{core::*, Win32::Foundation::*};

#[no_mangle]
unsafe extern "system" fn DllGetActivationFactory(_name: ManuallyDrop<HSTRING>, result: *mut *mut std::ffi::c_void) -> HRESULT {
*result = std::ptr::null_mut();
CLASS_E_CLASSNOTAVAILABLE
}

0 comments on commit 2266e23

Please sign in to comment.