Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ members = [
"crates/perry-stdlib-static",
"docs/examples/_fixtures/native-libraries/my-bindings",
]
# Only build platform-independent crates by default.
# Platform-specific UI crates (perry-ui-macos, perry-ui-ios, etc.) must be built
# explicitly with -p on their target platform.
# Build only the host-independent product set by default.
# Platform UI manifests keep their source and dependencies behind target cfgs.
# Build each platform package explicitly for its applicable target.
default-members = [
"crates/perry",
"crates/perry-parser",
Expand Down
1 change: 1 addition & 0 deletions changelog.d/6761-multiplatform-workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Cross-platform workspace builds:** gate each platform UI crate and its native dependencies for the applicable Cargo target. Host workspace checks no longer require SDKs or system libraries for other platforms. Update the container Compose FFI for the current engine API.
2 changes: 1 addition & 1 deletion crates/perry-audio-miniaudio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ crate-type = ["rlib"]
[build-dependencies]
cc = "1"

[dependencies]
[target.'cfg(any(target_os = "linux", target_os = "windows", target_os = "android"))'.dependencies]
libc.workspace = true
23 changes: 8 additions & 15 deletions crates/perry-audio-miniaudio/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ fn main() {

let target = env::var("TARGET").unwrap_or_default();

// We compile miniaudio for every host, including Apple — Apple targets
// get the rlib but never link the symbols (perry-ui-macos owns the
// AVAudioEngine backend). Compiling here keeps `cargo check` /
// `cargo build -p perry-audio-miniaudio` clean on developer Macs.
let supported =
target.contains("linux") || target.contains("android") || target.contains("windows");
if !supported {
return;
}

// This backend supports Linux, Windows, and Android. Apple targets use
// the AVAudioEngine backend in their platform UI crates.
let mut build = cc::Build::new();
build
.file("vendor/miniaudio_impl.c")
Expand Down Expand Up @@ -48,17 +52,6 @@ fn main() {
// requirement explicit here so the rlib stands on its own.
println!("cargo:rustc-link-lib=ole32");
println!("cargo:rustc-link-lib=winmm");
} else if target.contains("apple") {
// Apple targets compile this crate (so the workspace builds
// cleanly on macOS developer machines) but should never link
// its symbols — perry-ui-macos provides the real backend
// backed by AVAudioEngine. Pull in the Core Audio frameworks
// anyway because miniaudio_impl.c references them in its
// Apple branch.
println!("cargo:rustc-link-lib=framework=CoreAudio");
println!("cargo:rustc-link-lib=framework=AudioToolbox");
println!("cargo:rustc-link-lib=framework=AudioUnit");
println!("cargo:rustc-link-lib=framework=CoreFoundation");
}

build.compile("miniaudio_impl");
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-audio-miniaudio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
//! PlaybackId 0x10000001..=0x1FFFFFFF — live ma_sound voice
//! Bus 0x20000001..=0x2FFFFFFF — ma_sound_group (0 = master)

#![cfg(any(target_os = "linux", target_os = "windows", target_os = "android"))]

use libc::{c_char, c_float, c_int, c_uint, c_void};
use std::cell::RefCell;
use std::ffi::CString;
Expand Down
1 change: 0 additions & 1 deletion crates/perry-codegen/tests/i64_spec_ternary_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn empty_opts() -> CompileOptions {
verify_native_regions: false,
disable_buffer_fast_path: false,
namespace_imports: Vec::new(),
namespace_reexport_named_imports: std::collections::HashSet::new(),
imported_classes: Vec::new(),
imported_enums: Vec::new(),
imported_async_funcs: std::collections::HashSet::new(),
Expand Down
28 changes: 10 additions & 18 deletions crates/perry-container-compose/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ fn parse_compose_file(file_ptr: *const StringHeader) -> Option<PathBuf> {
}

fn make_engine(files: Vec<PathBuf>) -> Result<Arc<ComposeEngine>, String> {
let config = crate::config::ProjectConfig {
files,
..Default::default()
};
let config = crate::config::ProjectConfig::new(files, None, Vec::new());
let proj = crate::project::ComposeProject::load(&config).map_err(|e| e.to_string())?;
let backend: Arc<dyn crate::backend::ContainerBackend> =
match block(crate::backend::detect_backend()) {
Expand Down Expand Up @@ -145,20 +142,18 @@ pub unsafe extern "C" fn js_compose_logs(
_follow: bool,
) -> *const StringHeader {
let files: Vec<PathBuf> = parse_compose_file(file_ptr).into_iter().collect();
let service: Option<String> = string_from_header(services_ptr)
let services: Vec<String> = string_from_header(services_ptr)
.and_then(|s| serde_json::from_str::<Vec<String>>(&s).ok())
.and_then(|v| v.into_iter().next());
.unwrap_or_default();
Comment thread
TheHypnoo marked this conversation as resolved.
Outdated

match make_engine(files) {
Err(e) => json_err(&e),
Ok(engine) => match block(engine.logs(service.as_deref(), None)) {
Ok(engine) => match block(engine.logs(&services, None)) {
Err(e) => json_err(&e.to_string()),
Ok(logs) => {
let stdout = logs.stdout.replace('"', "\\\"").replace('\n', "\\n");
let stderr = logs.stderr.replace('"', "\\\"").replace('\n', "\\n");
let payload = format!("{{\"stdout\":\"{}\",\"stderr\":\"{}\"}}", stdout, stderr);
json_ok(&payload)
}
Ok(logs) => match serde_json::to_string(&logs) {
Ok(payload) => json_ok(&payload),
Err(e) => json_err(&e.to_string()),
},
},
}
}
Expand All @@ -180,7 +175,7 @@ pub unsafe extern "C" fn js_compose_exec(

match make_engine(files) {
Err(e) => json_err(&e),
Ok(engine) => match block(engine.exec(&service, &cmd)) {
Ok(engine) => match block(engine.exec(&service, &cmd, None, None)) {
Err(e) => json_err(&e.to_string()),
Ok(result) => {
let stdout = result.stdout.replace('"', "\\\"").replace('\n', "\\n");
Expand All @@ -195,10 +190,7 @@ pub unsafe extern "C" fn js_compose_exec(
#[no_mangle]
pub unsafe extern "C" fn js_compose_config(file_ptr: *const StringHeader) -> *const StringHeader {
let files: Vec<PathBuf> = parse_compose_file(file_ptr).into_iter().collect();
let config = crate::config::ProjectConfig {
files,
..Default::default()
};
let config = crate::config::ProjectConfig::new(files, None, Vec::new());
match crate::project::ComposeProject::load(&config) {
Err(e) => json_err(&e.to_string()),
Ok(proj) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["rlib", "staticlib"]
[features]
geisterhand = []

[dependencies]
[target.'cfg(target_os = "android")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-audio-miniaudio = { workspace = true }
perry-runtime = { path = "../perry-runtime", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-android/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "android")]

// Issue #552: force libperry_ui_android.a to bundle perry-ext-sharp's
// `js_sharp_*` symbols (resize / jpeg / toBuffer / etc). Without this `extern
// crate` reference, the rlib dep would be optimized out and the stubs in
Expand Down
3 changes: 1 addition & 2 deletions crates/perry-ui-gtk4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workspace = true
[lib]
crate-type = ["rlib", "staticlib"]

[dependencies]
[target.'cfg(target_os = "linux")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
perry-audio-miniaudio = { workspace = true }
Expand Down Expand Up @@ -44,7 +44,6 @@ gstreamer-app = "0.25"
# Bluetooth headphones (#366). Linux-only; zbus has Linux-specific
# system deps that don't build on macOS / Windows hosts, so the crate
# stays gated behind cfg(target_os = "linux") in the source.
[target.'cfg(target_os = "linux")'.dependencies]
mpris-server = { version = "0.10", features = ["tokio"] }
tokio = { version = "1", features = ["rt", "sync", "time", "net", "io-util"] }
# perry/ui — system tray icon support via the StatusNotifierItem
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-gtk4/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "linux")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-ios/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = []
plugins = []
geisterhand = []

[dependencies]
[target.'cfg(target_os = "ios")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
perry-runtime = { path = "../perry-runtime", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-ios/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "ios")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-macos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = []
plugins = []
geisterhand = []

[dependencies]
[target.'cfg(target_os = "macos")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
base64.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-macos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "macos")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-tvos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = []
plugins = []
geisterhand = []

[dependencies]
[target.'cfg(target_os = "tvos")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
perry-runtime = { path = "../perry-runtime", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-tvos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "tvos")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-visionos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = []
plugins = []
geisterhand = []

[dependencies]
[target.'cfg(target_os = "visionos")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
perry-runtime = { path = "../perry-runtime", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-visionos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "visionos")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-watchos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = []
plugins = []
geisterhand = []

[dependencies]
[target.'cfg(target_os = "watchos")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
perry-runtime = { path = "../perry-runtime", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-watchos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! The fixed PerryWatchApp.swift queries this tree via FFI and renders
//! it as SwiftUI views reactively.

#![cfg(target_os = "watchos")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
2 changes: 1 addition & 1 deletion crates/perry-ui-windows-winui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ workspace = true
# symbols), so no symbol is lost by going through this crate.
crate-type = ["rlib", "staticlib"]

[dependencies]
[target.'cfg(target_os = "windows")'.dependencies]
# The entire current Windows backend. Re-exported wholesale (see src/lib.rs).
perry-ui-windows = { path = "../perry-ui-windows" }

Expand Down
2 changes: 2 additions & 0 deletions crates/perry-ui-windows-winui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
//! Tracks discussion #3486. Near-term Win32 polish on the default target lives
//! in #4681.

#![cfg(target_os = "windows")]

// Re-export the entire Win32 backend. For Rust consumers this exposes the same
// module API as `perry-ui-windows`; for the C ABI it is a no-op (the
// `#[no_mangle]` entry points are emitted when `perry-ui-windows` is compiled
Expand Down
9 changes: 4 additions & 5 deletions crates/perry-ui-windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workspace = true
[lib]
crate-type = ["rlib", "staticlib"]

[dependencies]
[target.'cfg(target_os = "windows")'.dependencies]
perry-ui = { path = "../perry-ui" }
perry-ui-testkit = { workspace = true }
perry-audio-miniaudio = { workspace = true }
Expand All @@ -35,10 +35,6 @@ qrcodegen = "1.8"
# (a version skew here is what broke the Windows build at v0.5.1180).
webview2-com = "=0.39"

[features]
geisterhand = []

[target.'cfg(target_os = "windows")'.dependencies]
# The `#[implement]` macro from `windows` expands to absolute
# `::windows_core::` paths, so the consuming crate must depend on
# `windows-core` directly or the COM authoring in drag_drop.rs fails to
Expand Down Expand Up @@ -92,3 +88,6 @@ windows = { version = "0.62", features = [
# GdipLoadImageFromStream on the main thread during WM_PAINT.
"Win32_Networking_WinHttp",
] }

[features]
geisterhand = []
2 changes: 2 additions & 0 deletions crates/perry-ui-windows/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_os = "windows")]

pub mod app;
pub mod audio;
pub mod audio_playback;
Expand Down
Loading