Allow specifying top level target and flavor in nativeInteropPlugin.

This commit is contained in:
Alexander Gorshenev
2017-10-24 15:01:01 +03:00
committed by alexander-gorshenev
parent 8a8d50f55c
commit 31662cc445
2 changed files with 18 additions and 10 deletions
+3 -8
View File
@@ -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'
}
}
}
@@ -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<NamedNativeInteropConfig> {
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<NamedNat
@Override
protected NamedNativeInteropConfig doCreate(String name) {
return new NamedNativeInteropConfig(project, name)
def config = new NamedNativeInteropConfig(project, name, target, flavor)
return config
}
public void target(String value) {
this.target = value
}
public void flavor(String value) {
this.flavor = value
}
}