mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
fix: only build specified rust targets for aab/apk build (#6625)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
6
.changes/cli-android-specified-targets-only.md
Normal file
6
.changes/cli-android-specified-targets-only.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'cli.rs': 'patch'
|
||||
'cli.js': 'patch'
|
||||
---
|
||||
|
||||
Build only specified rust targets for `tauri android build` instead of all.
|
||||
4
tooling/cli/Cargo.lock
generated
4
tooling/cli/Cargo.lock
generated
@@ -3770,9 +3770,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-mobile"
|
||||
version = "0.2.5"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3603ad10b7b18e53f486b6a3de15b51d23098ce800a30162cb634a1c61afff64"
|
||||
checksum = "8fad13092a3a94d64f783bb2818a839897431d7224c26a98890d189af041c404"
|
||||
dependencies = [
|
||||
"cocoa",
|
||||
"colored 1.9.3",
|
||||
|
||||
@@ -42,7 +42,7 @@ path = "src/main.rs"
|
||||
openssl-vendored = [ "tauri-mobile/openssl-vendored" ]
|
||||
|
||||
[dependencies]
|
||||
tauri-mobile = { version = "0.2.5", default-features = false }
|
||||
tauri-mobile = { version = "0.3", default-features = false }
|
||||
textwrap = { version = "0.11.0", features = [ "term_size" ] }
|
||||
jsonrpsee = { version = "0.16", features = [ "server" ] }
|
||||
jsonrpsee-core = "0.16"
|
||||
|
||||
@@ -240,20 +240,15 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
|
||||
}
|
||||
|
||||
pub fn setup(options: &mut Options, mobile: bool) -> Result<AppInterface> {
|
||||
let (merge_config, merge_config_path) = if let Some(config) = &options.config {
|
||||
if config.starts_with('{') {
|
||||
(Some(config.to_string()), None)
|
||||
} else {
|
||||
(
|
||||
Some(
|
||||
std::fs::read_to_string(config).with_context(|| "failed to read custom configuration")?,
|
||||
),
|
||||
Some(config.clone()),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
let (merge_config, merge_config_path) = match &options.config {
|
||||
Some(config) if config.starts_with('{') => (Some(config.to_string()), None),
|
||||
Some(config) => (
|
||||
Some(std::fs::read_to_string(config).with_context(|| "failed to read custom configuration")?),
|
||||
Some(config.clone()),
|
||||
),
|
||||
None => (None, None),
|
||||
};
|
||||
|
||||
options.config = merge_config;
|
||||
|
||||
let tauri_path = tauri_dir();
|
||||
|
||||
@@ -181,7 +181,7 @@ fn run_build(
|
||||
env,
|
||||
noise_level,
|
||||
profile,
|
||||
get_targets_or_all(Vec::new())?,
|
||||
get_targets(options.targets.clone().unwrap_or_default())?,
|
||||
options.split_per_abi,
|
||||
)?
|
||||
} else {
|
||||
@@ -194,7 +194,7 @@ fn run_build(
|
||||
env,
|
||||
noise_level,
|
||||
profile,
|
||||
get_targets_or_all(Vec::new())?,
|
||||
get_targets(options.targets.unwrap_or_default())?,
|
||||
options.split_per_abi,
|
||||
)?
|
||||
} else {
|
||||
@@ -207,28 +207,24 @@ fn run_build(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_targets_or_all<'a>(targets: Vec<String>) -> Result<Vec<&'a Target<'a>>> {
|
||||
if targets.is_empty() {
|
||||
Ok(Target::all().iter().map(|t| t.1).collect())
|
||||
} else {
|
||||
let mut outs = Vec::new();
|
||||
fn get_targets<'a>(targets: Vec<String>) -> Result<Vec<&'a Target<'a>>> {
|
||||
let mut outs = Vec::new();
|
||||
|
||||
let possible_targets = Target::all()
|
||||
.keys()
|
||||
.map(|key| key.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(",");
|
||||
let possible_targets = Target::all()
|
||||
.keys()
|
||||
.map(|key| key.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(",");
|
||||
|
||||
for t in targets {
|
||||
let target = Target::for_name(&t).ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"Target {} is invalid; the possible targets are {}",
|
||||
t,
|
||||
possible_targets
|
||||
)
|
||||
})?;
|
||||
outs.push(target);
|
||||
}
|
||||
Ok(outs)
|
||||
for t in targets {
|
||||
let target = Target::for_name(&t).ok_or_else(|| {
|
||||
anyhow::anyhow!(
|
||||
"Target {} is invalid; the possible targets are {}",
|
||||
t,
|
||||
possible_targets
|
||||
)
|
||||
})?;
|
||||
outs.push(target);
|
||||
}
|
||||
Ok(outs)
|
||||
}
|
||||
|
||||
@@ -316,6 +316,7 @@ fn ensure_init(project_dir: PathBuf, target: Target) -> Result<()> {
|
||||
target.command_name(),
|
||||
)
|
||||
} else {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Target::Android = target {
|
||||
create_dir_all(project_dir.join(".tauri").join("plugins"))?;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ android {
|
||||
isMinifyEnabled = false
|
||||
packagingOptions {
|
||||
{{~#each targets}}
|
||||
|
||||
jniLibs.keepDebugSymbols.add("*/{{this.abi}}/*.so")
|
||||
{{/each}}
|
||||
}
|
||||
@@ -46,17 +45,14 @@ android {
|
||||
flavorDimensions.add("abi")
|
||||
productFlavors {
|
||||
create("universal") {
|
||||
val abiList = findProperty("abiList") as? String
|
||||
|
||||
dimension = "abi"
|
||||
ndk {
|
||||
abiFilters += abiList?.split(",")?.map { it.trim() } ?: listOf(
|
||||
abiFilters += (findProperty("abiList") as? String)?.split(",") ?: listOf(
|
||||
{{~#each targets}}
|
||||
"{{this.abi}}",{{/each}}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
{{~#each targets}}
|
||||
|
||||
create("{{this.arch}}") {
|
||||
@@ -74,8 +70,8 @@ android {
|
||||
|
||||
rust {
|
||||
rootDirRel = "{{root-dir-rel}}"
|
||||
targets = listOf({{quote-and-join target-names}})
|
||||
arches = listOf({{quote-and-join arches}})
|
||||
targets = (findProperty("targetList") as? String)?.split(",") ?: listOf({{quote-and-join target-names}})
|
||||
arches = (findProperty("archList") as? String)?.split(",") ?: listOf({{quote-and-join arches}})
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -98,9 +94,11 @@ afterEvaluate {
|
||||
android.applicationVariants.all {
|
||||
tasks["mergeUniversalReleaseJniLibFolders"].dependsOn(tasks["rustBuildRelease"])
|
||||
tasks["mergeUniversalDebugJniLibFolders"].dependsOn(tasks["rustBuildDebug"])
|
||||
productFlavors.filter{ it.name != "universal" }.forEach { _ ->
|
||||
val archAndBuildType = name.capitalize()
|
||||
tasks["merge${archAndBuildType}JniLibFolders"].dependsOn(tasks["rustBuild${archAndBuildType}"])
|
||||
if (findProperty("targetList") == null) {
|
||||
productFlavors.filter{ it.name != "universal" }.forEach { _ ->
|
||||
val archAndBuildType = name.capitalize()
|
||||
tasks["merge${archAndBuildType}JniLibFolders"].dependsOn(tasks["rustBuild${archAndBuildType}"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user