Skip to content

Commit 8334f7f

Browse files
authored
feat: device hot-reload, tools-relative adb, auto port bind (#3586)
* wip: bind to 0.0.0.0 instead of 127.0.0.1 * dont hang in background - ignore suspend commands when tty is disabled * use system adb * pass configs through to android mobile launch * fix: line sizes + clear pushes frame * dont resume window state on mobile * fix screen sizing for ipad * attempt and fail to implement codesigning * Clippy and note about safety in android bindings
1 parent e199e86 commit 8334f7f

22 files changed

+620
-212
lines changed

Cargo.lock

+43-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli-config/src/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,10 @@ macro_rules! read_env_config {
9999
/// For reference, the devserver typically lives on `127.0.0.1:8080` and serves the devserver websocket
100100
/// on `127.0.0.1:8080/_dioxus`.
101101
pub fn devserver_raw_addr() -> Option<SocketAddr> {
102-
// On android, 10.0.2.2 is the default loopback
103-
if cfg!(target_os = "android") {
104-
return Some("10.0.2.2:8080".parse().unwrap());
105-
}
106-
107102
std::env::var(DEVSERVER_RAW_ADDR_ENV)
108-
.map(|s| s.parse().ok())
103+
.unwrap_or_else(|_| "127.0.0.1:8080".to_string())
104+
.parse()
109105
.ok()
110-
.flatten()
111106
}
112107

113108
/// Get the address of the devserver for use over a websocket

packages/cli/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ tauri-bundler = { workspace = true }
122122
include_dir = "0.7.4"
123123
flate2 = "1.0.35"
124124
tar = "0.4.43"
125+
local-ip-address = "0.6.3"
125126
dircpy = "0.3.19"
127+
plist = "1.7.0"
126128

127129
[build-dependencies]
128130
built = { version = "=0.7.4", features = ["git2"] }

packages/cli/assets/ios/ios.plist.hbs

+50-18
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,59 @@
33
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
44
<plist version="1.0">
55
<dict>
6-
<key>CFBundleDisplayName</key>
7-
<string>{{ display_name }}</string>
6+
<key>CFBundleDisplayName</key>
7+
<string>{{ display_name }}</string>
88

9-
<key>CFBundleExecutable</key>
10-
<string>{{ executable_name }}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>{{ executable_name }}</string>
1111

12-
<key>CFBundleIdentifier</key>
13-
<string>{{ bundle_identifier }}</string>
12+
<key>CFBundleIdentifier</key>
13+
<string>{{ bundle_identifier }}</string>
1414

15-
<key>CFBundleName</key>
16-
<string>{{ bundle_name }}</string>
15+
<key>CFBundleName</key>
16+
<string>{{ bundle_name }}</string>
1717

18-
<key>CFBundleVersion</key>
19-
<string>0.1.0</string>
20-
<key>CFBundleShortVersionString</key>
21-
<string>0.1.0</string>
22-
<key>CFBundleDevelopmentRegion</key>
23-
<string>en_US</string>
24-
<key>UILaunchStoryboardName</key>
25-
<string></string>
26-
<key>LSRequiresIPhoneOS</key>
27-
<true/>
18+
<key>CFBundleVersion</key>
19+
<string>0.1.0</string>
20+
<key>CFBundleShortVersionString</key>
21+
<string>0.1.0</string>
22+
<key>CFBundleDevelopmentRegion</key>
23+
<string>en_US</string>
24+
<key>UILaunchStoryboardName</key>
25+
<string>LaunchScreen</string>
26+
<key>LSRequiresIPhoneOS</key>
27+
<true/>
28+
<key>UISupportsTrueScreenSizeOnMac</key>
29+
<true/>
30+
<key>UIRequiredDeviceCapabilities</key>
31+
<array>
32+
<string>arm64</string>
33+
<string>metal</string>
34+
</array>
35+
<key>UIDeviceFamily</key>
36+
<array>
37+
<integer>1</integer>
38+
<integer>2</integer>
39+
</array>
40+
<key>CFBundleSupportedPlatforms</key>
41+
<array>
42+
<string>iPhoneOS</string>
43+
<string>iPadOS</string>
44+
</array>
45+
<key>UILaunchStoryboardName</key>
46+
<string>LaunchScreen</string>
47+
<key>UISupportedInterfaceOrientations</key>
48+
<array>
49+
<string>UIInterfaceOrientationPortrait</string>
50+
<string>UIInterfaceOrientationLandscapeLeft</string>
51+
<string>UIInterfaceOrientationLandscapeRight</string>
52+
</array>
53+
<key>UISupportedInterfaceOrientations~ipad</key>
54+
<array>
55+
<string>UIInterfaceOrientationPortrait</string>
56+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
57+
<string>UIInterfaceOrientationLandscapeLeft</string>
58+
<string>UIInterfaceOrientationLandscapeRight</string>
59+
</array>
2860
</dict>
2961
</plist>

packages/cli/src/cli/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl BuildArgs {
156156
if self.platform == Some(Platform::Android) && self.target_args.arch.is_none() {
157157
tracing::debug!("No android arch provided, attempting to auto detect.");
158158

159-
let arch = Arch::autodetect().await;
159+
let arch = DioxusCrate::autodetect_android_arch().await;
160160

161161
// Some extra logs
162162
let arch = match arch {

packages/cli/src/cli/serve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ impl ServeArgs {
9696
}
9797

9898
pub(crate) fn is_interactive_tty(&self) -> bool {
99-
use crossterm::tty::IsTty;
100-
std::io::stdout().is_tty() && self.interactive.unwrap_or(true)
99+
use std::io::IsTerminal;
100+
std::io::stdout().is_terminal() && self.interactive.unwrap_or(true)
101101
}
102102

103103
pub(crate) fn should_proxy_build(&self) -> bool {

packages/cli/src/cli/target.rs

-44
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use super::*;
2-
use once_cell::sync::OnceCell;
32
use std::path::Path;
4-
use tokio::process::Command;
53

64
/// Information about the target to build
75
#[derive(Clone, Debug, Default, Deserialize, Parser)]
@@ -73,48 +71,6 @@ pub(crate) enum Arch {
7371
}
7472

7573
impl Arch {
76-
pub(crate) async fn autodetect() -> Option<Self> {
77-
// Try auto detecting arch through adb.
78-
static AUTO_ARCH: OnceCell<Option<Arch>> = OnceCell::new();
79-
80-
match AUTO_ARCH.get() {
81-
Some(a) => *a,
82-
None => {
83-
// TODO: Wire this up with --device flag. (add `-s serial`` flag before `shell` arg)
84-
let output = Command::new("adb")
85-
.arg("shell")
86-
.arg("uname")
87-
.arg("-m")
88-
.output()
89-
.await;
90-
91-
let out = match output {
92-
Ok(o) => o,
93-
Err(e) => {
94-
tracing::debug!("ADB command failed: {:?}", e);
95-
return None;
96-
}
97-
};
98-
99-
// Parse ADB output
100-
let Ok(out) = String::from_utf8(out.stdout) else {
101-
tracing::debug!("ADB returned unexpected data.");
102-
return None;
103-
};
104-
let trimmed = out.trim().to_string();
105-
tracing::trace!("ADB Returned: `{trimmed:?}`");
106-
107-
// Set the cell
108-
let arch = Arch::try_from(trimmed).ok();
109-
AUTO_ARCH
110-
.set(arch)
111-
.expect("the cell should have been checked empty by the match condition");
112-
113-
arch
114-
}
115-
}
116-
}
117-
11874
pub(crate) fn android_target_triplet(&self) -> &'static str {
11975
match self {
12076
Arch::Arm => "armv7-linux-androideabi",

packages/cli/src/config/serve.rs

+4-22
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,13 @@ use clap::Parser;
44
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};
55

66
/// The arguments for the address the server will run on
7-
#[derive(Clone, Debug, Parser)]
7+
#[derive(Clone, Debug, Default, Parser)]
88
pub(crate) struct AddressArguments {
99
/// The port the server will run on
1010
#[clap(long)]
11-
#[clap(default_value_t = default_port())]
12-
pub(crate) port: u16,
11+
pub(crate) port: Option<u16>,
1312

1413
/// The address the server will run on
15-
#[clap(long, default_value_t = default_address())]
16-
pub(crate) addr: std::net::IpAddr,
17-
}
18-
19-
impl Default for AddressArguments {
20-
fn default() -> Self {
21-
Self {
22-
port: default_port(),
23-
addr: default_address(),
24-
}
25-
}
26-
}
27-
28-
fn default_port() -> u16 {
29-
8080
30-
}
31-
32-
fn default_address() -> IpAddr {
33-
IpAddr::V4(std::net::Ipv4Addr::new(127, 0, 0, 1))
14+
#[clap(long)]
15+
pub(crate) addr: Option<std::net::IpAddr>,
3416
}

0 commit comments

Comments
 (0)