223 lines
6.5 KiB
Groovy
223 lines
6.5 KiB
Groovy
/*
|
|
* Copyright 2010-2017 JetBrains s.r.o.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
jcenter()
|
|
}
|
|
|
|
dependencies {
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
|
}
|
|
}
|
|
|
|
apply plugin: 'com.jfrog.bintray'
|
|
|
|
configurations {
|
|
kotlin_compiler_jar
|
|
kotlin_compiler_pom
|
|
}
|
|
|
|
repositories {
|
|
maven { url 'http://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
|
|
maven { url 'http://oss.sonatype.org/content/repositories/snapshots' }
|
|
}
|
|
|
|
dependencies {
|
|
kotlin_compiler_jar "$kotlinCompilerModule@jar"
|
|
kotlin_compiler_pom "$kotlinCompilerModule@pom"
|
|
}
|
|
|
|
// Hack kotlin-compiler pom-file to resolve the dependency correctly.
|
|
task generatePom(type: DefaultTask) {
|
|
def originalPom = configurations.kotlin_compiler_pom.singleFile
|
|
inputs.file(originalPom)
|
|
|
|
def newPom = file("${temporaryDir.canonicalPath}/${originalPom.name}")
|
|
outputs.file(newPom)
|
|
|
|
doLast {
|
|
def xml = new XmlParser().parse(originalPom)
|
|
def parent = xml.parent // <parent> </parent> section, not the parent node.
|
|
def groupId = parent.groupId
|
|
def version = parent.version
|
|
xml.append(groupId)
|
|
xml.append(version)
|
|
xml.remove(parent)
|
|
new XmlNodePrinter(new PrintWriter(new FileWriter(newPom))).print(xml)
|
|
}
|
|
}
|
|
|
|
bintray {
|
|
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
|
key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : System.getenv('BINTRAY_KEY')
|
|
pkg {
|
|
repo = 'kotlin-native-dependencies'
|
|
name = 'kotlin-compiler-builds'
|
|
userOrg = 'jetbrains'
|
|
publish = true
|
|
override = project.hasProperty("override")
|
|
}
|
|
filesSpec {
|
|
// kotlinCompilerModule@jar and @pom -> groupId/with/dots/replaced/by/slashes/artifactId/<major-version>-SNAPSHOT
|
|
// e.g. org.jetbrains.kotlin:kotlin-compiler:1.1-20170426.212805-507 -> org/jetbrains/kotlin/kotlin-compiler/1.1-SNAPSHOT
|
|
def (groupId, artifactId, version) = kotlinCompilerModule.tokenize(':')
|
|
def groupPath = groupId.replace('.', '/')
|
|
def artifactPath = artifactId
|
|
def versionPath = "${version.tokenize('-')[0]}-SNAPSHOT"
|
|
from project.configurations.kotlin_compiler_jar.files
|
|
from generatePom.outputs.files
|
|
into "$groupPath/$artifactPath/$versionPath"
|
|
}
|
|
}
|
|
|
|
task update_kotlin_compiler(type: DefaultTask) {
|
|
dependsOn(bintrayUpload)
|
|
}
|
|
|
|
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();
|
|
String baseUrl = "https://jetbrains.bintray.com/kotlin-native-dependencies"
|
|
|
|
@Input
|
|
abstract String getFileName()
|
|
|
|
protected String getUrl() {
|
|
return "$baseUrl/$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, baseUrl, 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)
|
|
}
|