feat: set windows subsytem to windows for gui apps (#4855)
* feat: set windows subsytem to windows for gui apps * typo * clippy
This commit is contained in:
1 parent
8adea41efa
commit
24df6439ea
2 files changed
+45
-19
No files matched your search
@@ -855,6 +855,27 @@ impl BuildRequest {
|
||||
let mut custom_linker = cargo_config.linker(triple.to_string()).ok().flatten();
|
||||
let mut rustflags = cargo_config2::Flags::default();
|
||||
|
||||
// Make sure to take into account the RUSTFLAGS env var and the CARGO_TARGET_<triple>_RUSTFLAGS
|
||||
for env in [
|
||||
"RUSTFLAGS".to_string(),
|
||||
format!("CARGO_TARGET_{triple}_RUSTFLAGS"),
|
||||
] {
|
||||
if let Ok(flags) = std::env::var(env) {
|
||||
rustflags
|
||||
.flags
|
||||
.extend(cargo_config2::Flags::from_space_separated(&flags).flags);
|
||||
}
|
||||
}
|
||||
|
||||
// Use the user's linker if the specify it at the target level
|
||||
if let Ok(target) = cargo_config.target(triple.to_string()) {
|
||||
if let Some(flags) = target.rustflags {
|
||||
rustflags.flags.extend(flags.flags);
|
||||
}
|
||||
}
|
||||
|
||||
// When we do android builds we need to make sure we link against the android libraries
|
||||
// We also `--export-dynamic` to make sure we can do shenanigans like `dlsym` the `main` symbol
|
||||
if matches!(bundle, BundleFormat::Android) {
|
||||
rustflags.flags.extend([
|
||||
"-Clink-arg=-landroid".to_string(),
|
||||
@@ -869,6 +890,22 @@ impl BuildRequest {
|
||||
]);
|
||||
}
|
||||
|
||||
// On windows, we pass /SUBSYSTbEM:WINDOWS to prevent a console from appearing
|
||||
if matches!(bundle, BundleFormat::Windows)
|
||||
&& !rustflags
|
||||
.flags
|
||||
.iter()
|
||||
.any(|f| f.starts_with("-Clink-arg=/SUBSYSTEM:"))
|
||||
{
|
||||
let subsystem = args
|
||||
.windows_subsystem
|
||||
.clone()
|
||||
.unwrap_or_else(|| "WINDOWS".to_string());
|
||||
rustflags
|
||||
.flags
|
||||
.push(format!("-Clink-arg=/SUBSYSTEM:{}", subsystem));
|
||||
}
|
||||
|
||||
// Make sure we set the sysroot for ios builds in the event the user doesn't have it set
|
||||
if matches!(bundle, BundleFormat::Ios) {
|
||||
let xcode_path = Workspace::get_xcode_path()
|
||||
@@ -897,25 +934,6 @@ impl BuildRequest {
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure to take into account the RUSTFLAGS env var and the CARGO_TARGET_<triple>_RUSTFLAGS
|
||||
for env in [
|
||||
"RUSTFLAGS".to_string(),
|
||||
format!("CARGO_TARGET_{triple}_RUSTFLAGS"),
|
||||
] {
|
||||
if let Ok(flags) = std::env::var(env) {
|
||||
rustflags
|
||||
.flags
|
||||
.extend(cargo_config2::Flags::from_space_separated(&flags).flags);
|
||||
}
|
||||
}
|
||||
|
||||
// Use the user's linker if the specify it at the target level
|
||||
if let Ok(target) = cargo_config.target(triple.to_string()) {
|
||||
if let Some(flags) = target.rustflags {
|
||||
rustflags.flags.extend(flags.flags);
|
||||
}
|
||||
}
|
||||
|
||||
// If no custom linker is set, then android falls back to us as the linker
|
||||
if custom_linker.is_none() && bundle == BundleFormat::Android {
|
||||
let min_sdk_version = config.application.android_min_sdk_version.unwrap_or(28);
|
||||
|
||||
Reference in new issue
Block a user