CInteropSettings

C interoperability settings

This interface represents the configuration settings for invoking the cinterop tool in Kotlin/Native projects. The cinterop tool provides the ability to use C libraries inside Kotlin projects.

Important: Use the CInteropSettings API instead of directly accessing tasks, configurations, and other related domain objects through the Gradle API.

Example

Here is an example of how to use CInteropSettings to configure a cinterop task for the linuxX64 target:

//build.gradle.kts
kotlin {
linuxX64() {
compilations.getByName("main") {
cinterops {
val cinteropForLinuxX64 by creating {
// Configure the CInteropSettings here
}
}
}
}
}

In this example, we've added a cinterop setting named cinteropForLinuxX64 to the linuxX64 main KotlinCompilation. These settings are used to create and configure a cinterop task, along with the necessary dependencies for the compile task.

Types

Link copied to clipboard

A collection of directories to look for headers.

Properties

Link copied to clipboard

The collection of libraries used for building during the C interoperability process. It's equivalent to the -library/-l cinterop tool options.

Functions

Link copied to clipboard
abstract fun compilerOpts(vararg values: String)
abstract fun compilerOpts(values: List<String>)

The options that are passed to the compiler by the cinterop tool.

Link copied to clipboard
abstract fun defFile(file: Any)

Specifies the path to the .def file that declares bindings for the C libraries. This function serves as a setter for the .def file path and is equivalent to passing -def to the cinterop tool.

Link copied to clipboard
abstract fun extraOpts(vararg values: Any)
abstract fun extraOpts(values: List<Any>)

Adds additional options that are passed to the cinterop tool.

Link copied to clipboard
abstract fun getName(): String
Link copied to clipboard
open fun header(file: Any)

Adds a header file to produce Kotlin bindings. It's equivalent to the -header cinterop tool option.

Link copied to clipboard
abstract fun headers(vararg files: Any)
abstract fun headers(files: FileCollection)

Adds header files to produce Kotlin bindings. It's equivalent to the -header cinterop tool option.

Link copied to clipboard
abstract fun includeDirs(vararg values: Any)

A collection of directories to search for headers.

Link copied to clipboard
abstract fun linkerOpts(vararg values: String)
abstract fun linkerOpts(values: List<String>)

Adds additional linker options. It's equivalent to the -linker-options cinterop tool option.

Link copied to clipboard
abstract fun packageName(value: String)

Defines the package name for the generated bindings. It is equivalent to passing -pkg to the cinterop tool.