mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
fix(cli): use Target::build to run initial Android build (#6220)
This commit is contained in:
committed by
GitHub
parent
78176edf4a
commit
da57e7c087
4
.github/workflows/test-mobile.yml
vendored
4
.github/workflows/test-mobile.yml
vendored
@@ -77,13 +77,13 @@ jobs:
|
||||
working-directory: ./examples/api
|
||||
run: yarn
|
||||
|
||||
- name: Init Android Studio Project
|
||||
- name: init Android Studio project
|
||||
working-directory: ./examples/api
|
||||
run: ../../tooling/cli/target/debug/cargo-tauri android init
|
||||
env:
|
||||
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
|
||||
- name: Build apk
|
||||
- name: build APK
|
||||
working-directory: ./examples/api
|
||||
run: ../../tooling/cli/target/debug/cargo-tauri android build
|
||||
env:
|
||||
|
||||
@@ -72,7 +72,7 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
||||
delete_codegen_vars();
|
||||
with_config(
|
||||
Some(Default::default()),
|
||||
|app, config, _metadata, _cli_options| {
|
||||
|app, config, metadata, _cli_options| {
|
||||
set_var("WRY_RUSTWEBVIEWCLIENT_CLASS_EXTENSION", "");
|
||||
set_var("WRY_RUSTWEBVIEW_CLASS_INIT", "");
|
||||
|
||||
@@ -81,6 +81,20 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
||||
let mut env = env()?;
|
||||
configure_cargo(app, Some((&mut env, config)))?;
|
||||
|
||||
// run an initial build to initialize plugins
|
||||
Target::all().first_key_value().unwrap().1.build(
|
||||
config,
|
||||
metadata,
|
||||
&env,
|
||||
noise_level,
|
||||
true,
|
||||
if options.debug {
|
||||
Profile::Debug
|
||||
} else {
|
||||
Profile::Release
|
||||
},
|
||||
)?;
|
||||
|
||||
let open = options.open;
|
||||
run_build(options, config, &mut env, noise_level)?;
|
||||
|
||||
@@ -120,7 +134,7 @@ fn run_build(
|
||||
.triple
|
||||
.into(),
|
||||
);
|
||||
let mut interface = crate::build::setup(&mut build_options, true)?;
|
||||
let interface = crate::build::setup(&mut build_options, true)?;
|
||||
|
||||
let interface_options = InterfaceOptions {
|
||||
debug: build_options.debug,
|
||||
@@ -156,9 +170,6 @@ fn run_build(
|
||||
.get_or_insert(Vec::new())
|
||||
.push("custom-protocol".into());
|
||||
|
||||
// run an initial build to initialize plugins
|
||||
interface.build(interface_options)?;
|
||||
|
||||
let apk_outputs = if options.apk {
|
||||
apk::build(
|
||||
config,
|
||||
|
||||
@@ -16,9 +16,11 @@ use tauri_mobile::{
|
||||
config::{Config as AndroidConfig, Metadata as AndroidMetadata},
|
||||
device::Device,
|
||||
env::Env,
|
||||
target::Target,
|
||||
},
|
||||
config::app::App,
|
||||
opts::{FilterLevel, NoiseLevel, Profile},
|
||||
target::TargetTrait,
|
||||
};
|
||||
|
||||
use std::env::set_var;
|
||||
@@ -112,12 +114,11 @@ fn run_dev(
|
||||
};
|
||||
|
||||
let mut dev_options: DevOptions = options.clone().into();
|
||||
dev_options.target = Some(
|
||||
device
|
||||
.as_ref()
|
||||
.map(|d| d.target().triple.to_string())
|
||||
.unwrap_or_else(|| "aarch64-linux-android".into()),
|
||||
);
|
||||
let target_triple = device
|
||||
.as_ref()
|
||||
.map(|d| d.target().triple.to_string())
|
||||
.unwrap_or_else(|| Target::all().first_key_value().unwrap().1.triple.into());
|
||||
dev_options.target = Some(target_triple.clone());
|
||||
let mut interface = crate::dev::setup(&mut dev_options, true)?;
|
||||
|
||||
let interface_options = InterfaceOptions {
|
||||
@@ -134,7 +135,11 @@ fn run_dev(
|
||||
configure_cargo(app, Some((&mut env, config)))?;
|
||||
|
||||
// run an initial build to initialize plugins
|
||||
interface.build(interface_options)?;
|
||||
let target = Target::all()
|
||||
.values()
|
||||
.find(|t| t.triple == target_triple)
|
||||
.unwrap_or(Target::all().first_key_value().unwrap().1);
|
||||
target.build(config, metadata, &env, noise_level, true, Profile::Debug)?;
|
||||
|
||||
let open = options.open;
|
||||
let exit_on_panic = options.exit_on_panic;
|
||||
|
||||
Reference in New Issue
Block a user