Configuration Reference
The cInterop { } block exposes the CInteropExtension, which controls all aspects of the pipeline.
Top-Level Properties
Property | Type | Default | Description |
|---|---|---|---|
|
|
| Master switch — must be |
|
|
| Selects the native language/pipeline: |
|
| (project name) | Overrides the name used for the native project directory and C-Interop compilation unit |
|
|
| Directory (relative to the Gradle module) where the Rust project is created |
|
|
| Overrides the Kotlin package name under which the native bindings are exposed |
|
| (auto-detected) | Explicit list of Rust target triples to compile for; if empty the host OS/arch is used |
Target Auto-Detection
When rustTargets is not set, Kreate detects the current host and selects a single target automatically:
Host OS | Host Architecture | Resolved Target |
|---|---|---|
Windows | x86_64 |
|
Linux | x86_64 |
|
Linux | aarch64 |
|
macOS | aarch64 |
|
For cross-compilation or multi-target releases, set rustTargets explicitly.
Rust Target → Kotlin/Native Target Mapping
Each Rust target triple is mapped to a Kotlin/Native target automatically:
Rust Target Triple | Kotlin/Native Target |
|---|---|
|
|
|
|
|
|
|
|
Any other triple causes a GradleException at configuration time.
Native Language (language)
The language property selects which native toolchain backs the interop. It accepts a NativeLanguage value:
NativeLanguage.RUST(default) — runs the full Cargo/cbindgenpipeline and honorsrustTargets.NativeLanguage.C/NativeLanguage.CPP— scaffold and build a CMake project, producing a static librarylib<projectName>.ain the project'sbuild/directory. The public API is declared in a hand-writteninclude/<projectName>.hheader (the C++ scaffold wraps it in anextern "C"boundary). These modes require CMake 3.20+ and a C/C++ compiler.
Definition File Configuration
The defFile { } sub-block configures the .def file generated for Kotlin/Native:
Property | Type | Default | Description |
|---|---|---|---|
|
|
| Name of the generated |
|
|
| Directory name (inside the Rust project) where the |
Per-Platform Native Target Configuration
You can apply additional Kotlin/Native target configuration for each platform family using the mingw { }, linux { }, and macos { } blocks. These receive a KotlinNativeTarget receiver and are executed after Kreate wires the C-Interop compilation:
Generated .def File Format
The GenerateDefinitionFiles task writes a .def file with the following format:
When multiple Rust targets are configured, all their release directories are listed in libraryPaths separated by spaces.
For NativeLanguage.C and NativeLanguage.CPP, libraryPaths instead points to the single CMake build directory:
Generated build.rs
The GenerateRustBuildScript task writes the following Rust build script if none exists yet (or if the existing file is empty):
This script runs automatically during cargo build and produces the C header consumed by the .def file.