manually apply debug assertions flag for fullstack debug mode

This commit is contained in:
Evan Almloff committed 2023-12-22 09:25:35 -06:00
1 parent 0914298bea
commit 601c63b67f
1 file changed
+22 -7
+22 -7
View File
@@ -66,7 +66,7 @@ impl Platform for FullstackPlatform {
}
None => desktop_config.features = Some(vec![desktop_feature]),
};
let _gaurd = FullstackServerEnvGuard::new(self.serve.debug);
let _gaurd = FullstackServerEnvGuard::new(&self.serve);
self.desktop.rebuild(&desktop_config)
};
thread_handle
@@ -88,7 +88,7 @@ fn build_web(serve: ConfigOptsServe, target_directory: &std::path::Path) -> Resu
};
web_config.platform = Some(crate::cfg::Platform::Web);
let _gaurd = FullstackWebEnvGuard::new(web_config.debug);
let _gaurd = FullstackWebEnvGuard::new(&web_config);
crate::cli::build::Build { build: web_config }.build(None, Some(target_directory))
}
@@ -99,14 +99,21 @@ pub(crate) struct FullstackWebEnvGuard {
}
impl FullstackWebEnvGuard {
pub fn new(debug_mode: bool) -> Self {
pub fn new(serve: &ConfigOptsBuild) -> Self {
Self {
old_rustflags: (!debug_mode).then(|| {
old_rustflags: (!serve.debug).then(|| {
let old_rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();
let debug_assertions = if serve.release {
""
} else {
" -C debug-assertions"
};
std::env::set_var(
"RUSTFLAGS",
format!("{old_rustflags} -C debuginfo=none -C strip=debuginfo"),
format!(
"{old_rustflags} -C debuginfo=none -C strip=debuginfo{debug_assertions}"
),
);
old_rustflags
}),
@@ -129,12 +136,20 @@ pub(crate) struct FullstackServerEnvGuard {
}
impl FullstackServerEnvGuard {
pub fn new(debug_mode: bool) -> Self {
pub fn new(debug_mode: bool, release_mode: bool) -> Self {
Self {
old_rustflags: (!debug_mode).then(|| {
let old_rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();
let debug_assertions = if serve.release {
""
} else {
" -C debug-assertions"
};
std::env::set_var("RUSTFLAGS", format!("{old_rustflags} -C opt-level=2"));
std::env::set_var(
"RUSTFLAGS",
format!("{old_rustflags} -C opt-level=2 {debug_assertions}"),
);
old_rustflags
}),
}