Code Monkey home page Code Monkey logo

cargo-ndk's Introduction

cargo-ndk

Use cargo with the NDK without too much hassle. Handles finding the correct linkers and converting between the triples used in the Rust world to the triples used in the Android world.

For a more manual approach, see this blog from Mozilla.

Supported triples

  • aarch64-linux-android
  • armv7-linux-androideabi
  • i686-linux-android
  • x86_64-linux-android

Supported hosts

  • Linux
  • macOS

There is not fundamental reason Windows can't be supported; pull requests welcomed warmly!

Usage

First you'll need to install all the toolchains you intend to use. Simplest way is with the following:

rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android

You'll also need the NDK installed somewhere, and the path to it exported as the NDK_HOME environment variable. On macOS with Android Studio, this is usually $HOME/Library/Android/sdk/ndk-bundle. On Linux, it's somewhere in $HOME/.android (pull requests accepted with actual location).

Install the plugin with cargo install cargo-ndk.

Then, simply run your usual cargo commands prefixed with cargo ndk --target <Android triplet> --android-platform <API> --, where API is the Android API platform version to target (for example, 16). Note the --, it is required to pass commands to cargo and not to the cargo-ndk plugin.

So, to do an ordinary release build for aarch64 against API 25, you'd run:

cargo ndk --target aarch64-linux-android --android-platform 25 -- build --release 

License

This project is licensed under either of

at your option.

cargo-ndk's People

Contributors

bbqsrc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.