Compare commits

...

9 Commits

Author SHA1 Message Date
Vyacheslav Gerasimov
ad671f7ad5 Build: Make proguard task cacheable 2020-02-04 02:44:04 +03:00
Vyacheslav Gerasimov
52d03fa3eb Always checkout/checkin text files with lf endings
Different line endings on linux/windows prevents gradle from reusing
build cache since endings make task inputs completely different between
systems
2020-02-03 20:08:48 +03:00
Vyacheslav Gerasimov
e82739cf80 Build: Make buildKLib tasks cacheable 2020-02-03 19:39:05 +03:00
Vyacheslav Gerasimov
432789c949 Build: Make compiler:fir:tree:generateTree cacheable 2020-02-03 16:45:50 +03:00
Vyacheslav Gerasimov
d37a40300b Build: Make DexMethodCount task cacheable 2020-02-03 16:45:50 +03:00
Vyacheslav Gerasimov
d5283c859b Build: Enable caching for all proguard tasks in the build 2020-02-03 16:45:50 +03:00
Vyacheslav Gerasimov
0aa84d6007 Build: Add buildserver.labs.intellij.net to valid hosts in caching check 2020-02-03 16:45:50 +03:00
Vyacheslav Gerasimov
83fc7f166a Build: Use sourceMapBaseDirs in :kotlin-stdlib-js:compileKotlin2Js
instead of freeCompiler args to avoid snapshotting absolute paths
and fix caching
2020-02-03 16:45:50 +03:00
Vyacheslav Gerasimov
43d596b247 Advance bootstrap to 1.4.0-dev-1818 2020-02-03 16:45:50 +03:00
12 changed files with 213 additions and 38 deletions

2
.gitattributes vendored
View File

@@ -1,4 +1,6 @@
**/testData/** linguist-vendored
*Generated.java linguist-generated=true
* eol=lf
compiler/cli/bin/* eol=lf
compiler/cli/bin/*.bat eol=crlf

View File

@@ -8,7 +8,7 @@ buildscript {
extra["defaultSnapshotVersion"] = "1.4-SNAPSHOT"
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
kotlinBootstrapFrom(BootstrapOption.BintrayBootstrap("1.4.0-dev-1075", cacheRedirectorEnabled))
kotlinBootstrapFrom(BootstrapOption.BintrayBootstrap("1.4.0-dev-1818", cacheRedirectorEnabled))
repositories {
bootstrapKotlinRepo?.let(::maven)
@@ -30,7 +30,6 @@ buildscript {
classpath("com.gradle.publish:plugin-publish-plugin:0.9.7")
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
classpath("net.sf.proguard:proguard-gradle:6.1.0")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17")
}
}

View File

@@ -102,6 +102,7 @@ dependencies {
implementation("com.jakewharton.dex:dex-method-list:3.0.0")
implementation("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
implementation("net.sf.proguard:proguard-gradle:6.2.2")
implementation("org.jetbrains.intellij.deps:asm-all:7.0.1")
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.5")

View File

@@ -0,0 +1,153 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.*
@CacheableTask
open class CacheableProguardTask : proguard.gradle.ProGuardTask() {
@Input
override fun getOutJarFilters(): MutableList<Any?> = super.getOutJarFilters()
@Input
override fun getrenamesourcefileattribute(): Any = super.getrenamesourcefileattribute()
@Input
override fun getprintusage(): Any = super.getprintusage()
@Input
override fun getforceprocessing(): Any = super.getforceprocessing()
@Input
override fun getInJarFilters(): MutableList<Any?> = super.getInJarFilters()
@Input
override fun getdontwarn(): Any = super.getdontwarn()
@Input
override fun getaddconfigurationdebugging(): Any = super.getaddconfigurationdebugging()
@Input
override fun getallowaccessmodification(): Any = super.getallowaccessmodification()
@Input
override fun getignorewarnings(): Any = super.getignorewarnings()
@Input
override fun getkeepdirectories(): Any = super.getkeepdirectories()
@Input
override fun getuseuniqueclassmembernames(): Any = super.getuseuniqueclassmembernames()
@Input
override fun getmicroedition(): Any = super.getmicroedition()
@Input
override fun getandroid(): Any = super.getandroid()
@Input
override fun getoverloadaggressively(): Any = super.getoverloadaggressively()
@Input
override fun getdontusemixedcaseclassnames(): Any = super.getdontusemixedcaseclassnames()
@Input
override fun getdontnote(): Any = super.getdontnote()
@Internal
override fun getInJarFiles(): MutableList<Any?> = super.getInJarFiles()
@Input
override fun getInJarCounts(): MutableList<Any?> = super.getInJarCounts()
@Input
override fun getdontpreverify(): Any = super.getdontpreverify()
@Input
override fun getverbose(): Any = super.getverbose()
@Input
override fun getskipnonpubliclibraryclasses(): Any = super.getskipnonpubliclibraryclasses()
@Input
override fun getdontoptimize(): Any = super.getdontoptimize()
@Input
override fun getdump(): Any = super.getdump()
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
override fun getInJarFileCollection(): FileCollection = super.getInJarFileCollection()
@Input
override fun getdontobfuscate(): Any = super.getdontobfuscate()
@Input
override fun getLibraryJarFilters(): MutableList<Any?> = super.getLibraryJarFilters()
@Input
override fun getprintmapping(): Any = super.getprintmapping()
@Input
override fun getdontshrink(): Any = super.getdontshrink()
@Input
override fun getkeepattributes(): Any = super.getkeepattributes()
@Internal
override fun getOutJarFileCollection(): FileCollection = super.getOutJarFileCollection()
@Input
override fun getdontskipnonpubliclibraryclassmembers(): Any = super.getdontskipnonpubliclibraryclassmembers()
@Input
override fun getprintconfiguration(): Any = super.getprintconfiguration()
@Input
override fun getmergeinterfacesaggressively(): Any = super.getmergeinterfacesaggressively()
@Input
override fun getConfigurationFiles(): MutableList<Any?> = super.getConfigurationFiles()
@Input
override fun getkeeppackagenames(): Any = super.getkeeppackagenames()
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
override fun getLibraryJarFileCollection(): FileCollection = super.getLibraryJarFileCollection()
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
override fun getConfigurationFileCollection(): FileCollection = super.getConfigurationFileCollection()
@Input
override fun getprintseeds(): Any = super.getprintseeds()
@Input
override fun getadaptresourcefilenames(): Any = super.getadaptresourcefilenames()
@Input
override fun getrepackageclasses(): Any = super.getrepackageclasses()
@Input
override fun getadaptresourcefilecontents(): Any = super.getadaptresourcefilecontents()
@Input
override fun getflattenpackagehierarchy(): Any = super.getflattenpackagehierarchy()
@Input
override fun getadaptclassstrings(): Any = super.getadaptclassstrings()
@Internal
override fun getLibraryJarFiles(): MutableList<Any?> = super.getLibraryJarFiles()
@Input
override fun getkeepparameternames(): Any = super.getkeepparameternames()
@Internal
override fun getOutJarFiles(): MutableList<Any?> = super.getOutJarFiles()
}

View File

@@ -21,9 +21,11 @@ open class DexMethodCount : DefaultTask() {
init {
outputs.upToDateWhen { !shouldPrintTeamCityStatistics } // always execute when teamCityStatistics output is required
outputs.cacheIf { true }
}
@InputFile
@PathSensitive(PathSensitivity.RELATIVE)
lateinit var jarFile: File
@Input

View File

@@ -1,10 +1,11 @@
import org.jetbrains.kotlin.ideaExt.idea
/*
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
import org.jetbrains.kotlin.ideaExt.idea
plugins {
kotlin("jvm")
id("jps-compatible")
@@ -43,7 +44,10 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) {
}
inputs.files(generatorConfigurationFiles)
.withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dirs(generationRoot)
outputs.cacheIf { true }
args(generationRoot)
classpath = generatorClasspath

View File

@@ -108,8 +108,10 @@ fun RepositoryHandler.redirect() {
}
}
// teamcity.jetbrains.com is located in the same local network with build agents
fun URI.isCachedOrLocal() = host == "cache-redirector.jetbrains.com" || scheme == "file" || host == "teamcity.jetbrains.com"
fun URI.isCachedOrLocal() = scheme == "file" ||
host == "cache-redirector.jetbrains.com" ||
host == "teamcity.jetbrains.com" ||
host == "buildserver.labs.intellij.net"
fun RepositoryHandler.findNonCachedRepositories(): List<String> {
val mavenNonCachedRepos = filterIsInstance<MavenArtifactRepository>()

View File

@@ -143,10 +143,8 @@ val stripMetadata by tasks.registering {
val proguardOutput = "$libsDir/${property("archivesBaseName")}-proguard.jar"
val proguard by task<ProGuardTask> {
val proguard by task<CacheableProguardTask> {
dependsOn(stripMetadata)
inputs.files(stripMetadata.get().outputs.files)
outputs.file(proguardOutput)
injars(mapOf("filter" to "!META-INF/versions/**"), stripMetadata.get().outputs.files)
injars(mapOf("filter" to "!META-INF/**,!**/*.kotlin_builtins"), proguardAdditionalInJars)

View File

@@ -162,13 +162,29 @@ val reducedRuntimeSources by task<Sync> {
into("$buildDir/reducedRuntime/src")
}
fun JavaExec.buildKLib(moduleName: String, sources: List<String>, dependencies: List<String>, outPath: String, commonSources: List<String>) {
fun JavaExec.buildKLib(
moduleName: String,
sources: List<File>,
dependencies: List<File>,
outDir: File,
commonSources: List<File>
) {
fun File.pathRelativeToWorkingDir(): String = absoluteFile.relativeTo(workingDir).path
inputs.files(sources)
outputs.dir(file(outPath).parent)
.withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir(file(outDir))
outputs.cacheIf { true }
classpath = jsIrKlibCli
main = "org.jetbrains.kotlin.ir.backend.js.GenerateJsIrKlibKt"
workingDir = rootDir
args = sources.toList() + listOf("-n", moduleName, "-o", outPath) + dependencies.flatMap { listOf("-d", it) } + commonSources.flatMap { listOf("-c", it) }
args = sources.map { it.pathRelativeToWorkingDir() } +
listOf("-n", moduleName, "-o", outDir.pathRelativeToWorkingDir()) +
dependencies.flatMap { listOf("-d", it.pathRelativeToWorkingDir()) } +
commonSources.flatMap { listOf("-c", it.pathRelativeToWorkingDir()) }
dependsOn(":compiler:cli-js-klib:jar")
passClasspathInJar()
@@ -180,10 +196,10 @@ val generateFullRuntimeKLib by eagerTask<NoDebugJavaExec> {
dependsOn(fullRuntimeSources)
buildKLib(moduleName = "kotlin",
sources = listOf(fullRuntimeSources.get().outputs.files.singleFile.path),
sources = listOf(fullRuntimeSources.get().outputs.files.singleFile),
dependencies = emptyList(),
outPath = fullRuntimeDir.absolutePath,
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/fullRuntime/src/libraries/stdlib/$it" }
outDir = fullRuntimeDir,
commonSources = listOf("common", "src", "unsigned").map { file("$buildDir/fullRuntime/src/libraries/stdlib/$it") }
)
}
@@ -197,20 +213,19 @@ val packFullRuntimeKLib by tasks.registering(Jar::class) {
val generateReducedRuntimeKLib by eagerTask<NoDebugJavaExec> {
dependsOn(reducedRuntimeSources)
val outPath = buildDir.resolve("reducedRuntime/klib").absolutePath
buildKLib(moduleName = "kotlin",
sources = listOf(reducedRuntimeSources.get().outputs.files.singleFile.path),
sources = listOf(reducedRuntimeSources.get().outputs.files.singleFile),
dependencies = emptyList(),
outPath = outPath,
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/reducedRuntime/src/libraries/stdlib/$it" }
outDir = buildDir.resolve("reducedRuntime/klib"),
commonSources = listOf("common", "src", "unsigned").map { file("$buildDir/reducedRuntime/src/libraries/stdlib/$it") }
)
}
val generateWasmRuntimeKLib by eagerTask<NoDebugJavaExec> {
buildKLib(moduleName = "kotlin",
sources = listOf("$rootDir/libraries/stdlib/wasm"),
sources = listOf(file("$rootDir/libraries/stdlib/wasm")),
dependencies = emptyList(),
outPath = "$buildDir/wasmRuntime/klib",
outDir = file("$buildDir/wasmRuntime/klib"),
commonSources = emptyList()
)
}
@@ -219,15 +234,16 @@ val kotlinTestCommonSources = listOf(
"$rootDir/libraries/kotlin.test/annotations-common/src/main",
"$rootDir/libraries/kotlin.test/common/src/main"
)
val generateKotlinTestKLib by eagerTask<NoDebugJavaExec> {
dependsOn(generateFullRuntimeKLib)
buildKLib(
moduleName = "kotlin-test",
sources = listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources,
dependencies = listOf("${generateFullRuntimeKLib.outputs.files.singleFile.path}/klib"),
outPath = "$buildDir/kotlin.test/klib",
commonSources = kotlinTestCommonSources
sources = (listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources).map(::file),
dependencies = listOf(generateFullRuntimeKLib.outputs.files.singleFile),
outDir = file("$buildDir/kotlin.test/klib"),
commonSources = kotlinTestCommonSources.map(::file)
)
}

View File

@@ -136,11 +136,11 @@ compileKotlin2Js {
outputFile = "${buildDir}/classes/main/kotlin.js"
sourceMap = true
sourceMapPrefix = "./"
sourceMapBaseDirs = files(
[builtinsSrcDir, jsSrcDir, jsCommonSrcDir, commonSrcDir, commonSrcDir2, unsignedCommonSrcDir]
.collect { file(it).absoluteFile }
)
freeCompilerArgs += [
"-source-map-base-dirs",
[builtinsSrcDir, jsSrcDir, jsCommonSrcDir, commonSrcDir, commonSrcDir2, unsignedCommonSrcDir]
.collect { file(it).absoluteFile }
.join(File.pathSeparator),
"-Xuse-experimental=kotlin.Experimental",
"-Xuse-experimental=kotlin.ExperimentalMultiplatform",
"-Xuse-experimental=kotlin.contracts.ExperimentalContracts",

View File

@@ -70,7 +70,7 @@ val packJar by task<ShadowJar> {
}
}
val proguard by task<ProGuardTask> {
val proguard by task<CacheableProguardTask> {
dependsOn(packJar)
configuration("main-kts.pro")
@@ -80,9 +80,6 @@ val proguard by task<ProGuardTask> {
outjars(outputJar)
inputs.files(packJar.get().outputs.files.singleFile)
outputs.file(outputJar)
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
}

View File

@@ -1,7 +1,6 @@
@file:Suppress("HasPlatformType")
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import proguard.gradle.ProGuardTask
import java.util.regex.Pattern.quote
description = "Kotlin Compiler"
@@ -245,15 +244,17 @@ val packCompiler by task<ShadowJar> {
}
}
val proguard by task<ProGuardTask> {
val proguard by task<CacheableProguardTask> {
dependsOn(packCompiler)
configuration("$rootDir/compiler/compiler.pro")
val outputJar = fileFrom(buildDir, "libs", "$compilerBaseName-after-proguard.jar")
val packedCompilerFile = packCompiler.get().outputs.files.singleFile
inputs.files(packedCompilerFile)
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(packCompiler.get().outputs.files.singleFile)
outputs.file(outputJar)
outputs.cacheIf { true }
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraries)
@@ -261,7 +262,7 @@ val proguard by task<ProGuardTask> {
// This properties are used by proguard config compiler.pro
doFirst {
System.setProperty("kotlin-compiler-jar-before-shrink", packCompiler.get().outputs.files.singleFile.canonicalPath)
System.setProperty("kotlin-compiler-jar-before-shrink", packedCompilerFile.canonicalPath)
System.setProperty("kotlin-compiler-jar", outputJar.canonicalPath)
}
}