Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --target flag not passed to cargo when Platform == Server #3595

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcobergamin-videam
Copy link

PR related to the Issue #3594

@marcobergamin-videam marcobergamin-videam requested a review from a team as a code owner January 20, 2025 09:31
@marcobergamin-videam
Copy link
Author

marcobergamin-videam commented Jan 20, 2025

Perphaps this whole if/else statement should be refactored?

It looks like the Linux/Windows/MacOS platforms have the same problem.

        if self.build.platform() == Platform::Server {
            cargo_args.push("--profile".to_string());
            match self.build.release {
                true => cargo_args.push("release".to_string()),
                false => cargo_args.push(self.build.server_profile.to_string()),
            };

            if let Some(target) = self.build.target_args.target.as_deref() {
                cargo_args.push("--target".to_string());
                cargo_args.push(target.to_string());
            }
        } else {
            // Add required profile flags. --release overrides any custom profiles.
            let custom_profile = &self.build.profile.as_ref();
            if custom_profile.is_some() || self.build.release {
                cargo_args.push("--profile".to_string());
                match self.build.release {
                    true => cargo_args.push("release".to_string()),
                    false => {
                        cargo_args.push(
                            custom_profile
                                .expect("custom_profile should have been checked by is_some")
                                .to_string(),
                        );
                    }
                };
            }
            // todo: use the right arch based on the current arch
            let custom_target = match self.build.platform() {
                Platform::Web => Some("wasm32-unknown-unknown"),
                Platform::Ios => match self.build.target_args.device {
                    Some(true) => Some("aarch64-apple-ios"),
                    _ => Some("aarch64-apple-ios-sim"),
                },
                Platform::Android => Some(self.build.target_args.arch().android_target_triplet()),
                Platform::Server => None,
                // we're assuming we're building for the native platform for now... if you're cross-compiling
                // the targets here might be different
                Platform::MacOS => None,
                Platform::Windows => None,
                Platform::Linux => None,
                Platform::Liveview => None,
            };
            if let Some(target) = custom_target.or(self.build.target_args.target.as_deref()) {
                cargo_args.push("--target".to_string());
                cargo_args.push(target.to_string());
            }
        }

@ealmloff ealmloff added the cli Related to the dioxus-cli program label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the dioxus-cli program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants