Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

build(cua-driver): remove macOS local installer warnings (#5920)

Francesco Bonacci9a3c33ca14c7
diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/build.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/build.rs
index 9f62ee6662..de9ed1cc17 100644
--- a/libs/cua-driver/rust/crates/cua-driver-sdk/build.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/build.rs
@@ -8,12 +8,16 @@ fn main() {
// loadable by Python, Node, and other hosts. @loader_path also permits
// a future package to colocate a back-deployed Swift runtime without
// changing the public ABI or loader contract.
- println!("cargo:rustc-cdylib-link-arg=-Wl,-rpath,/usr/lib/swift");
- println!("cargo:rustc-cdylib-link-arg=-Wl,-rpath,@loader_path");
-
- // Cargo links this crate's unit-test harness as an executable rather
- // than a cdylib, so mirror the runtime paths for that final artifact.
- println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
+ // rustc-link-arg applies to both the cdylib and unit-test executable.
+ // The enclosing workspace may already supply the Swift path via
+ // rustflags (for example cua-spacesd); avoid emitting it twice.
+ let rustflags = std::env::var("CARGO_ENCODED_RUSTFLAGS").unwrap_or_default();
+ if !rustflags
+ .split('\x1f')
+ .any(|arg| arg == "link-arg=-Wl,-rpath,/usr/lib/swift")
+ {
+ println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
+ }
println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path");
}
}
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/document_edit.rs b/libs/cua-driver/rust/crates/platform-macos/src/document_edit.rs
index dd919c71c2..b302f53cd5 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/document_edit.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/document_edit.rs
@@ -18,7 +18,8 @@
use std::time::Duration;
use crate::ax::bindings::{
- copy_element_attr, copy_string_attr, AXUIElementRef, AXUIElementSetAttributeValue,
+ copy_element_attr, copy_string_attr, kAXValueCFRangeType, AXUIElementRef,
+ AXUIElementSetAttributeValue, AXValueCreate,
};
/// What the document's edited mark showed after an AX text write.
@@ -60,12 +61,6 @@ impl DocumentEdited {
}
}
-#[link(name = "ApplicationServices", kind = "framework")]
-extern "C" {
- fn AXValueCreate(the_type: u32, value_ptr: *const std::ffi::c_void) -> *const std::ffi::c_void;
-}
-const AX_VALUE_CF_RANGE: u32 = 4;
-
#[repr(C)]
struct CfRange {
location: isize,
@@ -221,7 +216,7 @@ unsafe fn caret_to_end_of(element: AXUIElementRef) {
location: len as isize,
length: 0,
};
- let value = AXValueCreate(AX_VALUE_CF_RANGE, &range as *const CfRange as *const _);
+ let value = AXValueCreate(kAXValueCFRangeType, &range as *const CfRange as *const _);
if !value.is_null() {
use core_foundation::{base::TCFType, string::CFString};
let attr = CFString::new("AXSelectedTextRange");
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs
index 8503db326f..cbc7504cec 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs
@@ -148,10 +148,9 @@ fn press_error_may_have_acted(err: crate::ax::bindings::AXError) -> bool {
use crate::ax::bindings::{
kAXErrorActionUnsupported, kAXErrorAttributeUnsupported, kAXErrorFailure,
};
- matches!(
- err,
- kAXErrorFailure | kAXErrorAttributeUnsupported | kAXErrorActionUnsupported
- )
+ err == kAXErrorFailure
+ || err == kAXErrorAttributeUnsupported
+ || err == kAXErrorActionUnsupported
}
/// Whether a toggle's value moving from `before` to `now` is what pressing it