mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-14 13:21:01 +03:00
feat(cli): enhance android build task arguments (#4986)
This commit is contained in:
parent
6f0615044d
commit
8aad710064
@ -20,7 +20,7 @@ use cargo_mobile::{
|
||||
use clap::Parser;
|
||||
use handlebars::{Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderError};
|
||||
|
||||
use std::{fs, io, path::PathBuf};
|
||||
use std::{env::current_dir, fs, io, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[clap(about = "Initializes a Tauri Android project")]
|
||||
@ -125,14 +125,31 @@ pub fn exec(
|
||||
}
|
||||
|
||||
let (handlebars, mut map) = handlebars(&config);
|
||||
|
||||
let mut args = std::env::args_os();
|
||||
// TODO: make this a relative path
|
||||
map.insert(
|
||||
"tauri-binary",
|
||||
std::env::args_os()
|
||||
.next()
|
||||
.unwrap_or_else(|| std::ffi::OsString::from("cargo"))
|
||||
.to_string_lossy(),
|
||||
);
|
||||
let tauri_binary = args
|
||||
.next()
|
||||
.unwrap_or_else(|| std::ffi::OsString::from("cargo"));
|
||||
map.insert("tauri-binary", tauri_binary.to_string_lossy());
|
||||
let mut build_args = Vec::new();
|
||||
for arg in args {
|
||||
if arg == "android" {
|
||||
break;
|
||||
}
|
||||
let path = PathBuf::from(&arg);
|
||||
if path.exists() {
|
||||
if let Ok(dir) = current_dir() {
|
||||
let absolute_path = util::prefix_path(dir, path);
|
||||
build_args.push(absolute_path.to_string_lossy().into_owned());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
build_args.push(arg.to_string_lossy().into_owned());
|
||||
}
|
||||
build_args.push("android".into());
|
||||
build_args.push("build".into());
|
||||
map.insert("tauri-binary-args", build_args);
|
||||
|
||||
// Generate Android Studio project
|
||||
let android_env = if target == Target::Android {
|
||||
|
@ -27,7 +27,7 @@ open class BuildTask : DefaultTask() {
|
||||
project.exec {
|
||||
workingDir(File(project.projectDir, rootDirRel.path))
|
||||
executable("{{ tauri-binary }}")
|
||||
args(listOf("tauri", "android", "build"))
|
||||
args(listOf({{quote-and-join tauri-binary-args}}))
|
||||
if (project.logger.isEnabled(LogLevel.DEBUG)) {
|
||||
args("-vv")
|
||||
} else if (project.logger.isEnabled(LogLevel.INFO)) {
|
||||
|
Loading…
Reference in New Issue
Block a user