Remove task for ant, include preprocessor into the compiler, call preprocessor in ant build.
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
<project name="Kotlin" default="dist" xmlns:if="ant:if" xmlns:unless="ant:unless">
|
<project name="Kotlin" default="dist" xmlns:if="ant:if" xmlns:unless="ant:unless">
|
||||||
<include file="jslib_files.xml" />
|
|
||||||
|
|
||||||
<property file="resources/kotlinManifest.properties"/>
|
<property file="resources/kotlinManifest.properties"/>
|
||||||
|
|
||||||
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
|
<!-- Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -->
|
||||||
@@ -16,7 +14,7 @@
|
|||||||
<property name="bootstrap.reflect" value="${bootstrap.compiler.home}/lib/kotlin-reflect.jar"/>
|
<property name="bootstrap.reflect" value="${bootstrap.compiler.home}/lib/kotlin-reflect.jar"/>
|
||||||
|
|
||||||
<property name="output" value="${basedir}/dist"/>
|
<property name="output" value="${basedir}/dist"/>
|
||||||
<property name="intermediate-sources" value="${basedir}/out/src" />
|
<property name="intermediate-sources" value="out/src" />
|
||||||
<property name="kotlin-home" value="${output}/kotlinc"/>
|
<property name="kotlin-home" value="${output}/kotlinc"/>
|
||||||
<property name="build.number" value="snapshot"/>
|
<property name="build.number" value="snapshot"/>
|
||||||
<property name="bootstrap.build.no.tests" value="false"/>
|
<property name="bootstrap.build.no.tests" value="false"/>
|
||||||
@@ -40,6 +38,8 @@
|
|||||||
</or>
|
</or>
|
||||||
</condition>
|
</condition>
|
||||||
|
|
||||||
|
<include file="jslib_files.xml" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
The compiler produced on the first step of the build (Bootstrap No Tests) is only guaranteed to work against the OLD runtime
|
The compiler produced on the first step of the build (Bootstrap No Tests) is only guaranteed to work against the OLD runtime
|
||||||
located in dependencies/bootstrap-compiler/.../kotlin-runtime.jar, because the newly built compiler is just a Kotlin application,
|
located in dependencies/bootstrap-compiler/.../kotlin-runtime.jar, because the newly built compiler is just a Kotlin application,
|
||||||
@@ -87,6 +87,7 @@
|
|||||||
<include name="compiler/builtins-serializer/src"/>
|
<include name="compiler/builtins-serializer/src"/>
|
||||||
<include name="compiler/cli/src"/>
|
<include name="compiler/cli/src"/>
|
||||||
<include name="compiler/cli/cli-common/src"/>
|
<include name="compiler/cli/cli-common/src"/>
|
||||||
|
<include name="compiler/conditional-preprocessor/src/"/>
|
||||||
<include name="compiler/rmi/rmi-server/src"/>
|
<include name="compiler/rmi/rmi-server/src"/>
|
||||||
<include name="compiler/rmi/rmi-interface/src"/>
|
<include name="compiler/rmi/rmi-interface/src"/>
|
||||||
<include name="compiler/container/src"/>
|
<include name="compiler/container/src"/>
|
||||||
@@ -203,6 +204,7 @@
|
|||||||
<fileset dir="compiler/builtins-serializer/src"/>
|
<fileset dir="compiler/builtins-serializer/src"/>
|
||||||
<fileset dir="compiler/cli/src"/>
|
<fileset dir="compiler/cli/src"/>
|
||||||
<fileset dir="compiler/cli/cli-common/src"/>
|
<fileset dir="compiler/cli/cli-common/src"/>
|
||||||
|
<fileset dir="compiler/conditional-preprocessor/src"/>
|
||||||
<fileset dir="compiler/rmi/rmi-server/src"/>
|
<fileset dir="compiler/rmi/rmi-server/src"/>
|
||||||
<fileset dir="compiler/rmi/rmi-interface/src"/>
|
<fileset dir="compiler/rmi/rmi-interface/src"/>
|
||||||
<fileset dir="compiler/container/src"/>
|
<fileset dir="compiler/container/src"/>
|
||||||
@@ -305,6 +307,8 @@
|
|||||||
<property name="compiled.stdlib.meta.js" value="stdlib.meta.js"/>
|
<property name="compiled.stdlib.meta.js" value="stdlib.meta.js"/>
|
||||||
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData"/>
|
<property name="stdlib.js.dir" value="${basedir}/js/js.translator/testData"/>
|
||||||
|
|
||||||
|
<kotlin-pp src="libraries/stdlib/src" output="${intermediate-sources}/stdlib/js" profile="JS" />
|
||||||
|
|
||||||
<new-kotlin2js output="${output}/${compiled.builtins.js}">
|
<new-kotlin2js output="${output}/${compiled.builtins.js}">
|
||||||
<src>
|
<src>
|
||||||
<fileset refid="kotlin.builtin.files"/>
|
<fileset refid="kotlin.builtin.files"/>
|
||||||
@@ -725,6 +729,29 @@
|
|||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
|
|
||||||
|
<macrodef name="kotlin-pp">
|
||||||
|
<attribute name="src"/>
|
||||||
|
<attribute name="output"/>
|
||||||
|
<attribute name="profile"/>
|
||||||
|
|
||||||
|
<sequential>
|
||||||
|
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
|
||||||
|
</classpath>
|
||||||
|
<assertions>
|
||||||
|
<enable/>
|
||||||
|
</assertions>
|
||||||
|
<arg value="-cp"/>
|
||||||
|
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
||||||
|
<arg value="org.jetbrains.kotlin.preprocessor.PreprocessorPackage"/>
|
||||||
|
<arg value="@{src}"/>
|
||||||
|
<arg value="@{output}"/>
|
||||||
|
<arg value="@{profile}"/>
|
||||||
|
</java>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
|
||||||
<target name="builtins">
|
<target name="builtins">
|
||||||
<new-kotlinc output="${output}/classes/builtins" moduleName="kotlin-builtins">
|
<new-kotlinc output="${output}/classes/builtins" moduleName="kotlin-builtins">
|
||||||
<src>
|
<src>
|
||||||
@@ -739,13 +766,10 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="stdlib">
|
<target name="stdlib">
|
||||||
<taskdef name="kotlin-pp" classname="org.jetbrains.kotlin.preprocessor.PreprocessorTask" classpathref="classpath" classpath="out\production\conditional-preprocessor" />
|
<kotlin-pp src="libraries/stdlib/src" output="${intermediate-sources}/stdlib/jvm6" profile="JVM6" />
|
||||||
<kotlin-pp src="libraries/stdlib/src">
|
|
||||||
<jvmprofile version="6" output="${intermediate-sources}/stdlib/jvm6" />
|
|
||||||
</kotlin-pp>
|
|
||||||
<new-kotlinc output="${output}/classes/stdlib" moduleName="kotlin-stdlib" additionalOptions="-Xmultifile-package-facades">
|
<new-kotlinc output="${output}/classes/stdlib" moduleName="kotlin-stdlib" additionalOptions="-Xmultifile-package-facades">
|
||||||
<src>
|
<src>
|
||||||
<include name="libraries/stdlib/src"/>
|
<include name="${intermediate-sources}/stdlib/jvm6"/>
|
||||||
</src>
|
</src>
|
||||||
<class-path>
|
<class-path>
|
||||||
<pathelement path="${output}/classes/builtins"/>
|
<pathelement path="${output}/classes/builtins"/>
|
||||||
|
|||||||
+20
-18
@@ -68,7 +68,7 @@ public class Preprocessor() {
|
|||||||
|
|
||||||
val sourceText = sourceFile.readText().convertLineSeparators()
|
val sourceText = sourceFile.readText().convertLineSeparators()
|
||||||
val psiFile = jetPsiFactory.createFile(sourceFile.name, sourceText)
|
val psiFile = jetPsiFactory.createFile(sourceFile.name, sourceText)
|
||||||
println("$psiFile")
|
//println("$psiFile")
|
||||||
|
|
||||||
|
|
||||||
val fileAnnotations = psiFile.parseConditionalAnnotations()
|
val fileAnnotations = psiFile.parseConditionalAnnotations()
|
||||||
@@ -93,40 +93,42 @@ public class Preprocessor() {
|
|||||||
for (sourceFile in sourceFiles)
|
for (sourceFile in sourceFiles)
|
||||||
{
|
{
|
||||||
val result = processFileSingleEvaluator(sourceFile, evaluator)
|
val result = processFileSingleEvaluator(sourceFile, evaluator)
|
||||||
if (result is FileProcessingResult.Skip)
|
if (result is FileProcessingResult.Skip) {
|
||||||
|
println("$sourceFile is excluded")
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
val destFile = sourceFile.makeRelativeTo(sourceRoot, targetRoot)
|
val targetFile = sourceFile.makeRelativeTo(sourceRoot, targetRoot)
|
||||||
processedFiles += destFile
|
processedFiles += targetFile
|
||||||
|
|
||||||
if (destFile.exists() && destFile.isDirectory)
|
if (targetFile.exists() && targetFile.isDirectory)
|
||||||
destFile.deleteRecursively()
|
targetFile.deleteRecursively()
|
||||||
|
|
||||||
// if no modifications — copy
|
// if no modifications — copy
|
||||||
if (result is FileProcessingResult.Copy) {
|
if (result is FileProcessingResult.Copy) {
|
||||||
FileUtil.copy(sourceFile, destFile)
|
FileUtil.copy(sourceFile, targetFile)
|
||||||
} else if (result is FileProcessingResult.Modify) {
|
} else if (result is FileProcessingResult.Modify) {
|
||||||
val resultText = result.getModifiedText()
|
val resultText = result.getModifiedText()
|
||||||
if (destFile.exists() && destFile.isTextEqualTo(resultText))
|
if (targetFile.exists() && targetFile.isTextEqualTo(resultText))
|
||||||
continue
|
continue
|
||||||
destFile.writeText(resultText)
|
println("Rewriting modified $targetFile")
|
||||||
|
targetFile.writeText(resultText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sourceDir in sourceDirectories) {
|
for (sourceDir in sourceDirectories) {
|
||||||
val destDir = sourceDir.makeRelativeTo(sourceRoot, targetRoot)
|
val targetDir = sourceDir.makeRelativeTo(sourceRoot, targetRoot)
|
||||||
if (!destDir.exists()) {
|
if (targetDir.exists() && !targetDir.isDirectory) {
|
||||||
destDir.mkdirsOrFail()
|
targetDir.delete()
|
||||||
}
|
}
|
||||||
else if (!destDir.isDirectory) {
|
targetDir.mkdirsOrFail()
|
||||||
destDir.delete()
|
processDirectorySingleEvaluator(sourceDir, targetDir, evaluator)
|
||||||
}
|
processedFiles += targetDir
|
||||||
processDirectorySingleEvaluator(sourceDir, destDir, evaluator)
|
|
||||||
processedFiles += destDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetRoot.listFiles().forEach { targetFile ->
|
for (targetFile in targetRoot.listFiles()) {
|
||||||
if (!processedFiles.remove(processedFiles.find { FileUtil.filesEqual(it, targetFile) })) {
|
if (!processedFiles.remove(processedFiles.find { FileUtil.filesEqual(it, targetFile) })) {
|
||||||
|
println("Removing skipped $targetFile")
|
||||||
targetFile.deleteRecursively()
|
targetFile.deleteRecursively()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.preprocessor
|
package org.jetbrains.kotlin.preprocessor
|
||||||
|
/*
|
||||||
import org.apache.tools.ant.Task
|
import org.apache.tools.ant.Task
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ public class PreprocessorTask: Task() {
|
|||||||
public var version: Int? = null
|
public var version: Int? = null
|
||||||
public var output: File? = null
|
public var output: File? = null
|
||||||
}
|
}
|
||||||
public class JsProfileConfig{
|
public class JsProfileConfig {
|
||||||
public var output: File? = null
|
public var output: File? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,4 +57,5 @@ public class PreprocessorTask: Task() {
|
|||||||
if (src == null) throw IllegalArgumentException("src")
|
if (src == null) throw IllegalArgumentException("src")
|
||||||
if (profiles.isEmpty()) throw IllegalArgumentException("profiles")
|
if (profiles.isEmpty()) throw IllegalArgumentException("profiles")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -21,17 +21,27 @@ import java.util.concurrent.Executors
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
require(args.size() == 2, "Please specify path to sources and output path for all platforms")
|
if (args.size() != 3) {
|
||||||
|
println("Usage: <path to sources> <output path> <profile>")
|
||||||
|
System.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
val sourcePath = File(args[0])
|
val sourcePath = File(args[0])
|
||||||
val targetPath = File(args[1])
|
val targetPath = File(args[1])
|
||||||
|
val profileName = args[2]
|
||||||
|
|
||||||
val profiles = listOf(6, 7, 8).map { createJvmProfile(targetPath, version = it) } + createJsProfile(targetPath)
|
val profiles = listOf(6, 7, 8).map { version -> "JVM$version" to { JvmPlatformEvaluator(version) } } + ("JS" to { JsPlatformEvaluator() })
|
||||||
|
|
||||||
val pool = Executors.newCachedThreadPool()
|
val (name, evaluatorBuilder) = profiles.single { it.first.equals(profileName, ignoreCase = true) }
|
||||||
|
val profile = Profile(name, evaluatorBuilder(), targetPath)
|
||||||
|
|
||||||
profiles.forEach { profile -> pool.submit { Preprocessor().processSources(sourcePath, profile) } }
|
println("Preprocessing sources in $sourcePath to $targetPath with profile ${profile.name}")
|
||||||
|
Preprocessor().processSources(sourcePath, profile)
|
||||||
|
|
||||||
pool.shutdown()
|
// val pool = Executors.newCachedThreadPool()
|
||||||
pool.awaitTermination(1, TimeUnit.MINUTES)
|
//
|
||||||
|
// profiles.forEach { profile -> pool.submit { Preprocessor().processSources(sourcePath, profile) } }
|
||||||
|
//
|
||||||
|
// pool.shutdown()
|
||||||
|
// pool.awaitTermination(1, TimeUnit.MINUTES)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-14
@@ -20,25 +20,12 @@
|
|||||||
<include name="kotlin/annotation/Annotations.kt"/>
|
<include name="kotlin/annotation/Annotations.kt"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
|
||||||
<fileset dir="${basedir}/libraries/stdlib/src">
|
<fileset dir="${basedir}/${intermediate-sources}/stdlib/js">
|
||||||
<include name="**/*.kt" />
|
<include name="**/*.kt" />
|
||||||
|
|
||||||
<!-- JVM specific -->
|
<!-- JVM specific -->
|
||||||
<exclude name="**/*JVM.kt" />
|
<exclude name="**/*JVM.kt" />
|
||||||
<exclude name="kotlin/jvm/**" />
|
<exclude name="kotlin/jvm/**" />
|
||||||
<exclude name="kotlin/beans/**" />
|
|
||||||
<exclude name="kotlin/browser/**" />
|
|
||||||
<exclude name="kotlin/concurrent/**" />
|
|
||||||
<exclude name="kotlin/io/**" />
|
|
||||||
<exclude name="kotlin/math/**" />
|
|
||||||
<exclude name="kotlin/template/**" />
|
|
||||||
|
|
||||||
<!-- Temporary disabled -->
|
|
||||||
<!--TODO fix: (84, 27) Unresolved reference: copyOf (_SpecialJVM.kt)-->
|
|
||||||
<exclude name="kotlin/collections/ImmutableArrayList.kt" />
|
|
||||||
|
|
||||||
<!-- TODO fix: AllModules is subclass of ThreadLocal. -->
|
|
||||||
<exclude name="kotlin/modules/**" />
|
|
||||||
</fileset>
|
</fileset>
|
||||||
</union>
|
</union>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user