Skip to content

Commit

Permalink
Allow specifying top level target and flavor in nativeInteropPlugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-gorshenev committed Oct 25, 2017
1 parent 8a8d50f commit 31662cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 3 additions & 8 deletions backend.native/tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2099,49 +2099,44 @@ 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()) {
objcSmoke {
defFile 'interop/objc/objcSmoke.def'
headers "$projectDir/interop/objc/smoke.h"
linkerOpts "-L$buildDir", "-lobjcsmoke"
flavor 'native'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand All @@ -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
}
}

Expand Down

0 comments on commit 31662cc

Please sign in to comment.