|
@@ -339,6 +339,8 @@ pub struct Settings {
|
|
|
bundle_settings: BundleSettings,
|
|
|
/// the binaries to bundle.
|
|
|
binaries: Vec<BundleBinary>,
|
|
|
+ /// The target triple.
|
|
|
+ target: String,
|
|
|
}
|
|
|
|
|
|
/// A builder for [`Settings`].
|
|
@@ -350,6 +352,7 @@ pub struct SettingsBuilder {
|
|
|
package_settings: Option<PackageSettings>,
|
|
|
bundle_settings: BundleSettings,
|
|
|
binaries: Vec<BundleBinary>,
|
|
|
+ target: Option<String>,
|
|
|
}
|
|
|
|
|
|
impl SettingsBuilder {
|
|
@@ -396,13 +399,24 @@ impl SettingsBuilder {
|
|
|
self
|
|
|
}
|
|
|
|
|
|
+ /// Sets the target triple.
|
|
|
+ pub fn target(mut self, target: String) -> Self {
|
|
|
+ self.target.replace(target);
|
|
|
+ self
|
|
|
+ }
|
|
|
+
|
|
|
/// Builds a Settings from the CLI args.
|
|
|
///
|
|
|
/// Package settings will be read from Cargo.toml.
|
|
|
///
|
|
|
/// Bundle settings will be read from from $TAURI_DIR/tauri.conf.json if it exists and fallback to Cargo.toml's [package.metadata.bundle].
|
|
|
pub fn build(self) -> crate::Result<Settings> {
|
|
|
- let bundle_settings = parse_external_bin(self.bundle_settings)?;
|
|
|
+ let target = if let Some(t) = self.target {
|
|
|
+ t
|
|
|
+ } else {
|
|
|
+ target_triple()?
|
|
|
+ };
|
|
|
+ let bundle_settings = parse_external_bin(&target, self.bundle_settings)?;
|
|
|
|
|
|
Ok(Settings {
|
|
|
package: self.package_settings.expect("package settings is required"),
|
|
@@ -413,6 +427,7 @@ impl SettingsBuilder {
|
|
|
.expect("out directory is required"),
|
|
|
binaries: self.binaries,
|
|
|
bundle_settings,
|
|
|
+ target,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -425,7 +440,17 @@ impl Settings {
|
|
|
|
|
|
/// Returns the architecture for the binary being bundled (e.g. "arm", "x86" or "x86_64").
|
|
|
pub fn binary_arch(&self) -> &str {
|
|
|
- std::env::consts::ARCH
|
|
|
+ if self.target.starts_with("x86_64") {
|
|
|
+ "x86_64"
|
|
|
+ } else if self.target.starts_with('i') {
|
|
|
+ "x86"
|
|
|
+ } else if self.target.starts_with("arm") {
|
|
|
+ "arm"
|
|
|
+ } else if self.target.starts_with("aarch64") {
|
|
|
+ "aarch64"
|
|
|
+ } else {
|
|
|
+ panic!("Unexpected target triple {}", self.target)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// Returns the file name of the binary being bundled.
|
|
@@ -660,8 +685,10 @@ impl Settings {
|
|
|
}
|
|
|
|
|
|
/// Parses the external binaries to bundle, adding the target triple suffix to each of them.
|
|
|
-fn parse_external_bin(bundle_settings: BundleSettings) -> crate::Result<BundleSettings> {
|
|
|
- let target_triple = target_triple()?;
|
|
|
+fn parse_external_bin(
|
|
|
+ target_triple: &str,
|
|
|
+ bundle_settings: BundleSettings,
|
|
|
+) -> crate::Result<BundleSettings> {
|
|
|
let mut win_paths = Vec::new();
|
|
|
let external_bin = match bundle_settings.external_bin {
|
|
|
Some(paths) => {
|