Move builtins generators to their own source set

Make them depend on bootstrap stdlib.
This is to prevent recompiling the entire project when we need just to
generate builtins sources.
This commit is contained in:
Ilya Gorbunov
2018-04-26 00:07:17 +03:00
parent a704a1b6d0
commit 7438d12ad7
14 changed files with 51 additions and 32 deletions
+3 -2
View File
@@ -7,6 +7,7 @@ import org.gradle.api.file.CopySourceSpec
import org.gradle.api.file.SourceDirectorySet import org.gradle.api.file.SourceDirectorySet
import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetOutput import org.gradle.api.tasks.SourceSetOutput
import org.gradle.kotlin.dsl.creating import org.gradle.kotlin.dsl.creating
import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.extra
@@ -52,8 +53,8 @@ var Project.javaHome: String?
get() = extra.takeIf { it.has("javaHome") }?.get("javaHome") as? String get() = extra.takeIf { it.has("javaHome") }?.get("javaHome") as? String
set(v) { extra["javaHome"] = v } set(v) { extra["javaHome"] = v }
fun Project.generator(fqName: String) = smartJavaExec { fun Project.generator(fqName: String, sourceSet: SourceSet? = null) = smartJavaExec {
classpath = the<JavaPluginConvention>().sourceSets["test"].runtimeClasspath classpath = (sourceSet ?: the<JavaPluginConvention>().sourceSets["test"]).runtimeClasspath
main = fqName main = fqName
workingDir = rootDir workingDir = rootDir
} }
+14 -4
View File
@@ -4,6 +4,16 @@ plugins {
id("jps-compatible") id("jps-compatible")
} }
sourceSets {
"main" { }
"test" { projectDefault() }
}
val builtinsSourceSet = the<JavaPluginConvention>().sourceSets.create("builtins") {
java.srcDir("builtins")
}
val builtinsCompile by configurations
dependencies { dependencies {
compile(projectTests(":compiler:cli")) compile(projectTests(":compiler:cli"))
compile(projectTests(":idea:idea-maven")) compile(projectTests(":idea:idea-maven"))
@@ -18,17 +28,15 @@ dependencies {
compile(projectTests(":kotlin-noarg-compiler-plugin")) compile(projectTests(":kotlin-noarg-compiler-plugin"))
compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin")) compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin"))
compile(projectTests(":generators:test-generator")) compile(projectTests(":generators:test-generator"))
builtinsCompile("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion")
testCompileOnly(intellijDep("jps-build-test")) testCompileOnly(intellijDep("jps-build-test"))
testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-reflect-api"))
testCompile(intellijDep("jps-build-test")) testCompile(intellijDep("jps-build-test"))
testCompile(builtinsSourceSet.output)
testRuntime(intellijDep()) { includeJars("idea_rt") } testRuntime(intellijDep()) { includeJars("idea_rt") }
testRuntime(projectDist(":kotlin-reflect")) testRuntime(projectDist(":kotlin-reflect"))
} }
sourceSets {
"main" { }
"test" { projectDefault() }
}
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
@@ -41,4 +49,6 @@ val generateProtoBufCompare by generator("org.jetbrains.kotlin.generators.protob
val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt") val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt")
val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet)
testsJar() testsJar()
+14 -4
View File
@@ -4,6 +4,16 @@ plugins {
id("jps-compatible") id("jps-compatible")
} }
sourceSets {
"main" { }
"test" { projectDefault() }
}
val builtinsSourceSet = the<JavaPluginConvention>().sourceSets.create("builtins") {
java.srcDir("builtins")
}
val builtinsCompile by configurations
dependencies { dependencies {
compile(projectTests(":compiler:cli")) compile(projectTests(":compiler:cli"))
compile(projectTests(":idea:idea-maven")) compile(projectTests(":idea:idea-maven"))
@@ -18,16 +28,14 @@ dependencies {
compile(projectTests(":kotlin-noarg-compiler-plugin")) compile(projectTests(":kotlin-noarg-compiler-plugin"))
compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin")) compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin"))
compile(projectTests(":generators:test-generator")) compile(projectTests(":generators:test-generator"))
builtinsCompile("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion")
// testCompileOnly(intellijDep("jps-build-test")) // testCompileOnly(intellijDep("jps-build-test"))
testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-reflect-api"))
testCompile(builtinsSourceSet.output)
testRuntime(intellijDep()) { includeJars("idea_rt") } testRuntime(intellijDep()) { includeJars("idea_rt") }
testRuntime(projectDist(":kotlin-reflect")) testRuntime(projectDist(":kotlin-reflect"))
} }
sourceSets {
"main" { }
"test" { projectDefault() }
}
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
@@ -40,4 +48,6 @@ val generateProtoBufCompare by generator("org.jetbrains.kotlin.generators.protob
val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt") val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt")
val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet)
testsJar() testsJar()
+14 -4
View File
@@ -4,6 +4,16 @@ plugins {
id("jps-compatible") id("jps-compatible")
} }
sourceSets {
"main" { }
"test" { projectDefault() }
}
val builtinsSourceSet = the<JavaPluginConvention>().sourceSets.create("builtins") {
java.srcDir("builtins")
}
val builtinsCompile by configurations
dependencies { dependencies {
compile(projectTests(":compiler:cli")) compile(projectTests(":compiler:cli"))
compile(projectTests(":idea:idea-maven")) compile(projectTests(":idea:idea-maven"))
@@ -19,15 +29,13 @@ dependencies {
compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin")) compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin"))
compile(projectTests(":generators:test-generator")) compile(projectTests(":generators:test-generator"))
// testCompileOnly(intellijDep("jps-build-test")) // testCompileOnly(intellijDep("jps-build-test"))
builtinsCompile("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion")
testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-reflect-api"))
testCompile(builtinsSourceSet.output)
testRuntime(intellijDep()) { includeJars("idea_rt") } testRuntime(intellijDep()) { includeJars("idea_rt") }
testRuntime(projectDist(":kotlin-reflect")) testRuntime(projectDist(":kotlin-reflect"))
} }
sourceSets {
"main" { }
"test" { projectDefault() }
}
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
@@ -40,4 +48,6 @@ val generateProtoBufCompare by generator("org.jetbrains.kotlin.generators.protob
val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt") val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt")
val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet)
testsJar() testsJar()
@@ -1,24 +1,12 @@
/* /*
* Copyright 2010-2016 JetBrains s.r.o. * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* * that can be found in the license/LICENSE.txt file.
* 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.
*/ */
package org.jetbrains.kotlin.generators.builtins.ranges package org.jetbrains.kotlin.generators.builtins.ranges
import org.jetbrains.kotlin.generators.builtins.PrimitiveType import org.jetbrains.kotlin.generators.builtins.PrimitiveType
import org.jetbrains.kotlin.generators.builtins.generateBuiltIns.BuiltInsSourceGenerator import org.jetbrains.kotlin.generators.builtins.generateBuiltIns.BuiltInsSourceGenerator
import org.jetbrains.kotlin.util.OperatorNameConventions
import java.io.PrintWriter import java.io.PrintWriter
class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
@@ -43,7 +31,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
"and" to "Performs a bitwise AND operation between the two values.", "and" to "Performs a bitwise AND operation between the two values.",
"or" to "Performs a bitwise OR operation between the two values.", "or" to "Performs a bitwise OR operation between the two values.",
"xor" to "Performs a bitwise XOR operation between the two values.") "xor" to "Performs a bitwise XOR operation between the two values.")
private val typeDescriptions: Map<PrimitiveType, String> = hashMapOf( private val typeDescriptions: Map<PrimitiveType, String> = mapOf(
PrimitiveType.DOUBLE to "double-precision 64-bit IEEE 754 floating point number", PrimitiveType.DOUBLE to "double-precision 64-bit IEEE 754 floating point number",
PrimitiveType.FLOAT to "single-precision 32-bit IEEE 754 floating point number", PrimitiveType.FLOAT to "single-precision 32-bit IEEE 754 floating point number",
PrimitiveType.LONG to "64-bit signed integer", PrimitiveType.LONG to "64-bit signed integer",
@@ -57,7 +45,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
PrimitiveType.INT -> listOf(java.lang.Integer.MIN_VALUE, java.lang.Integer.MAX_VALUE) PrimitiveType.INT -> listOf(java.lang.Integer.MIN_VALUE, java.lang.Integer.MAX_VALUE)
PrimitiveType.BYTE -> listOf(java.lang.Byte.MIN_VALUE, java.lang.Byte.MAX_VALUE) PrimitiveType.BYTE -> listOf(java.lang.Byte.MIN_VALUE, java.lang.Byte.MAX_VALUE)
PrimitiveType.SHORT -> listOf(java.lang.Short.MIN_VALUE, java.lang.Short.MAX_VALUE) PrimitiveType.SHORT -> listOf(java.lang.Short.MIN_VALUE, java.lang.Short.MAX_VALUE)
PrimitiveType.LONG ->listOf((java.lang.Long.MIN_VALUE + 1).toString() + "L - 1L", java.lang.Long.MAX_VALUE.toString() + "L") PrimitiveType.LONG -> listOf((java.lang.Long.MIN_VALUE + 1).toString() + "L - 1L", java.lang.Long.MAX_VALUE.toString() + "L")
// PrimitiveType.DOUBLE -> listOf(java.lang.Double.MIN_VALUE, java.lang.Double.MAX_VALUE, "1.0/0.0", "-1.0/0.0", "0.0/0.0") // PrimitiveType.DOUBLE -> listOf(java.lang.Double.MIN_VALUE, java.lang.Double.MAX_VALUE, "1.0/0.0", "-1.0/0.0", "0.0/0.0")
// PrimitiveType.FLOAT -> listOf(java.lang.Float.MIN_VALUE, java.lang.Float.MAX_VALUE, "1.0F/0.0F", "-1.0F/0.0F", "0.0F/0.0F").map { it as? String ?: "${it}F" } // PrimitiveType.FLOAT -> listOf(java.lang.Float.MIN_VALUE, java.lang.Float.MAX_VALUE, "1.0F/0.0F", "-1.0F/0.0F", "0.0F/0.0F").map { it as? String ?: "${it}F" }
else -> throw IllegalArgumentException("type: $type") else -> throw IllegalArgumentException("type: $type")
@@ -167,10 +155,10 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
out.println(" /** $doc */") out.println(" /** $doc */")
when (name) { when (name) {
OperatorNameConventions.REM.asString() -> "rem" ->
out.println(" @SinceKotlin(\"1.1\")") out.println(" @SinceKotlin(\"1.1\")")
OperatorNameConventions.MOD.asString() -> "mod" ->
out.println(" @Deprecated(\"Use rem(other) instead\", ReplaceWith(\"rem(other)\"), DeprecationLevel.WARNING)") out.println(" @Deprecated(\"Use rem(other) instead\", ReplaceWith(\"rem(other)\"), DeprecationLevel.WARNING)")
} }
out.println(" public operator fun $name(other: ${otherKind.capitalized}): ${returnType.capitalized}") out.println(" public operator fun $name(other: ${otherKind.capitalized}): ${returnType.capitalized}")