From 31662cc44537a54d683d2659f03914e7bdbde553 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 24 Oct 2017 15:01:01 +0300 Subject: [PATCH] Allow specifying top level target and flavor in nativeInteropPlugin. --- backend.native/tests/build.gradle | 11 +++-------- .../jetbrains/kotlin/NativeInteropPlugin.groovy | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 3202425f1ce..fb726096ba6 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -2099,41 +2099,37 @@ task inline_defaultArgs_linkTest(type: LinkKonanTest) { } kotlinNativeInterop { + target project.testTarget ?: 'host' + flavor 'native' + sysstat { pkg 'sysstat' headers 'sys/stat.h' - flavor 'native' } cstdlib { pkg 'cstdlib' headers 'stdlib.h' - flavor 'native' } cstdio { defFile 'interop/basics/cstdio.def' - flavor 'native' } sockets { defFile 'interop/basics/sockets.def' - flavor 'native' } bitfields { defFile 'interop/basics/bitfields.def' - flavor 'native' } cglobals { defFile 'interop/basics/cglobals.def' - flavor 'native' } cfunptr { defFile 'interop/basics/cfunptr.def' - flavor 'native' } if (isMac()) { @@ -2141,7 +2137,6 @@ kotlinNativeInterop { defFile 'interop/objc/objcSmoke.def' headers "$projectDir/interop/objc/smoke.h" linkerOpts "-L$buildDir", "-lobjcsmoke" - flavor 'native' } } } diff --git a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 75ba57cf6bf..5fdc6a96bdd 100644 --- a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -152,9 +152,11 @@ class NamedNativeInteropConfig implements Named { return new File(project.buildDir, "nativeInteropStubs/$name/kotlin") } - NamedNativeInteropConfig(Project project, String name) { + NamedNativeInteropConfig(Project project, String name, String target = null, String flavor = 'jvm') { this.name = name this.project = project + this.target = target + this.flavor = flavor this.headers = [] this.linkFiles = project.files() @@ -254,6 +256,8 @@ class NamedNativeInteropConfig implements Named { class NativeInteropExtension extends AbstractNamedDomainObjectContainer { private final Project project + private String target = null + private String flavor = 'jvm' protected NativeInteropExtension(Project project) { super(NamedNativeInteropConfig, project.gradle.services.get(Instantiator)) @@ -262,7 +266,16 @@ class NativeInteropExtension extends AbstractNamedDomainObjectContainer