tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] `tauri-bundler` fails to compile on Termux/Android

Open arqalite opened this issue 9 months ago • 1 comments

Describe the bug

I'm running a Linux environment on my Android phone (Galaxy Fold 4) using Termux, and I'm trying to build one of my Dioxus projects. Dioxus CLI makes use of tauri-bundler, which fails to compile on Termux because function create_tar_from_src() in src/bundle/updater_bundle.rs is only defined for macOS and Linux targets.

cargo build output:

   Compiling tauri-bundler v1.5.4
error[E0425]: cannot find function `create_tar_from_src` in this scope
   --> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-bundler-1.5.4/src/bundle/updater_bundle.rs:242:22
    |
242 |   let gzip_encoder = create_tar_from_src(src_dir, gzip_encoder)?;
    |                      ^^^^^^^^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `tauri-bundler` (lib) due to 1 previous error

Termux makes use of Android's libc and as such Rust by default builds everything for the aarch64-linux-android target.

A possible fix would be add Android to the Linux version of the function, so #[cfg(target_os = "linux")] becomes #[cfg(any(target_os = "android", target_os = "linux"))], however this might have some consequences I might not be aware of.

Maybe we can switch the attributes around so the Mac version build as-is, but if the target OS is not Mac then we use the Linux version directly? (#[cfg(target_os = "linux")] would become #[cfg(not(target_os = "macos"))]).

This would avoid explicitly mentioning Android in the code in case that might cause issues or confusion.

I was planning on forking Tauri instead of submitting an issue, but I thought it's worth bringing up at least. Let me know what you think - I'm also willing to submit a PR if you agree to this change.

I understand if the Tauri team does not consider this worth dealing with, my setup is pretty obscure and I'm fine with just forking and making the changes for my own purposes.

Reproduction

Install Termux on an Android phone. Install Rust with pkg install rust, create a test project with Cargo and add tauri-bundler to it. Then run cargo build.

Expected behavior

tauri-bundler builds without error.

Full tauri info output

N/A

Stack trace

N/A

arqalite avatar May 19 '24 17:05 arqalite