From 117d3c08e5539f67e33bf0747c6db0065dd57970 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov <41585329+ddolovov@users.noreply.github.com> Date: Mon, 29 Oct 2018 17:55:48 +0700 Subject: [PATCH] FAQ: Examples in MPP DSL, not the first Native DSL. (#2270) * Examples in MPP DSL, not the 1st Native DSL. * Fix formatting for sourse code example. --- FAQ.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/FAQ.md b/FAQ.md index b8e4a0fcc87..2c4f5a536b4 100644 --- a/FAQ.md +++ b/FAQ.md @@ -15,7 +15,14 @@ garbage. ### Q: How do I create a shared library? -A: Use the `-produce dynamic` compiler switch, or `konanArtifacts { dynamic('foo') {} }` in Gradle. +A: Use the `-produce dynamic` compiler switch, or `compilations.main.outputKinds 'DYNAMIC'` in Gradle, i.e. +```groovy +targets { + fromPreset(presets.iosArm64, 'mylib') { + compilations.main.outputKinds 'DYNAMIC' + } +} +``` It will produce a platform-specific shared object (.so on Linux, .dylib on macOS, and .dll on Windows targets) and a C language header, allowing the use of all public APIs available in your Kotlin/Native program from C/C++ code. See `samples/python_extension` for an example of using such a shared object to provide a bridge between Python and @@ -24,7 +31,14 @@ Kotlin/Native. ### Q: How do I create a static library or an object file? -A: Use the `-produce static` compiler switch, or `konanArtifacts { static('foo') {} }` in Gradle. +A: Use the `-produce static` compiler switch, or `compilations.main.outputKinds 'STATIC'` in Gradle, i.e. +```groovy +targets { + fromPreset(presets.iosArm64, 'mylib') { + compilations.main.outputKinds 'STATIC' + } +} +``` It will produce a platform-specific static object (.a library format) and a C language header, allowing you to use all the public APIs available in your Kotlin/Native program from C/C++ code. @@ -113,7 +127,10 @@ You can then set the `KONAN_HOME` env variable to the generated `dist` folder in
For Gradle, you can use Gradle composite builds like this: -``` +
+ + +```bash # Set with the path of your kotlin-native clone export KONAN_REPO=$PWD/../kotlin-native @@ -124,4 +141,6 @@ pushd $KONAN_REPO && git pull && ./gradlew clean dependencies:update dist distPl ./gradlew check -Pkonan.home=$KONAN_REPO/dist --include-build $KONAN_REPO/shared --include-build $KONAN_REPO/tools/kotlin-native-gradle-plugin ``` +
+