Interop: implement stub gen without .def

also add some default values to .def file format
This commit is contained in:
Svyatoslav Scherbina
2016-10-12 16:46:41 +03:00
parent fc5c7ac6df
commit 94f3c1d048
3 changed files with 70 additions and 29 deletions
@@ -22,7 +22,10 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
private String defFile
private String pkg;
private List<String> compilerOpts = []
private FileCollection headers;
private List<String> linkerOpts = []
private FileCollection linkFiles;
private List<String> linkTasks = []
@@ -32,10 +35,19 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
genTask.inputs.file(project.file(defFile))
}
void pkg(String value) {
pkg = value
}
void compilerOpts(String... values) {
compilerOpts.addAll(values)
}
void headers(FileCollection files) {
dependsOnFiles(files)
headers = headers + files
}
void linkerOpts(String... values) {
linkerOpts.addAll(values)
}
@@ -95,6 +107,7 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
this.name = name
this.project = project
this.headers = project.files()
this.linkFiles = project.files()
interopStubs = project.sourceSets.create(name + "InteropStubs")
@@ -139,10 +152,21 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named {
linkerOpts += linkFiles.files
args = [generatedSrcDir, nativeLibsDir, project.file(defFile)]
args = [generatedSrcDir, nativeLibsDir]
if (defFile != null) {
args "-def:" + project.file(defFile)
}
if (pkg != null) {
args "-pkg:" + pkg
}
args compilerOpts.collect { "-copt:$it" }
args linkerOpts.collect { "-lopt:$it" }
headers.files.each {
args "-h:$it"
}
}
}
}