Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5905bce
Add --renderer argument to the CLI
nicoburns Jun 24, 2025
0f0826f
Make `--platform native` work
nicoburns Jun 30, 2025
6332252
Emit `krates` error when cargo metadata fails
jkelleyrtp Jul 1, 2025
c806365
Reinstate default "desktop" feature for examples
nicoburns Jul 2, 2025
72a32a0
Remove commented 'no platform specified' error
nicoburns Jul 2, 2025
51b259b
use the target tripple and bundle format as the source of truth for t…
ealmloff Jul 8, 2025
59dc4d0
resolve renderer and bundle format
ealmloff Jul 8, 2025
4594dff
add shorthand flags
ealmloff Jul 8, 2025
11b1539
add headings to the help for shorthands
ealmloff Jul 8, 2025
40ae4e7
Merge branch 'remote-origin' into cli-renderer-flag
ealmloff Jul 8, 2025
f77f371
resolve the renderer from the target triple if it isn't passed
ealmloff Jul 8, 2025
cef67e7
make value after --fullstack optional
ealmloff Jul 8, 2025
a073579
convert desktop -> mobile when targeting mobile webview
ealmloff Jul 8, 2025
e01dc1d
use the new shorthand flags in the playwright tests
ealmloff Jul 8, 2025
e2a6677
fix clippy
ealmloff Jul 8, 2025
79ce1c2
Merge remote-tracking branch 'origin/main' into cli-renderer-flag
jkelleyrtp Jul 14, 2025
c5851ed
merge fix
jkelleyrtp Jul 14, 2025
256153b
cleanup merge conflicts
jkelleyrtp Jul 14, 2025
bd28449
fix clippy
ealmloff Jul 14, 2025
e11ff9b
Merge remote-tracking branch 'origin/main' into cli-renderer-flag
jkelleyrtp Jul 15, 2025
860d3de
remove nit
jkelleyrtp Jul 15, 2025
0c78865
restore platform as a legacy argument
ealmloff Jul 21, 2025
2d6f796
improve help message
ealmloff Jul 21, 2025
873ccf5
Merge branch 'remote-origin' into cli-renderer-flag
ealmloff Jul 21, 2025
ec0f180
vendor openssl on native, pin server_fn
jkelleyrtp Jul 22, 2025
0b9eb8c
print build errors as warnings
jkelleyrtp Jul 22, 2025
081c1a7
add --desktop arg compat
jkelleyrtp Jul 22, 2025
84e3685
adjust cli headings
jkelleyrtp Jul 22, 2025
b4c2af6
prefer self.is_wasm_or_wasi()
jkelleyrtp Jul 22, 2025
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
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ lru = "0.16.0"
async-trait = "0.1.88"
axum = { version = "0.8.4", default-features = false }
axum-server = { version = "0.7.2", default-features = false }
server_fn = { version = "0.8.2", default-features = false }
server_fn_macro = { version = "0.8.2" }
server_fn = { version = "=0.8.3", default-features = false }
server_fn_macro = { version = "=0.8.3" }
tower = "0.5.2"
http = "1.3.1"
notify = { version = "8.1.0" }
Expand Down
82 changes: 41 additions & 41 deletions packages/cli/src/build/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
serve::WebServer, BuildArtifacts, BuildRequest, BuildStage, BuilderUpdate, Platform,
serve::WebServer, BuildArtifacts, BuildRequest, BuildStage, BuilderUpdate, BundleFormat,
ProgressRx, ProgressTx, Result, RustcArgs, StructuredOutput,
};
use anyhow::{bail, Context};
Expand All @@ -16,6 +16,7 @@ use std::{
process::Stdio,
};
use subsecond_types::JumpTable;
use target_lexicon::Architecture;
use tokio::{
io::{AsyncBufReadExt, BufReader, Lines},
process::{Child, ChildStderr, ChildStdout, Command},
Expand Down Expand Up @@ -189,7 +190,7 @@ impl AppBuilder {
match bundle {
Ok(Ok(bundle)) => BuilderUpdate::BuildReady { bundle },
Ok(Err(err)) => BuilderUpdate::BuildFailed { err },
Err(err) => BuilderUpdate::BuildFailed { err: anyhow::anyhow!("Build panicked! {:#?}", err) },
Err(err) => BuilderUpdate::BuildFailed { err: anyhow::anyhow!("Build panicked! {err:#?}") },
}
},
Some(Ok(Some(msg))) = OptionFuture::from(self.stdout.as_mut().map(|f| f.next_line())) => {
Expand Down Expand Up @@ -300,7 +301,13 @@ impl AppBuilder {
// for all other platforms, we need to use the ASLR reference to know where to insert the patch.
let aslr_reference = match self.aslr_reference {
Some(val) => val,
None if self.build.platform == Platform::Web => 0,
None if matches!(
self.build.triple.architecture,
Architecture::Wasm32 | Architecture::Wasm64
) =>
{
0
}
None => {
tracing::warn!(
"Ignoring hotpatch since there is no ASLR reference. Is the client connected?"
Expand Down Expand Up @@ -542,18 +549,18 @@ impl AppBuilder {
);

// We try to use stdin/stdout to communicate with the app
match self.build.platform {
match self.build.bundle {
// Unfortunately web won't let us get a proc handle to it (to read its stdout/stderr) so instead
// use use the websocket to communicate with it. I wish we could merge the concepts here,
// like say, opening the socket as a subprocess, but alas, it's simpler to do that somewhere else.
Platform::Web => {
BundleFormat::Web => {
// Only the first build we open the web app, after that the user knows it's running
if open_browser {
self.open_web(open_address.unwrap_or(devserver_ip));
}
}

Platform::Ios => {
BundleFormat::Ios => {
if self.build.device {
self.codesign_ios().await?;
self.open_ios_device().await?
Expand All @@ -562,16 +569,15 @@ impl AppBuilder {
}
}

Platform::Android => {
BundleFormat::Android => {
self.open_android_sim(false, devserver_ip, envs).await?;
}

// These are all just basically running the main exe, but with slightly different resource dir paths
Platform::Server
| Platform::MacOS
| Platform::Windows
| Platform::Linux
| Platform::Liveview => self.open_with_main_exe(envs, args)?,
BundleFormat::Server
| BundleFormat::MacOS
| BundleFormat::Windows
| BundleFormat::Linux => self.open_with_main_exe(envs, args)?,
};

self.builds_opened += 1;
Expand Down Expand Up @@ -661,7 +667,7 @@ impl AppBuilder {
}

// If the emulator is android, we need to copy the asset to the device with `adb push asset /data/local/tmp/dx/assets/filename.ext`
if self.build.platform == Platform::Android {
if self.build.bundle == BundleFormat::Android {
let bundled_name = PathBuf::from(bundled.bundled_path());
_ = self.copy_file_to_android_tmp(&from, &bundled_name).await;
}
Expand All @@ -684,7 +690,7 @@ impl AppBuilder {
let mut jump_table = crate::build::create_jump_table(&new, &triple, cache)?;

// If it's android, we need to copy the assets to the device and then change the location of the patch
if self.build.platform == Platform::Android {
if self.build.bundle == BundleFormat::Android {
jump_table.lib = self
.copy_file_to_android_tmp(&new, &(PathBuf::from(new.file_name().unwrap())))
.await?;
Expand Down Expand Up @@ -777,7 +783,7 @@ impl AppBuilder {
}

// If the emulator is android, we need to copy the asset to the device with `adb push asset /data/local/tmp/dx/assets/filename.ext`
if self.build.platform == Platform::Android {
if self.build.bundle == BundleFormat::Android {
_ = self
.copy_file_to_android_tmp(&changed_file, &bundled_name)
.await;
Expand Down Expand Up @@ -972,7 +978,7 @@ impl AppBuilder {
.await?;

if !output.status.success() {
bail!("Failed to install app: {:?}", output);
bail!("Failed to install app: {output:?}");
}

let json: Value = serde_json::from_str(&std::fs::read_to_string(tmpfile.path())?)
Expand Down Expand Up @@ -1007,7 +1013,7 @@ impl AppBuilder {
.await?;

if !output.status.success() {
bail!("Failed to launch app: {:?}", output);
bail!("Failed to launch app: {output:?}");
}

let json: Value = serde_json::from_str(&std::fs::read_to_string(tmpfile.path())?)
Expand All @@ -1032,7 +1038,7 @@ impl AppBuilder {
.await?;

if !output.status.success() {
bail!("Failed to resume app: {:?}", output);
bail!("Failed to resume app: {output:?}");
}

Ok(())
Expand Down Expand Up @@ -1255,8 +1261,8 @@ We checked the folders:
let port = devserver_socket.port();
if let Err(e) = Command::new(&adb)
.arg("reverse")
.arg(format!("tcp:{}", port))
.arg(format!("tcp:{}", port))
.arg(format!("tcp:{port}"))
.arg(format!("tcp:{port}"))
.output()
.await
{
Expand Down Expand Up @@ -1362,18 +1368,14 @@ We checked the folders:
let mut main_exe = self.build.main_exe();

// The requirement here is based on the platform, not necessarily our current architecture.
let requires_entropy = match self.build.platform {
let requires_entropy = match self.build.bundle {
// When running "bundled", we don't need entropy
Platform::Web => false,
Platform::MacOS => false,
Platform::Ios => false,
Platform::Android => false,
BundleFormat::Web | BundleFormat::MacOS | BundleFormat::Ios | BundleFormat::Android => {
false
}

// But on platforms that aren't running as "bundled", we do.
Platform::Windows => true,
Platform::Linux => true,
Platform::Server => true,
Platform::Liveview => true,
BundleFormat::Windows | BundleFormat::Linux | BundleFormat::Server => true,
};

if requires_entropy || crate::devcfg::should_force_entropy() {
Expand Down Expand Up @@ -1443,24 +1445,22 @@ We checked the folders:
}

pub(crate) async fn open_debugger(&mut self, server: &WebServer) -> Result<()> {
let url = match self.build.platform {
Platform::MacOS
| Platform::Windows
| Platform::Linux
| Platform::Server
| Platform::Liveview => {
let url = match self.build.bundle {
BundleFormat::MacOS
| BundleFormat::Windows
| BundleFormat::Linux
| BundleFormat::Server => {
let Some(Some(pid)) = self.child.as_mut().map(|f| f.id()) else {
tracing::warn!("No process to attach debugger to");
return Ok(());
};

format!(
"vscode://vadimcn.vscode-lldb/launch/config?{{'request':'attach','pid':{}}}",
pid
"vscode://vadimcn.vscode-lldb/launch/config?{{'request':'attach','pid':{pid}}}"
)
}

Platform::Web => {
BundleFormat::Web => {
// code --open-url "vscode://DioxusLabs.dioxus/debugger?uri=http://127.0.0.1:8080"
// todo - debugger could open to the *current* page afaik we don't have a way to have that info
let address = server.devserver_address();
Expand All @@ -1474,7 +1474,7 @@ We checked the folders:
format!("vscode://DioxusLabs.dioxus/debugger?uri={protocol}://{address}{base_path}")
}

Platform::Ios => {
BundleFormat::Ios => {
let Some(pid) = self.pid else {
tracing::warn!("No process to attach debugger to");
return Ok(());
Expand Down Expand Up @@ -1513,7 +1513,7 @@ We checked the folders:
// (lldb) settings append target.exec-search-paths target/dx/tw6/debug/android/app/app/src/main/jniLibs/arm64-v8a/libdioxusmain.so
// (lldb) process handle SIGSEGV --pass true --stop false --notify true (otherwise the java threads cause crash)
//
Platform::Android => {
BundleFormat::Android => {
// adb push ./sdk/ndk/29.0.13113456/toolchains/llvm/prebuilt/darwin-x86_64/lib/clang/20/lib/linux/aarch64/lldb-server /tmp
// adb shell "/tmp/lldb-server --server --listen ..."
// "vscode://vadimcn.vscode-lldb/launch/config?{{'request':'connect','port': {}}}",
Expand Down Expand Up @@ -1601,7 +1601,7 @@ We checked the folders:
}
};

tracing::info!("Opening debugger for [{}]: {url}", self.build.platform);
tracing::info!("Opening debugger for [{}]: {url}", self.build.bundle);

_ = tokio::process::Command::new("code")
.arg("--open-url")
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/build/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl BuildContext {
}

pub(crate) fn status_build_error(&self, line: String) {
tracing::debug!(dx_src = ?TraceSrc::Cargo, "{line}");
tracing::warn!(dx_src = ?TraceSrc::Cargo, "{line}");
}

pub(crate) fn status_build_message(&self, line: String) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/build/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ pub fn create_undefined_symbol_stub(
let mut defined_symbols = HashSet::new();

for path in sorted {
let bytes = std::fs::read(path).with_context(|| format!("failed to read {:?}", path))?;
let bytes = std::fs::read(path).with_context(|| format!("failed to read {path:?}"))?;
let file = File::parse(bytes.deref() as &[u8])?;
for symbol in file.symbols() {
if symbol.is_undefined() {
Expand Down Expand Up @@ -853,7 +853,7 @@ pub fn create_undefined_symbol_stub(
if aslr_reference < aslr_ref_address {
return Err(PatchError::InvalidModule(
format!(
"ASLR reference is less than the main module's address - is there a `main`?. {:x} < {:x}", aslr_reference, aslr_ref_address )
"ASLR reference is less than the main module's address - is there a `main`?. {aslr_reference:x} < {aslr_ref_address:x}" )
));
}

Expand Down
Loading
Loading