Skip to content

Commit

Permalink
fix(cli.js): adb commands not working, closes #6659 (#6708)
Browse files Browse the repository at this point in the history
fix(cli.js): adb commands not working, closes #6659
  • Loading branch information
lucasfernog authored Apr 23, 2023
1 parent 96639ca commit 41f49ae
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 67 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-nodejs-android-cmds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cli.js": patch
---

Update tauri-mobile to fix running ADB scripts.
10 changes: 7 additions & 3 deletions core/tauri-build/src/mobile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,19 @@ impl PluginBuilder {
pub fn link_swift_library(name: &str, source: impl AsRef<Path>) {
let source = source.as_ref();

let curr_dir = std::env::current_dir().unwrap();
std::env::set_current_dir(source).unwrap();
let sdk_root = std::env::var_os("SDKROOT");
std::env::remove_var("SDKROOT");

swift_rs::SwiftLinker::new(
&std::env::var("MACOSX_DEPLOYMENT_TARGET").unwrap_or_else(|_| "10.13".into()),
)
.with_ios(&std::env::var("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|_| "13.0".into()))
.with_package(name, source)
.link();
std::env::set_current_dir(curr_dir).unwrap();

if let Some(root) = sdk_root {
std::env::set_var("SDKROOT", root);
}
}

#[doc(hidden)]
Expand Down
45 changes: 2 additions & 43 deletions examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tooling/cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ path = "src/main.rs"
openssl-vendored = [ "tauri-mobile/openssl-vendored" ]

[dependencies]
tauri-mobile = { version = "0.3", default-features = false }
tauri-mobile = { version = "0.4", default-features = false }
textwrap = { version = "0.11.0", features = [ "term_size" ] }
jsonrpsee = { version = "0.16", features = [ "server" ] }
jsonrpsee-core = "0.16"
Expand All @@ -60,6 +60,7 @@ serde_json = "1.0"
notify = "5.0"
notify-debouncer-mini = "0.2"
shared_child = "1.0"
duct = "0.13"
toml_edit = "0.14"
json-patch = "0.2"
tauri-utils = { version = "2.0.0-alpha.4", path = "../../core/tauri-utils", features = [ "isolation", "schema", "config-json5", "config-toml" ] }
Expand Down
10 changes: 10 additions & 0 deletions tooling/cli/node/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */

/* auto-generated by NAPI-RS */

const { existsSync, readFileSync } = require('fs')
const { join } = require('path')

Expand Down
29 changes: 19 additions & 10 deletions tooling/cli/src/mobile/ios/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use tauri_mobile::{
deps, rust_version_check,
target::Target,
},
bossy,
config::app::DEFAULT_ASSET_DIR,
target::TargetTrait as _,
util::{self, cli::TextWrapper},
Expand Down Expand Up @@ -181,17 +180,27 @@ pub fn gen(
// Note that Xcode doesn't always reload the project nicely; reopening is
// often necessary.
println!("Generating Xcode project...");
bossy::Command::impure("xcodegen")
.with_args(["generate", "--spec"])
.with_arg(dest.join("project.yml"))
.run_and_wait()
.with_context(|| "failed to run `xcodegen`")?;
duct::cmd(
"xcodegen",
[
"generate",
"--spec",
&dest.join("project.yml").to_string_lossy(),
],
)
.run()
.with_context(|| "failed to run `xcodegen`")?;

if !ios_pods.is_empty() || !macos_pods.is_empty() {
bossy::Command::impure_parse("pod install")
.with_arg(format!("--project-directory={}", dest.display()))
.run_and_wait()
.with_context(|| "failed to run `pod install`")?;
duct::cmd(
"pod",
[
"install",
&format!("--project-directory={}", dest.display()),
],
)
.run()
.with_context(|| "failed to run `pod install`")?;
}
Ok(())
}
13 changes: 6 additions & 7 deletions tooling/cli/src/mobile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use jsonrpsee::server::{RpcModule, ServerBuilder, ServerHandle};
use jsonrpsee_client_transport::ws::WsTransportClientBuilder;
use jsonrpsee_core::rpc_params;
use serde::{Deserialize, Serialize};
use shared_child::SharedChild;

use std::{
collections::HashMap,
Expand All @@ -34,10 +33,10 @@ use std::{
},
};
use tauri_mobile::{
bossy,
config::app::{App, Raw as RawAppConfig},
env::Error as EnvError,
opts::{NoiseLevel, Profile},
ChildHandle,
};
use tokio::runtime::Runtime;

Expand All @@ -55,14 +54,14 @@ const MIN_DEVICE_MATCH_SCORE: isize = 0;

#[derive(Clone)]
pub struct DevChild {
child: Arc<SharedChild>,
child: Arc<ChildHandle>,
manually_killed_process: Arc<AtomicBool>,
}

impl DevChild {
fn new(handle: bossy::Handle) -> Self {
fn new(handle: ChildHandle) -> Self {
Self {
child: Arc::new(SharedChild::new(handle.into()).unwrap()),
child: Arc::new(handle),
manually_killed_process: Default::default(),
}
}
Expand All @@ -76,11 +75,11 @@ impl DevProcess for DevChild {
}

fn try_wait(&self) -> std::io::Result<Option<ExitStatus>> {
self.child.try_wait()
self.child.try_wait().map(|res| res.map(|o| o.status))
}

fn wait(&self) -> std::io::Result<ExitStatus> {
self.child.wait()
self.child.wait().map(|o| o.status)
}

fn manually_killed_process(&self) -> bool {
Expand Down

0 comments on commit 41f49ae

Please sign in to comment.