From 55d5ec3fc89e05d4c9d7f1d94ebfeab99c64494e Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 5 Nov 2025 18:57:28 +0100 Subject: [PATCH] feat: add --raw-json-diagnostics flag to dx build (#4887) This flag allows users to get the raw JSON output from cargo instead of having it processed by Dioxus. This is useful for integration with other tools that expect cargo's native JSON diagnostic format. When enabled, cargo's JSON messages are relayed directly to stdout while still allowing DX to track essential build information internally. Usage: dx build --raw-json-diagnostics --- packages/cli/src/build/request.rs | 7 +++++++ packages/cli/src/cli/target.rs | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/cli/src/build/request.rs b/packages/cli/src/build/request.rs index cf1233585..1892a1e19 100644 --- a/packages/cli/src/build/request.rs +++ b/packages/cli/src/build/request.rs @@ -399,6 +399,7 @@ pub(crate) struct BuildRequest { pub(crate) apple_entitlements: Option, pub(crate) apple_team_id: Option, pub(crate) session_cache_dir: PathBuf, + pub(crate) raw_json_diagnostics: bool, } /// dx can produce different "modes" of a build. A "regular" build is a "base" build. The Fat and Thin @@ -1038,6 +1039,7 @@ impl BuildRequest { inject_loading_scripts: args.inject_loading_scripts, apple_entitlements: args.apple_entitlements.clone(), apple_team_id: args.apple_team_id.clone(), + raw_json_diagnostics: args.raw_json_diagnostics, }) } @@ -1195,6 +1197,11 @@ impl BuildRequest { else => break, }; + // If raw JSON diagnostics are requested, relay the line directly + if self.raw_json_diagnostics { + println!("{}", line); + } + let Some(Ok(message)) = Message::parse_stream(std::io::Cursor::new(line)).next() else { continue; }; diff --git a/packages/cli/src/cli/target.rs b/packages/cli/src/cli/target.rs index d62c5acad..5f8bcb485 100644 --- a/packages/cli/src/cli/target.rs +++ b/packages/cli/src/cli/target.rs @@ -161,6 +161,14 @@ pub(crate) struct TargetArgs { /// See for more information. #[clap(long, help_heading = HELP_HEADING)] pub(crate) windows_subsystem: Option, + + /// Output raw JSON diagnostics from cargo instead of processing them [default: false] + /// + /// When enabled, cargo's JSON output will be relayed directly to stdout without any processing or formatting by DX. + /// This is useful for integration with other tools that expect cargo's raw JSON format. + #[clap(long, help_heading = HELP_HEADING)] + #[serde(default)] + pub(crate) raw_json_diagnostics: bool, } impl Anonymized for TargetArgs { @@ -186,6 +194,7 @@ impl Anonymized for TargetArgs { "base_path": self.base_path.is_some(), "cargo_args": self.cargo_args.is_some(), "rustc_args": self.rustc_args.is_some(), + "raw_json_diagnostics": self.raw_json_diagnostics, }} } }