gradle-plugin: Allow compile time measurement
This commit is contained in:
+39
-19
@@ -67,12 +67,24 @@ Each element (interop) in this block corresponds to some native library describe
|
||||
|
||||
Each interop is processed by the plugin in two steps:
|
||||
|
||||
1. Stub generation. In this step the plugin uses `cinterop` tool to generate Kotlin and bitcode (*.bc) stubs for the
|
||||
1. **Stub generation.** In this step the plugin uses `cinterop` tool to generate Kotlin and bitcode (*.bc) stubs for the
|
||||
library. You can specify additional parameters for this tool in the interop block (e.g. a custom def-file is specified
|
||||
in the example above). See [**Plugin DSL**](#plugin-dsl) section below for available parameters and
|
||||
[`INTEROP.md`](INTEROP.md) for `cinterop` tool description.
|
||||
2. Stub compilation. In this step the plugin uses Kotlin/Native compiler to compile the stubs generated by the step (1)
|
||||
2. **Stub compilation.** In this step the plugin uses Kotlin/Native compiler to compile the stubs generated by the step (1)
|
||||
into a klib which can be linked with a Kotlin/Native application.
|
||||
Usually there is no need to specify additional compilation options for this stage. But if for some reason you need to do
|
||||
it, you can use `compileStubsConfig` property of an interop. This property provides an access to a `KonanCompileConfig`
|
||||
object containing the same methods as an artifact in the `konanArtifacts` block. E.g. this sample enables time measurement
|
||||
for compilation of stubs:
|
||||
|
||||
```
|
||||
konanInterop {
|
||||
stdio {
|
||||
compileStubsConfig.measureTime true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To build some artifact with an interop add `useInterop` command in the artifact section:
|
||||
|
||||
@@ -99,11 +111,11 @@ You can also pass additional command line keys to the compiler or cinterop tool
|
||||
available an artifact or interop block. For example this sample enables a verbose output for a link and bitcode
|
||||
generation stages and prints execution time for all compiler phases:
|
||||
|
||||
konanArtifacts
|
||||
foo {
|
||||
extraOpts '--verbose', 'linker', '--verbose', 'bitcode', '--time'
|
||||
}
|
||||
}
|
||||
konanArtifacts
|
||||
foo {
|
||||
extraOpts '--verbose', 'linker', '--verbose', 'bitcode', '--time'
|
||||
}
|
||||
}
|
||||
|
||||
Any command line key supported by the according tool (compiler or cinterop) can be used. Some of them are listed in the
|
||||
tables below.
|
||||
@@ -154,6 +166,7 @@ You may get this task using the `compilationTask` property of an artifact or by
|
||||
|`noMain `|`boolean` |Is the `main` function provided by a library used |
|
||||
|`enableOptimization`|`boolean` |Is the optimization enabled |
|
||||
|`enableAssertions `|`boolean` |Is the assertion support enabled |
|
||||
|`measureTime `|`boolean` |Does the compiler print phase time |
|
||||
|
||||
* __gen*InteropName*InteropStubs__. The plugin creates such a task for each an interop defined in a `konanInterop` block.
|
||||
You may get this task using `generateStubsTask` property of an interop object or by its name:
|
||||
@@ -166,15 +179,16 @@ You may get this task using `generateStubsTask` property of an interop object or
|
||||
Such a task generates stubs for the library defined by the interop and has the following properties accessible
|
||||
from a build script
|
||||
|
||||
|Property |Type |Description |
|
||||
|-------------- |----------------------------|--------------------------------------------------|
|
||||
|`stubsDir `|`File` |An output directory for the Kotlin stubs generated|
|
||||
|`libsDir `|`File` |An output directory for the compiled stubs |
|
||||
|`defFile `|`File` |Def-file used by the interop |
|
||||
|`compilerOpts `|`List<String>` |Additional options passed to clang |
|
||||
|`linkerOpts `|`List<String>` |Additional options passed to a linker |
|
||||
|`headers `|`Collection<FileCollection>`|Additional headers used for stub generation |
|
||||
|`linkFiles `|`Collection<FileCollection>`|Additional files linked with the stubs |
|
||||
|Property |Type |Description |
|
||||
|-------------- |----------------------------|--------------------------------------------------------|
|
||||
|`stubsDir `|`File` |An output directory for the Kotlin stubs generated |
|
||||
|`libsDir `|`File` |An output directory for the compiled stubs |
|
||||
|`defFile `|`File` |Def-file used by the interop |
|
||||
|`compilerOpts `|`List<String>` |Additional options passed to clang |
|
||||
|`linkerOpts `|`List<String>` |Additional options passed to a linker |
|
||||
|`headers `|`Collection<FileCollection>`|Additional headers used for stub generation |
|
||||
|`linkFiles `|`Collection<FileCollection>`|Additional files linked with the stubs |
|
||||
|`measureTime `|`boolean` |Does the compiler print phase time for stubs compilation|
|
||||
|
||||
* __compile*InteropName*InteropStubs__. The plugin creates such a task for each interop defined in a `konanInterop` block.
|
||||
You may get this task using `compileStubsTask` property of an interop object or by its name:
|
||||
@@ -271,7 +285,10 @@ For this project the task graph will be the following:
|
||||
useInterop "interopName"
|
||||
|
||||
// Print all parameters during the build.
|
||||
dumpParameters(true)
|
||||
dumpParameters true
|
||||
|
||||
// Print time of compilation phases (equivalent of the `--time` command line option).
|
||||
measureTime true
|
||||
|
||||
// Add the `anotherTask` to the compilation task dependencies.
|
||||
dependsOn anotherTask
|
||||
@@ -294,10 +311,13 @@ For this project the task graph will be the following:
|
||||
headers project.files('header1.h', 'header2.h') // Additional headers to parse.
|
||||
includeDirs "include/directory" "another/directory" // Directories to look for headers.
|
||||
|
||||
link <files which will be linked with native stubs> // Additional files to link with native stubs.
|
||||
link <files which will be linked with native stubs> // Additional files to link with native stubs.
|
||||
|
||||
dumpParameters(true) // Print all parameters during the build.
|
||||
dumpParameters true // Print all parameters during the build.
|
||||
|
||||
// Print time of stub compilation phases (equivalent of the `--time` command line option).
|
||||
measureTime true
|
||||
|
||||
// Add the `anotherTask` to the stub generation task dependencies.
|
||||
dependsOn anotherTask
|
||||
|
||||
|
||||
Reference in New Issue
Block a user