Fix --args and handle merging in @server and @client (#4212)

* Pass args after -- to the executable during run and serve

* fix clippy

* switch to accepting a string argument for subcommand compatibility

* Handle merging with `@server` and `@client`

* fix clippy

* fix formatting

* always build into the client package

* fix clippy

* more clippy fixes
This commit is contained in:
Evan Almloff authored and GitHub committed 2025-06-17 18:17:06 -07:00
1 parent 6fcb496fd5
commit 3bf8f09c65
10 files changed
+291 -207

No files matched your search

+5 -2
View File
@@ -417,6 +417,7 @@ impl AppBuilder {
}
}
#[allow(clippy::too_many_arguments)]
pub(crate) async fn open(
&mut self,
devserver_ip: SocketAddr,
@@ -425,6 +426,7 @@ impl AppBuilder {
open_browser: bool,
always_on_top: bool,
build_id: BuildId,
args: &[String],
) -> Result<()> {
let krate = &self.build;
@@ -501,7 +503,7 @@ impl AppBuilder {
| Platform::MacOS
| Platform::Windows
| Platform::Linux
| Platform::Liveview => self.open_with_main_exe(envs)?,
| Platform::Liveview => self.open_with_main_exe(envs, args)?,
};
self.builds_opened += 1;
@@ -732,12 +734,13 @@ impl AppBuilder {
/// paths right now, but they will when we start to enable things like swift integration.
///
/// Server/liveview/desktop are all basically the same, though
fn open_with_main_exe(&mut self, envs: Vec<(&str, String)>) -> Result<()> {
fn open_with_main_exe(&mut self, envs: Vec<(&str, String)>, args: &[String]) -> Result<()> {
let main_exe = self.app_exe();
tracing::debug!("Opening app with main exe: {main_exe:?}");
let mut child = Command::new(main_exe)
.args(args)
.envs(envs)
.env_remove("CARGO_MANIFEST_DIR") // running under `dx` shouldn't expose cargo-only :
.stderr(Stdio::piped())
+13 -3
View File
@@ -374,6 +374,7 @@ pub(crate) struct BuildRequest {
pub(crate) triple: Triple,
pub(crate) device: bool,
pub(crate) package: String,
pub(crate) main_target: String,
pub(crate) features: Vec<String>,
pub(crate) extra_cargo_args: Vec<String>,
pub(crate) extra_rustc_args: Vec<String>,
@@ -463,7 +464,11 @@ impl BuildRequest {
///
/// Note: Build requests are typically created only when the CLI is invoked or when significant
/// changes are detected in the `Cargo.toml` (e.g., features added or removed).
pub(crate) async fn new(args: &TargetArgs, workspace: Arc<Workspace>) -> Result<Self> {
pub(crate) async fn new(
args: &TargetArgs,
main_target: Option<String>,
workspace: Arc<Workspace>,
) -> Result<Self> {
let crate_package = workspace.find_main_package(args.package.clone())?;
let config = workspace
@@ -506,6 +511,10 @@ impl BuildRequest {
})
.unwrap_or(workspace.krates[crate_package].name.clone());
// Use the main_target for the client + server build if it is set, otherwise use the target name for this
// specific build
let main_target = main_target.unwrap_or(target_name.clone());
let crate_target = main_package
.targets
.iter()
@@ -727,6 +736,7 @@ impl BuildRequest {
extra_cargo_args,
release,
package,
main_target,
skip_assets: args.skip_assets,
base_path: args.base_path.clone(),
wasm_split: args.wasm_split,
@@ -2737,7 +2747,7 @@ impl BuildRequest {
/// target/dx/build/app/web/server.exe
pub(crate) fn build_dir(&self, platform: Platform, release: bool) -> PathBuf {
self.internal_out_dir()
.join(self.executable_name())
.join(&self.main_target)
.join(if release { "release" } else { "debug" })
.join(platform.build_folder_name())
}
@@ -2748,7 +2758,7 @@ impl BuildRequest {
/// target/dx/bundle/app/public/
pub(crate) fn bundle_dir(&self, platform: Platform) -> PathBuf {
self.internal_out_dir()
.join(self.executable_name())
.join(&self.main_target)
.join("bundle")
.join(platform.build_folder_name())
}