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
This commit is contained in:
Amos Wenger authored and GitHub committed 2025-11-05 14:57:28 -03:00
1 parent 3ac4230ecf
commit 55d5ec3fc8
2 files changed
+16

No files matched your search

+7
View File
@@ -399,6 +399,7 @@ pub(crate) struct BuildRequest {
pub(crate) apple_entitlements: Option<PathBuf>,
pub(crate) apple_team_id: Option<String>,
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;
};