c4abb8f706
* Implement CValues.equals and .hashCode * Add trivial test for interop varargs * Implement varargs in interop for Kotlin N * Compile and link runtime with libffi * Fix few places.
116 lines
2.9 KiB
Groovy
116 lines
2.9 KiB
Groovy
abstract class NativeDep extends DefaultTask {
|
|
|
|
private String getCurrentHostTarget() {
|
|
if (project.isMac() && project.isAmd64()) {
|
|
return 'darwin-macos'
|
|
} else if (project.isLinux() && project.isAmd64()) {
|
|
return 'linux-x86-64'
|
|
} else {
|
|
throw project.unsupportedPlatformException()
|
|
}
|
|
}
|
|
|
|
protected final String host = getCurrentHostTarget();
|
|
|
|
@Input
|
|
abstract String getFileName()
|
|
|
|
protected String getUrl() {
|
|
return "https://jetbrains.bintray.com/kotlin-native-dependencies/$fileName"
|
|
}
|
|
|
|
protected File getBaseOutDir() {
|
|
final File res = project.file("all")
|
|
res.mkdirs()
|
|
return res
|
|
}
|
|
|
|
protected File download() {
|
|
File result = new File(baseOutDir, fileName)
|
|
if (!result.exists())
|
|
ant.get(src: url, dest: result, usetimestamp: true)
|
|
return result
|
|
}
|
|
}
|
|
|
|
class TgzNativeDep extends NativeDep {
|
|
String baseName
|
|
|
|
@Override
|
|
String getFileName() {
|
|
return "${baseName}.tar.gz"
|
|
}
|
|
|
|
@OutputDirectory
|
|
File getOutputDir() {
|
|
return new File(baseOutDir, baseName)
|
|
}
|
|
|
|
@TaskAction
|
|
public void downloadAndExtract() {
|
|
File archived = this.download()
|
|
|
|
try {
|
|
// Builtin Gradle unpacking tools seem to unable to handle symlinks;
|
|
// Use external "tar" executable as workaround:
|
|
project.exec {
|
|
executable "tar"
|
|
workingDir baseOutDir
|
|
args "xf", archived
|
|
}
|
|
} catch (Throwable e) {
|
|
e.printStackTrace()
|
|
project.delete(outputDir)
|
|
throw e
|
|
}
|
|
|
|
// TODO: improve downloaded files caching
|
|
// TODO: do not extract if already extracted
|
|
}
|
|
}
|
|
|
|
|
|
task hostLibffi(type: TgzNativeDep) {
|
|
baseName = "libffi-3.2.1-2-$host"
|
|
}
|
|
|
|
task llvm(type: TgzNativeDep) {
|
|
baseName = "clang+llvm-$llvmVersion-$host"
|
|
}
|
|
|
|
if (isLinux()) {
|
|
task gccToolchain(type: TgzNativeDep) {
|
|
baseName = "target-gcc-toolchain-3-$host"
|
|
}
|
|
task raspberryPiSysroot(type: TgzNativeDep) {
|
|
baseName = "target-sysroot-1-raspberrypi"
|
|
}
|
|
task raspberrypiLibffi(type: TgzNativeDep) {
|
|
baseName = "libffi-3.2.1-2-raspberrypi"
|
|
}
|
|
} else {
|
|
task hostSysroot(type: TgzNativeDep) {
|
|
baseName = "target-sysroot-1-$host"
|
|
}
|
|
task iphoneSysroot(type: TgzNativeDep) {
|
|
baseName = "target-sysroot-2-darwin-ios"
|
|
}
|
|
task iphoneLibffi(type: TgzNativeDep) {
|
|
baseName = "libffi-3.2.1-2-darwin-ios"
|
|
}
|
|
// TODO: re-enable when we known how to bring the simulator
|
|
// sysroot to dependencies.
|
|
// task iphoneSimSysroot(type: TgzNativeDep) {
|
|
// baseName = "target-sysroot-1-darwin-ios-sim"
|
|
// }
|
|
}
|
|
|
|
|
|
task update {
|
|
dependsOn tasks.withType(NativeDep)
|
|
}
|
|
|
|
tasks.withType(TgzNativeDep) {
|
|
rootProject.ext.set("${name}Dir", outputDir.path)
|
|
}
|