|
@@ -33,7 +33,27 @@ pub fn command(target: Target, ci: bool, reinstall_deps: bool) -> Result<()> {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
-pub fn init_dot_cargo(app: &App, android: Option<(&AndroidEnv, &AndroidConfig)>) -> Result<()> {
|
|
|
+pub fn configure_cargo(
|
|
|
+ app: &App,
|
|
|
+ android: Option<(&mut AndroidEnv, &AndroidConfig)>,
|
|
|
+) -> Result<()> {
|
|
|
+ if let Some((env, config)) = android {
|
|
|
+ for target in AndroidTarget::all().values() {
|
|
|
+ let config = target.generate_cargo_config(config, env)?;
|
|
|
+ let target_var_name = target.triple.replace('-', "_").to_uppercase();
|
|
|
+ if let Some(linker) = config.linker {
|
|
|
+ env.base.insert_env_var(
|
|
|
+ format!("CARGO_TARGET_{target_var_name}_LINKER"),
|
|
|
+ linker.into(),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ env.base.insert_env_var(
|
|
|
+ format!("CARGO_TARGET_{target_var_name}_RUSTFLAGS"),
|
|
|
+ config.rustflags.join(" ").into(),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let mut dot_cargo = dot_cargo::DotCargo::load(app)?;
|
|
|
// Mysteriously, builds that don't specify `--target` seem to fight over
|
|
|
// the build cache with builds that use `--target`! This means that
|
|
@@ -47,15 +67,6 @@ pub fn init_dot_cargo(app: &App, android: Option<(&AndroidEnv, &AndroidConfig)>)
|
|
|
// https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags
|
|
|
dot_cargo.set_default_target(util::host_target_triple()?);
|
|
|
|
|
|
- if let Some((env, config)) = android {
|
|
|
- for target in AndroidTarget::all().values() {
|
|
|
- dot_cargo.insert_target(
|
|
|
- target.triple.to_owned(),
|
|
|
- target.generate_cargo_config(config, env)?,
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
dot_cargo.write(app).map_err(Into::into)
|
|
|
}
|
|
|
|
|
@@ -110,12 +121,11 @@ pub fn exec(
|
|
|
let app = match target {
|
|
|
// Generate Android Studio project
|
|
|
Target::Android => match AndroidEnv::new() {
|
|
|
- Ok(env) => {
|
|
|
+ Ok(_env) => {
|
|
|
let (app, config, metadata) =
|
|
|
super::android::get_config(Some(app), tauri_config_, &Default::default());
|
|
|
map.insert("android", &config);
|
|
|
super::android::project::gen(&config, &metadata, (handlebars, map), wrapper)?;
|
|
|
- init_dot_cargo(&app, Some((&env, &config)))?;
|
|
|
app
|
|
|
}
|
|
|
Err(err) => {
|
|
@@ -125,7 +135,6 @@ pub fn exec(
|
|
|
err,
|
|
|
)
|
|
|
.print(wrapper);
|
|
|
- init_dot_cargo(&app, None)?;
|
|
|
app
|
|
|
} else {
|
|
|
return Err(err.into());
|
|
@@ -146,7 +155,6 @@ pub fn exec(
|
|
|
non_interactive,
|
|
|
reinstall_deps,
|
|
|
)?;
|
|
|
- init_dot_cargo(&app, None)?;
|
|
|
app
|
|
|
}
|
|
|
};
|