|
@@ -1,7 +1,12 @@
|
|
|
use super::{env, with_config};
|
|
|
-use crate::Result;
|
|
|
-use clap::Parser;
|
|
|
+use crate::{
|
|
|
+ helpers::config::get as get_config,
|
|
|
+ interface::{AppInterface, AppSettings, Interface, Options as InterfaceOptions},
|
|
|
+ Result,
|
|
|
+};
|
|
|
|
|
|
+use clap::Parser;
|
|
|
+use heck::AsSnakeCase;
|
|
|
use tauri_mobile::{apple::target::Target, opts::Profile, util};
|
|
|
|
|
|
use std::{collections::HashMap, ffi::OsStr, path::PathBuf};
|
|
@@ -124,12 +129,14 @@ pub fn command(options: Options) -> Result<()> {
|
|
|
|
|
|
let isysroot = format!("-isysroot {}", options.sdk_root.display());
|
|
|
|
|
|
+ let tauri_config = get_config(None)?;
|
|
|
+
|
|
|
for arch in options.arches {
|
|
|
// Set target-specific flags
|
|
|
- let triple = match arch.as_str() {
|
|
|
- "arm64" => "aarch64_apple_ios",
|
|
|
- "arm64-sim" => "aarch64_apple_ios_sim",
|
|
|
- "x86_64" => "x86_64_apple_ios",
|
|
|
+ let (env_triple, rust_triple) = match arch.as_str() {
|
|
|
+ "arm64" => ("aarch64_apple_ios", "aarch64-apple-ios"),
|
|
|
+ "arm64-sim" => ("aarch64_apple_ios_sim", "aarch64-apple-ios-sim"),
|
|
|
+ "x86_64" => ("x86_64_apple_ios", "x86_64-apple-ios"),
|
|
|
"Simulator" => continue,
|
|
|
_ => {
|
|
|
return Err(anyhow::anyhow!(
|
|
@@ -138,9 +145,15 @@ pub fn command(options: Options) -> Result<()> {
|
|
|
))
|
|
|
}
|
|
|
};
|
|
|
- let cflags = format!("CFLAGS_{}", triple);
|
|
|
- let cxxflags = format!("CFLAGS_{}", triple);
|
|
|
- let objc_include_path = format!("OBJC_INCLUDE_PATH_{}", triple);
|
|
|
+
|
|
|
+ let interface = AppInterface::new(
|
|
|
+ tauri_config.lock().unwrap().as_ref().unwrap(),
|
|
|
+ Some(rust_triple.into()),
|
|
|
+ )?;
|
|
|
+
|
|
|
+ let cflags = format!("CFLAGS_{}", env_triple);
|
|
|
+ let cxxflags = format!("CFLAGS_{}", env_triple);
|
|
|
+ let objc_include_path = format!("OBJC_INCLUDE_PATH_{}", env_triple);
|
|
|
let mut target_env = host_env.clone();
|
|
|
target_env.insert(cflags.as_ref(), isysroot.as_ref());
|
|
|
target_env.insert(cxxflags.as_ref(), isysroot.as_ref());
|
|
@@ -165,6 +178,28 @@ pub fn command(options: Options) -> Result<()> {
|
|
|
&env,
|
|
|
target_env,
|
|
|
)?;
|
|
|
+
|
|
|
+ let bin_path = interface
|
|
|
+ .app_settings()
|
|
|
+ .app_binary_path(&InterfaceOptions {
|
|
|
+ debug: matches!(profile, Profile::Debug),
|
|
|
+ target: Some(rust_triple.into()),
|
|
|
+ ..Default::default()
|
|
|
+ })?;
|
|
|
+ let out_dir = bin_path.parent().unwrap();
|
|
|
+
|
|
|
+ std::fs::create_dir_all(format!(
|
|
|
+ "gen/apple/Externals/{rust_triple}/{}",
|
|
|
+ profile.as_str()
|
|
|
+ ))?;
|
|
|
+ std::fs::copy(
|
|
|
+ out_dir.join(format!("lib{}.a", AsSnakeCase(config.app().name()))),
|
|
|
+ format!(
|
|
|
+ "gen/apple/Externals/{rust_triple}/{}/lib{}.a",
|
|
|
+ profile.as_str(),
|
|
|
+ AsSnakeCase(config.app().name())
|
|
|
+ ),
|
|
|
+ )?;
|
|
|
}
|
|
|
Ok(())
|
|
|
})
|