How to run a local cargo-tool?

Cargo tools like this GitHub - bbqsrc/cargo-ndk: Compile Rust projects against the Android NDK without hassle can be installed. If I clone it, how can I run it? Can I also install it?

I tried

RUST_LOG=trace cargo run -- -t arm64-v8a --bindgen build

but I'm getting lots of errors

RUST_LOG=trace cargo run -- -t arm64-v8a --bindgen build
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/cargo-ndk -t arm64-v8a --bindgen build`
[2022-05-19T23:41:40Z TRACE cargo_ndk::cli] Args: ["arm64-v8a", "--bindgen", "build"]
[2022-05-19T23:41:40Z TRACE cargo_ndk::cli] is_release: false
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli] Using NDK at path: /opt/android-sdk-linux/ndk/22.1.7171670
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cli] Exporting CARGO_NDK_CMAKE_TOOLCHAIN_PATH = "/opt/android-sdk-linux/ndk/22.1.7171670/build/cmake/android.toolchain.cmake"
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli] NDK API level: 21
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli] Building targets: armeabi-v7a, arm64-v8a
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cli] Exporting CARGO_NDK_ANDROID_TARGET = "armeabi-v7a"
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] Detected NDK version: Version { major: 22, minor: 1, patch: 7171670 }
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] cargo: /usr/local/rustup/toolchains/1.60.0-x86_64-unknown-linux-gnu/bin/cargo
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] AR_armv7-linux-androideabi=/opt/android-sdk-linux/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] CC_armv7-linux-androideabi=/opt/android-sdk-linux/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] CXX_armv7-linux-androideabi=/opt/android-sdk-linux/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_AR=/opt/android-sdk-linux/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=/opt/android-sdk-linux/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] BINDGEN_EXTRA_CLANG_ARGS_armv7_linux_androideabi=/opt/android-sdk-linux/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] Args: ["arm64-v8a", "--bindgen", "build"]
[2022-05-19T23:41:41Z DEBUG cargo_ndk::cargo] Working directory does not match manifest-path
error: no such subcommand: `arm64-v8a`
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli] 
[2022-05-19T23:41:41Z INFO  cargo_ndk::cli]     rustup target install armv7-linux-androideabi

I think the subcommands work a little different when the tool is not installed

To install

cargo install cargo-ndk

The use GitHub - bbqsrc/cargo-ndk: Compile Rust projects against the Android NDK without hassle

yes but I want to modify and test my local modifications to the cloned repo

Oh sorry.
To install go to the cargo-ndk directory and do.

cargo install --path .

To just build, do

cargo build

To use go to the sources you want to compile and do

cargo ndk ...

I think. But I have never used the tool

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.