Skip to content

Gradle Plugin for compatibility between Rust Code and TypeScript Code for Android

License

Notifications You must be signed in to change notification settings

Cach30verfl0w/react-native-rust-plugin

Repository files navigation

React Native Rust Plugin

Gradle Plugin for compatibility between Rust Code and TypeScript Code for Android. For this plugin, you need to have Cargo and the Android NDK (Native Development Kit) installed.

Dependencies

This project uses the following dependencies:

Name Author License
antlr4 Antlr Project BSD-3 Clause License
Java Annotations JetBrains Apache-2.0 License
Night Config (Toml) TheElectronWill GNU Lesser General Public License 3.0

Configuration

You can configure the plugin with the react-native-rust section in your build.gradle. The following code shows an example (In the rustBaseFolder you can create cargo projects):

react-native-rust {
	basePackage = "com.user.example"
	rustBaseFolder = "src/main/rust"
	androidApiVersion = 33 as Byte
	
	cargoFile = file("%CARGO_PATH%") // Optional, defaulted to cargo executable
	ndkFolder = file("%NDK_FOLDER%") // Optional, defaulted to NDK_HOME env variable

	module('rust-module-name') // Add module to list
}

After the configuration, you can run three tasks:

  • javaCodeGen - Generate Java-side Code by the Rust code in the projects
  • cargoCompile - Compile all Rust projects in base folder
  • nativeBundle - Move all rust library files to the src/main/jniLibs folder

About

Gradle Plugin for compatibility between Rust Code and TypeScript Code for Android

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages