Skip to content

Commit

Permalink
macos test
Browse files Browse the repository at this point in the history
  • Loading branch information
oligamiq committed Dec 18, 2023
1 parent 122fe88 commit bc6ffd6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
".\\examples\\iphone\\Cargo.toml",
".\\examples\\common\\Cargo.toml"
],
"rust-analyzer.cargo.target": "aarch64-linux-android",
// "rust-analyzer.cargo.target": "aarch64-linux-android",
// "rust-analyzer.cargo.target": "x86_64-apple-ios",
// "rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu",
// "rust-analyzer.cargo.target": "wasm32-wasi",
"rust-analyzer.cargo.target": "x86_64-apple-darwin",
"cSpell.words": [
"binstall",
"COMPUTERNAME",
Expand Down
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-apple-darwin]
image = "ghcr.io/cross-rs/x86_64-apple-darwin-cross:local"
13 changes: 12 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios"))]

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (ubuntu-latest, beta, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (ubuntu-latest, stable, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (ubuntu-latest, nightly, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, nightly, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, nightly, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, beta, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, beta, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, stable, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, stable, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / clippy_android (ubuntu-latest, stable, android_test)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / clippy_android (ubuntu-latest, beta, android_test)

unneeded sub `cfg` when there is only one condition

Check failure on line 2 in build.rs

View workflow job for this annotation

GitHub Actions / clippy_android (ubuntu-latest, nightly, android_test)

unneeded sub `cfg` when there is only one condition
{
// println!("cargo:rustc-link-lib=framework=Foundation");

Expand All @@ -9,4 +9,15 @@ fn main() {
// println!("cargo:rustc-link-lib=framework=QuartzCore");
// println!("cargo:rustc-link-lib=framework=Security");
}

#[cfg(any(target_os = "macos"))]

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (ubuntu-latest, beta, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (ubuntu-latest, stable, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (ubuntu-latest, nightly, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, nightly, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, nightly, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, beta, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, beta, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, stable, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (windows-latest, stable, pc_test_target_tier2)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / clippy_android (ubuntu-latest, stable, android_test)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / clippy_android (ubuntu-latest, beta, android_test)

unneeded sub `cfg` when there is only one condition

Check failure on line 13 in build.rs

View workflow job for this annotation

GitHub Actions / clippy_android (ubuntu-latest, nightly, android_test)

unneeded sub `cfg` when there is only one condition
{
println!("cargo:rustc-link-lib=framework=Foundation");

println!("cargo:rustc-link-lib=framework=AppKit");

println!("cargo:rustc-link-lib=framework=CoreGraphics");
println!("cargo:rustc-link-lib=framework=QuartzCore");
println!("cargo:rustc-link-lib=framework=Security");
}
}
2 changes: 2 additions & 0 deletions examples/common/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-apple-darwin]
image = "ghcr.io/cross-rs/x86_64-apple-darwin-cross:local"
11 changes: 9 additions & 2 deletions rust/macos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
mod nick_name;
pub use self::nick_name::NickName;
mod objc;
pub use objc::nick_name::NickName;

Check failure on line 2 in rust/macos/mod.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, 1.68.0, pc_test_target_tier2)

`objc` is ambiguous

Check failure on line 2 in rust/macos/mod.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, 1.68.0, pc_test_target_tier1)

`objc` is ambiguous

Check failure on line 2 in rust/macos/mod.rs

View workflow job for this annotation

GitHub Actions / run_pc (macos-latest, 1.68.0, pc_run)

`objc` is ambiguous

mod util {
use objc::runtime::NSObject;

#[allow(non_camel_case_types)]
pub(crate) type id = *const NSObject;
}
1 change: 1 addition & 0 deletions rust/macos/objc/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod nick_name;
16 changes: 14 additions & 2 deletions rust/macos/nick_name.rs → rust/macos/objc/nick_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ use std::ffi::CStr;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::os::unix::ffi::OsStrExt;
use std::sync::Arc;
use std::sync::RwLock;

use objc::class;
use objc::msg_send;

use crate::macos::util::id;
const _POSIX_HOST_NAME_MAX: libc::c_long = 255;

pub struct NickName {}
pub struct NickName(pub Arc<RwLock<id>>);

impl Debug for NickName {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
Expand All @@ -16,7 +23,12 @@ impl Debug for NickName {

impl NickName {
pub fn new() -> crate::Result<Self> {
Ok(Self {})
Ok(Self(Arc::new(RwLock::new(unsafe {
// Create an instance of the UIDevice class
let superclass = class!(NSApplication);

Check failure on line 28 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, beta, pc_test_target_tier2)

unused variable: `superclass`

Check failure on line 28 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, nightly, pc_test_target_tier2)

unused variable: `superclass`

Check failure on line 28 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, stable, pc_test_target_tier2)

unused variable: `superclass`

Check failure on line 28 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, stable, pc_test_target_tier1)

unused variable: `superclass`

Check failure on line 28 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, beta, pc_test_target_tier1)

unused variable: `superclass`

Check failure on line 28 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, nightly, pc_test_target_tier1)

unused variable: `superclass`

msg_send![class!(NSApplication), sharedApplication]
}))))
}

pub fn get(&self) -> crate::Result<String> {
Expand Down

0 comments on commit bc6ffd6

Please sign in to comment.