a906bd0d07
Don't extract dependencies in dependencies/all, only in dist/dependencies Remove konan.dependencies property
142 lines
3.7 KiB
Groovy
142 lines
3.7 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
}
|
|
}
|
|
|
|
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.rootProject.file("dist/dependencies")
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|
|
class HelperNativeDep extends TgzNativeDep {
|
|
|
|
public HelperNativeDep() {
|
|
dependsOn(':tools:helpers:jar')
|
|
}
|
|
|
|
@TaskAction
|
|
public void downloadAndExtract() {
|
|
project.javaexec {
|
|
main = "org.jetbrains.kotlin.konan.MainKt"
|
|
classpath += project.findProject(':tools:helpers').getConfigurations().getByName("runtime")
|
|
classpath += project.findProject(':tools:helpers').getConfigurations().getByName("runtime").artifacts.files
|
|
args baseOutDir.canonicalPath,
|
|
project.findProject(":backend.native").file("konan.properties").canonicalPath,
|
|
baseName
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
task hostLibffi(type: HelperNativeDep) {
|
|
baseName = "libffi-3.2.1-2-$host"
|
|
}
|
|
|
|
task llvm(type: HelperNativeDep) {
|
|
baseName = "clang-llvm-$llvmVersion-$host"
|
|
}
|
|
|
|
if (isLinux()) {
|
|
task gccToolchain(type: HelperNativeDep) {
|
|
baseName = "target-gcc-toolchain-3-$host"
|
|
}
|
|
task raspberryPiSysroot(type: HelperNativeDep) {
|
|
baseName = "target-sysroot-1-raspberrypi"
|
|
}
|
|
task raspberrypiLibffi(type: HelperNativeDep) {
|
|
baseName = "libffi-3.2.1-2-raspberrypi"
|
|
}
|
|
} else {
|
|
task hostSysroot(type: HelperNativeDep) {
|
|
baseName = "target-sysroot-1-$host"
|
|
}
|
|
task iphoneSysroot(type: HelperNativeDep) {
|
|
baseName = "target-sysroot-2-darwin-ios"
|
|
}
|
|
task iphoneLibffi(type: HelperNativeDep) {
|
|
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(type: Copy) {
|
|
dependsOn tasks.withType(NativeDep)
|
|
}
|
|
|
|
tasks.withType(TgzNativeDep) {
|
|
rootProject.ext.set("${name}Dir", outputDir.path)
|
|
}
|