[JS] Migrate tests onto IR compiler with outputDir API instead of outputFile

^KT-61117 fixed
This commit is contained in:
Ilya Goncharov
2023-11-29 11:21:56 +00:00
committed by Space Team
parent e50f6e6bca
commit 08e3cb300a
38 changed files with 208 additions and 201 deletions
@@ -23,17 +23,17 @@ import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
import org.jetbrains.kotlin.incremental.js.IrTranslationResultValue
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
import org.jetbrains.kotlin.incremental.storage.*
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl
import org.jetbrains.kotlin.metadata.deserialization.getExtensionOrNull
import org.jetbrains.kotlin.metadata.js.JsProtoBuf
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.parentOrNull
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
import org.jetbrains.kotlin.serialization.deserialization.getClassId
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
import java.io.DataInput
import java.io.DataOutput
@@ -371,7 +371,7 @@ private class ProtoDataProvider(private val serializerProtocol: SerializerExtens
// TODO: remove this method once AbstractJsProtoComparisonTest is fixed
fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData> {
val classes = hashMapOf<ClassId, ProtoData>()
val proto = ProtoBuf.PackageFragment.parseFrom(metadata, JsSerializerProtocol.extensionRegistry)
val proto = ProtoBuf.PackageFragment.parseFrom(metadata, KlibMetadataSerializerProtocol.extensionRegistry)
val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
proto.class_List.forEach {
@@ -380,7 +380,7 @@ fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData>
}
proto.`package`.apply {
val packageFqName = getExtensionOrNull(JsProtoBuf.packageFqName)?.let(nameResolver::getPackageFqName)?.let(::FqName) ?: FqName.ROOT
val packageFqName = getExtensionOrNull(KlibMetadataProtoBuf.packageFqName)?.let(nameResolver::getPackageFqName)?.let(::FqName) ?: FqName.ROOT
val packagePartClassId = ClassId(packageFqName, Name.identifier(sourceFile.nameWithoutExtension.capitalizeAsciiOnly() + "Kt"))
classes[packagePartClassId] = PackagePartProtoData(this, nameResolver, packageFqName)
}
@@ -21,8 +21,10 @@ import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufClassKind
import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufPackageKind
import org.jetbrains.kotlin.incremental.storage.ProtoMapValue
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.ProtoBuf.Type
import org.jetbrains.kotlin.metadata.deserialization.Flags
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
import org.jetbrains.kotlin.metadata.deserialization.TypeTable
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.protobuf.MessageLite
@@ -260,10 +262,40 @@ class DifferenceCalculatorForClass(
isClassAffected = true
areSubclassesAffected = true
val oldSupertypes = oldProto.supertypeList.map { oldNameResolver.getClassId(it.className).asSingleFqName() }
val newSupertypes = newProto.supertypeList.map { newNameResolver.getClassId(it.className).asSingleFqName() }
val oldTypeTable = oldProto.typeTableOrNull?.let { TypeTable(it) }
val newTypeTable = newProto.typeTableOrNull?.let { TypeTable(it) }
fun getSupertypes(supertypeList: List<Type>, nameResolver: NameResolver): List<FqName> {
return supertypeList.map { nameResolver.getClassId(it.className).asSingleFqName() }
}
fun getSupertypesById(supertypeIdList: List<Int>, typeTable: TypeTable?, nameResolver: NameResolver): List<FqName> {
return supertypeIdList.mapNotNull { id ->
typeTable?.get(id)?.className?.let {
nameResolver.getClassId(it).asSingleFqName()
}
}
}
val oldSupertypes = getSupertypes(oldProto.supertypeList, oldNameResolver)
val newSupertypes = getSupertypes(newProto.supertypeList, newNameResolver)
val oldSupertypesById = getSupertypesById(
oldProto.supertypeIdList,
oldTypeTable,
oldNameResolver
)
val newSupertypesById = getSupertypesById(
newProto.supertypeIdList,
newTypeTable,
newNameResolver
)
val changed = (oldSupertypes union newSupertypes) subtract (oldSupertypes intersect newSupertypes)
changedSupertypes.addAll(changed)
val changedById = (oldSupertypesById union newSupertypesById) subtract (oldSupertypesById intersect newSupertypesById)
val elements: Set<FqName> = changed + changedById
changedSupertypes.addAll(elements)
}
ProtoBufClassKind.JVM_EXT_CLASS_MODULE_NAME,
ProtoBufClassKind.JS_EXT_CLASS_CONTAINING_FILE_ID -> {
@@ -2,15 +2,17 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder
import org.jetbrains.kotlin.incremental.utils.TestCompilationResult
import org.jetbrains.kotlin.incremental.utils.TestICReporter
import org.jetbrains.kotlin.incremental.utils.TestMessageCollector
import java.io.File
abstract class AbstractIncrementalK1JsKlibCompilerRunnerTest : AbstractIncrementalK1JsLegacyCompilerRunnerTest() {
abstract class AbstractIncrementalK1JsKlibCompilerRunnerTest : AbstractIncrementalCompilerRunnerTestBase<K2JSCompilerArguments>() {
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments =
K2JSCompilerArguments().apply {
libraries = "build/js-ir-runtime/full-runtime.klib"
outputDir = destinationDir.path
moduleName = testDir.name
outputFile = null
sourceMap = false
irProduceKlibDir = false
irProduceKlibFile = true
@@ -19,7 +21,22 @@ abstract class AbstractIncrementalK1JsKlibCompilerRunnerTest : AbstractIncrement
}
override val buildLogFinder: BuildLogFinder
get() = super.buildLogFinder.copy(isKlibEnabled = true)
get() = super.buildLogFinder.copy(
isKlibEnabled = true,
isJsEnabled = true,
isScopeExpansionEnabled = scopeExpansionMode != CompileScopeExpansionMode.NEVER,
)
override fun make(cacheDir: File, outDir: File, sourceRoots: Iterable<File>, args: K2JSCompilerArguments): TestCompilationResult {
val reporter = TestICReporter()
val messageCollector = TestMessageCollector()
makeJsIncrementally(cacheDir, sourceRoots, args, buildHistoryFile(cacheDir), messageCollector, reporter, scopeExpansionMode)
return TestCompilationResult(reporter, messageCollector)
}
protected open val scopeExpansionMode = CompileScopeExpansionMode.NEVER
override fun failFile(testDir: File): File = testDir.resolve("fail_js_legacy.txt")
}
abstract class AbstractIncrementalK1JsKlibCompilerWithScopeExpansionRunnerTest : AbstractIncrementalK1JsKlibCompilerRunnerTest() {
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import java.io.File
abstract class AbstractIncrementalK1JsLegacyCompilerRunnerWithFriendModulesDisabledTest : AbstractIncrementalK1JsLegacyCompilerRunnerTest() {
abstract class AbstractIncrementalK1JsKlibCompilerRunnerWithFriendModulesDisabledTest : AbstractIncrementalK1JsKlibCompilerRunnerTest() {
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments =
super.createCompilerArguments(destinationDir, testDir).apply {
friendModulesDisabled = true
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import java.io.File
abstract class AbstractIncrementalK1JsLegacyMultiplatformJsCompilerRunnerTest : AbstractIncrementalK1JsLegacyCompilerRunnerTest() {
abstract class AbstractIncrementalK1JsKlibMultiplatformJsCompilerRunnerTest : AbstractIncrementalK1JsKlibCompilerRunnerTest() {
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments {
return super.createCompilerArguments(destinationDir, testDir).apply {
multiPlatform = true
@@ -1,52 +0,0 @@
/*
* 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.
*/
package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder
import org.jetbrains.kotlin.incremental.utils.TestCompilationResult
import org.jetbrains.kotlin.incremental.utils.TestICReporter
import org.jetbrains.kotlin.incremental.utils.TestMessageCollector
import java.io.File
abstract class AbstractIncrementalK1JsLegacyCompilerRunnerTest : AbstractIncrementalCompilerRunnerTestBase<K2JSCompilerArguments>() {
override fun make(cacheDir: File, outDir: File, sourceRoots: Iterable<File>, args: K2JSCompilerArguments): TestCompilationResult {
val reporter = TestICReporter()
val messageCollector = TestMessageCollector()
makeJsIncrementally(cacheDir, sourceRoots, args, buildHistoryFile(cacheDir), messageCollector, reporter, scopeExpansionMode)
return TestCompilationResult(reporter, messageCollector)
}
override val buildLogFinder: BuildLogFinder
get() = super.buildLogFinder.copy(
isJsEnabled = true,
isScopeExpansionEnabled = scopeExpansionMode != CompileScopeExpansionMode.NEVER
)
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments =
K2JSCompilerArguments().apply {
outputFile = File(destinationDir, "${testDir.name}.js").path
sourceMap = true
metaInfo = true
forceDeprecatedLegacyCompilerUsage = true
languageVersion = "1.9"
}
protected open val scopeExpansionMode = CompileScopeExpansionMode.NEVER
override fun failFile(testDir: File): File = testDir.resolve("fail_js_legacy.txt")
}
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
@TestMetadata("jps/jps-plugin/testData/incremental/js/friendsModuleDisabled")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IncrementalK1JsLegacyCompilerRunnerWithFriendModulesDisabledTestGenerated extends AbstractIncrementalK1JsLegacyCompilerRunnerWithFriendModulesDisabledTest {
public class IncrementalK1JsKlibCompilerRunnerWithFriendModulesDisabledTestGenerated extends AbstractIncrementalK1JsKlibCompilerRunnerWithFriendModulesDisabledTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@@ -20,7 +20,7 @@ import java.util.regex.Pattern;
@TestMetadata("jps/jps-plugin/testData/incremental/mpp/allPlatforms")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IncrementalK1JsLegacyMultiplatformJsCompilerRunnerTestGenerated extends AbstractIncrementalK1JsLegacyMultiplatformJsCompilerRunnerTest {
public class IncrementalK1JsKlibMultiplatformJsCompilerRunnerTestGenerated extends AbstractIncrementalK1JsKlibMultiplatformJsCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@@ -42,7 +42,7 @@ public class IncrementalK1JsLegacyMultiplatformJsCompilerRunnerTestGenerated ext
@TestMetadata("jps/jps-plugin/testData/incremental/mpp/allPlatforms/touchActual")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TouchActual extends AbstractIncrementalK1JsLegacyMultiplatformJsCompilerRunnerTest {
public static class TouchActual extends AbstractIncrementalK1JsKlibMultiplatformJsCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@@ -55,7 +55,7 @@ public class IncrementalK1JsLegacyMultiplatformJsCompilerRunnerTestGenerated ext
@TestMetadata("jps/jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TouchExpect extends AbstractIncrementalK1JsLegacyMultiplatformJsCompilerRunnerTest {
public static class TouchExpect extends AbstractIncrementalK1JsKlibMultiplatformJsCompilerRunnerTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
+8 -4
View File
@@ -1,5 +1,9 @@
$TESTDATA_DIR$/../kotlinPackage.kt
-no-stdlib
-Xforce-deprecated-legacy-compiler-usage
-output
$TEMP_DIR$/out.js
-Xir-produce-klib-dir
-Xir-only
-libraries
$STDLIB_JS$
-ir-output-dir
$TEMP_DIR$
-ir-output-name
out
@@ -5,10 +5,6 @@
<target name="build">
<mkdir dir="${temp.library.path}"/>
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="true">
<compilerarg value="-Xforce-deprecated-legacy-compiler-usage"/>
</kotlin2js>
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
<libraries>
<pathelement path="${temp.library.path}"/>
@@ -146,7 +146,7 @@ fun main(args: Array<String>) {
model("incremental/js", extension = null, excludeParentDirs = true)
}
testClass<AbstractIncrementalK1JsLegacyCompilerRunnerWithFriendModulesDisabledTest> {
testClass<AbstractIncrementalK1JsKlibCompilerRunnerWithFriendModulesDisabledTest> {
model("incremental/js/friendsModuleDisabled", extension = null, recursive = false)
}
@@ -154,7 +154,7 @@ fun main(args: Array<String>) {
model("incremental/mpp/allPlatforms", extension = null, excludeParentDirs = true)
model("incremental/mpp/jvmOnlyK1", extension = null, excludeParentDirs = true)
}
testClass<AbstractIncrementalK1JsLegacyMultiplatformJsCompilerRunnerTest> {
testClass<AbstractIncrementalK1JsKlibMultiplatformJsCompilerRunnerTest> {
model("incremental/mpp/allPlatforms", extension = null, excludeParentDirs = true)
}
//TODO: write a proper k2 multiplatform test runner KT-63183
@@ -181,10 +181,12 @@ private fun readV2AndLaterConfig(
}
productionOutputPath = element.getChild("productionOutputPath")?.let {
(it.content.firstOrNull() as? Text)?.textTrim?.let(FileUtilRt::toSystemDependentName)
} ?: (compilerArguments as? K2JSCompilerArguments)?.outputFile
} ?: (compilerArguments as? K2JSCompilerArguments)?.outputDir
?: (compilerArguments as? K2JSCompilerArguments)?.outputFile
testOutputPath = element.getChild("testOutputPath")?.let {
(it.content.firstOrNull() as? Text)?.textTrim?.let(FileUtilRt::toSystemDependentName)
} ?: (compilerArguments as? K2JSCompilerArguments)?.outputFile
} ?: (compilerArguments as? K2JSCompilerArguments)?.outputDir
?: (compilerArguments as? K2JSCompilerArguments)?.outputFile
}
}
@@ -239,7 +241,7 @@ fun CommonCompilerArguments.convertPathsToSystemIndependent() {
}
is K2JSCompilerArguments -> {
outputFile = outputFile?.let(FileUtilRt::toSystemIndependentName)
outputDir = (outputDir ?: outputFile)?.let(FileUtilRt::toSystemIndependentName)
libraries = libraries?.let(FileUtilRt::toSystemIndependentName)
}
@@ -354,14 +356,16 @@ private fun KotlinFacetSettings.writeConfig(element: Element) {
if (pureKotlinSourceFolders.isNotEmpty()) {
element.setAttribute("pureKotlinSourceFolders", pureKotlinSourceFolders.joinToString(";"))
}
productionOutputPath?.let {
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
element.addContent(Element("productionOutputPath").apply { addContent(FileUtilRt.toSystemIndependentName(it)) })
(compilerArguments as? K2JSCompilerArguments)?.let { compilerArguments ->
productionOutputPath?.let {
if (it != compilerArguments.outputDir && it != compilerArguments.outputFile) {
element.addContent(Element("productionOutputPath").apply { addContent(FileUtilRt.toSystemIndependentName(it)) })
}
}
}
testOutputPath?.let {
if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {
element.addContent(Element("testOutputPath").apply { addContent(FileUtilRt.toSystemIndependentName(it)) })
testOutputPath?.let {
if (it != compilerArguments.outputDir && it != compilerArguments.outputFile) {
element.addContent(Element("testOutputPath").apply { addContent(FileUtilRt.toSystemIndependentName(it)) })
}
}
}
compilerSettings?.copyOf()?.let {
@@ -237,7 +237,8 @@ class CompilerArgumentsContentProspectorTest {
K2JSCompilerArguments::wasm
)
private val k2JSCompilerArgumentsStringProperties = commonCompilerArgumentsStringProperties + listOf(
K2JSCompilerArguments::outputFile,
K2JSCompilerArguments::outputDir,
K2JSCompilerArguments::moduleName,
K2JSCompilerArguments::libraries,
K2JSCompilerArguments::sourceMapPrefix,
K2JSCompilerArguments::sourceMapBaseDirs,
@@ -99,9 +99,6 @@ abstract class AbstractJvmLookupTrackerTest : AbstractLookupTrackerTest() {
}
abstract class AbstractJsKlibLookupTrackerTest : AbstractJsLookupTrackerTest() {
override val jsStdlibFile: File
get() = File(System.getProperty("jps.testData.js-ir-runtime") ?: "build/js-ir-runtime/full-runtime.klib")
override fun configureAdditionalArgs(args: K2JSCompilerArguments) {
args.irProduceKlibDir = true
args.irOnly = true
@@ -157,7 +154,6 @@ abstract class AbstractJsLookupTrackerTest : AbstractLookupTrackerTest() {
get() = PathUtil.kotlinPathsForDistDirectoryForTests.jsStdLibKlibPath
protected open fun configureAdditionalArgs(args: K2JSCompilerArguments) {
args.outputFile = File(outDir, "out.js").canonicalPath
}
override fun runCompiler(filesToCompile: Iterable<File>, env: JpsCompilerEnvironment): Any? {
@@ -166,7 +162,6 @@ abstract class AbstractJsLookupTrackerTest : AbstractLookupTrackerTest() {
libraries = libPaths.joinToString(File.pathSeparator)
reportOutputFiles = true
freeArgs = filesToCompile.map { it.canonicalPath }
forceDeprecatedLegacyCompilerUsage = true
useFirLT = false
}
configureAdditionalArgs(args)
@@ -90,9 +90,7 @@ abstract class KotlinJpsBuildTestBase : AbstractKotlinJpsBuildTestCase() {
protected fun setupKotlinJSFacet() {
myProject.modules.forEach {
val facet = KotlinFacetSettings()
facet.compilerArguments = K2JSCompilerArguments().apply {
forceDeprecatedLegacyCompilerUsage = true
}
facet.compilerArguments = K2JSCompilerArguments()
facet.targetPlatform = JsPlatforms.defaultJsPlatform
it.container.setChild(
@@ -264,7 +264,6 @@ class ModulesTxtBuilder {
"js" -> settings.compilerArguments =
K2JSCompilerArguments().also {
settings.targetPlatform = JsPlatforms.defaultJsPlatform
it.forceDeprecatedLegacyCompilerUsage = true
}
"native" -> settings.compilerArguments =
K2NativeCompilerArguments().also { settings.targetPlatform = NativePlatforms.unspecifiedNativePlatform }
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.jps.incremental
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
@@ -27,10 +26,15 @@ import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
import org.jetbrains.kotlin.incremental.utils.TestMessageCollector
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.test.kotlinPathsForDistDirectoryForTests
import org.jetbrains.kotlin.utils.PathUtil
import org.junit.Assert
import java.io.File
abstract class AbstractJsProtoComparisonTest : AbstractProtoComparisonTest<ProtoData>() {
protected open val jsStdlibFile: File
get() = PathUtil.kotlinPathsForDistDirectoryForTests.jsStdLibKlibPath
override fun expectedOutputFile(testDir: File): File =
File(testDir, "result-js.out")
.takeIf { it.exists() }
@@ -47,11 +51,13 @@ abstract class AbstractJsProtoComparisonTest : AbstractProtoComparisonTest<Proto
val messageCollector = TestMessageCollector()
val outputItemsCollector = OutputItemsCollectorImpl()
val args = K2JSCompilerArguments().apply {
outputFile = File(outputDir, "out.js").canonicalPath
metaInfo = true
this.outputDir = outputDir.normalize().absolutePath
moduleName = "out"
libraries = jsStdlibFile.absolutePath
irProduceKlibDir = true
irOnly = true
main = K2JsArgumentConstants.NO_CALL
freeArgs = ktFiles
forceDeprecatedLegacyCompilerUsage = true
languageVersion = "1.9"
}
@@ -343,11 +343,12 @@ class JpsKotlinCompilerRunner {
settings: K2JSCompilerArguments,
) {
with(settings) {
noStdlib = true
freeArgs = allSourceFiles.map { it.path }.toMutableList()
irProduceKlibDir = true
irOnly = true
commonSources = _commonSources.map { it.path }.toTypedArray()
outputFile = _outputFile.path
metaInfo = true
outputDir = _outputFile.parent
moduleName = _outputFile.nameWithoutExtension
libraries = _libraries.joinToString(File.pathSeparator)
friendModules = _friendModules.joinToString(File.pathSeparator)
}
@@ -22,10 +22,9 @@ import org.jetbrains.jps.incremental.ModuleBuildTarget
import org.jetbrains.jps.incremental.storage.BuildDataManager
import org.jetbrains.jps.incremental.storage.StorageOwner
import org.jetbrains.kotlin.incremental.*
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
import org.jetbrains.kotlin.jps.build.KotlinBuilder
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
import org.jetbrains.kotlin.library.metadata.KlibMetadataSerializerProtocol
import java.io.File
interface JpsIncrementalCache : IncrementalCacheCommon, StorageOwner {
@@ -52,7 +51,7 @@ class JpsIncrementalJsCache(
target: ModuleBuildTarget,
paths: BuildDataPaths,
icContext: IncrementalCompilationContext
) : IncrementalJsCache(paths.getTargetDataRoot(target), icContext, JsSerializerProtocol), JpsIncrementalCache {
) : IncrementalJsCache(paths.getTargetDataRoot(target), icContext, KlibMetadataSerializerProtocol), JpsIncrementalCache {
override fun addJpsDependentCache(cache: JpsIncrementalCache) {
if (cache is JpsIncrementalJsCache) {
addDependentCache(cache)
@@ -1,10 +1,10 @@
PROTO DIFFERENCE in test/AnnotationAdded: JS_EXT_CLASS_ANNOTATION_LIST
PROTO DIFFERENCE in test/AnnotationAdded: KLIB_EXT_CLASS_ANNOTATION_LIST
CHANGES in test/AnnotationAdded: CLASS_SIGNATURE
PROTO DIFFERENCE in test/AnnotationListBecomeEmpty: FLAGS, JS_EXT_CLASS_ANNOTATION_LIST
PROTO DIFFERENCE in test/AnnotationListBecomeEmpty: FLAGS, KLIB_EXT_CLASS_ANNOTATION_LIST
CHANGES in test/AnnotationListBecomeEmpty: CLASS_SIGNATURE
PROTO DIFFERENCE in test/AnnotationListBecomeNotEmpty: FLAGS, JS_EXT_CLASS_ANNOTATION_LIST
PROTO DIFFERENCE in test/AnnotationListBecomeNotEmpty: FLAGS, KLIB_EXT_CLASS_ANNOTATION_LIST
CHANGES in test/AnnotationListBecomeNotEmpty: CLASS_SIGNATURE
PROTO DIFFERENCE in test/AnnotationRemoved: JS_EXT_CLASS_ANNOTATION_LIST
PROTO DIFFERENCE in test/AnnotationRemoved: KLIB_EXT_CLASS_ANNOTATION_LIST
CHANGES in test/AnnotationRemoved: CLASS_SIGNATURE
PROTO DIFFERENCE in test/AnnotationReplaced: JS_EXT_CLASS_ANNOTATION_LIST
PROTO DIFFERENCE in test/AnnotationReplaced: KLIB_EXT_CLASS_ANNOTATION_LIST
CHANGES in test/AnnotationReplaced: CLASS_SIGNATURE
@@ -2,10 +2,10 @@ PROTO DIFFERENCE in test/AbstractFlagAdded: FLAGS
CHANGES in test/AbstractFlagAdded: CLASS_SIGNATURE
PROTO DIFFERENCE in test/AbstractFlagRemoved: FLAGS
CHANGES in test/AbstractFlagRemoved: CLASS_SIGNATURE
PROTO DIFFERENCE in test/AnnotationFlagAdded: FLAGS, SUPERTYPE_LIST
PROTO DIFFERENCE in test/AnnotationFlagAdded: FLAGS, SUPERTYPE_ID_LIST
CHANGES in test/AnnotationFlagAdded: CLASS_SIGNATURE, PARENTS
[kotlin.Annotation, kotlin.Any]
PROTO DIFFERENCE in test/AnnotationFlagRemoved: FLAGS, SUPERTYPE_LIST
PROTO DIFFERENCE in test/AnnotationFlagRemoved: FLAGS, SUPERTYPE_ID_LIST
CHANGES in test/AnnotationFlagRemoved: CLASS_SIGNATURE, PARENTS
[kotlin.Annotation, kotlin.Any]
PROTO DIFFERENCE in test/DataFlagAdded: FLAGS, FUNCTION_LIST
@@ -14,10 +14,10 @@ CHANGES in test/DataFlagAdded: CLASS_SIGNATURE, MEMBERS
PROTO DIFFERENCE in test/DataFlagRemoved: FLAGS, FUNCTION_LIST
CHANGES in test/DataFlagRemoved: CLASS_SIGNATURE, MEMBERS
[component1, copy, equals, hashCode, toString]
PROTO DIFFERENCE in test/EnumFlagAdded: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST
PROTO DIFFERENCE in test/EnumFlagAdded: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_ID_LIST
CHANGES in test/EnumFlagAdded: CLASS_SIGNATURE, PARENTS
[kotlin.Any, kotlin.Enum]
PROTO DIFFERENCE in test/EnumFlagRemoved: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_LIST
PROTO DIFFERENCE in test/EnumFlagRemoved: CONSTRUCTOR_LIST, FLAGS, SUPERTYPE_ID_LIST
CHANGES in test/EnumFlagRemoved: CLASS_SIGNATURE, PARENTS
[kotlin.Any, kotlin.Enum]
PROTO DIFFERENCE in test/InnerClassHolder.InnerFlagAdded: FLAGS
@@ -0,0 +1,3 @@
PROTO DIFFERENCE in test/ClassWithSuperTypeListChanged: SUPERTYPE_ID_LIST
CHANGES in test/ClassWithSuperTypeListChanged: CLASS_SIGNATURE, PARENTS
[kotlin.Any, kotlin.Throwable]
@@ -0,0 +1,3 @@
PROTO DIFFERENCE in test/Base.Nested1.Nested2: SUPERTYPE_ID_LIST
CHANGES in test/Base.Nested1.Nested2: CLASS_SIGNATURE, PARENTS
[kotlin.Any, test.Base]
@@ -0,0 +1,8 @@
ADDED test/Impl11
PROTO DIFFERENCE in test/Base1: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base1: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base2: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Impl22: SUPERTYPE_ID_LIST
CHANGES in test/Impl22: CLASS_SIGNATURE, PARENTS
[kotlin.Any, test.Base2]
@@ -0,0 +1,8 @@
REMOVED test/Impl11
PROTO DIFFERENCE in test/Base1: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base1: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base2: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Impl22: SUPERTYPE_ID_LIST
CHANGES in test/Impl22: CLASS_SIGNATURE, PARENTS
[kotlin.Any, test.Base2]
@@ -0,0 +1,9 @@
ADDED test/Base1.Nested2
PROTO DIFFERENCE in test/Base1: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base1: CLASS_SIGNATURE, MEMBERS
[Nested2]
PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base2: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Base2.Nested2: SUPERTYPE_ID_LIST
CHANGES in test/Base2.Nested2: CLASS_SIGNATURE, PARENTS
[kotlin.Any, test.Base2]
@@ -0,0 +1,13 @@
ADDED test/Base1.Nested1.Nested2.Nested3
ADDED test/Base2.Nested1.Nested3
PROTO DIFFERENCE in test/Base1.Nested1.Nested2: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base1.Nested1.Nested2: CLASS_SIGNATURE, MEMBERS
[Nested3]
PROTO DIFFERENCE in test/Base2.Nested1: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base2.Nested1: CLASS_SIGNATURE, MEMBERS
[Nested3]
PROTO DIFFERENCE in test/Base3.Nested1: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base3.Nested1: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Base3.Nested1.Nested2: SUPERTYPE_ID_LIST
CHANGES in test/Base3.Nested1.Nested2: CLASS_SIGNATURE, PARENTS
[kotlin.Any, test.Base3.Nested1]
@@ -0,0 +1,9 @@
REMOVED test/Base1.Nested2
PROTO DIFFERENCE in test/Base1: NESTED_CLASS_NAME_LIST, SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base1: CLASS_SIGNATURE, MEMBERS
[Nested2]
PROTO DIFFERENCE in test/Base2: SEALED_SUBCLASS_FQ_NAME_LIST
CHANGES in test/Base2: CLASS_SIGNATURE
PROTO DIFFERENCE in test/Base2.Nested2: SUPERTYPE_ID_LIST
CHANGES in test/Base2.Nested2: CLASS_SIGNATURE, PARENTS
[kotlin.Any, test.Base2]
@@ -1,7 +1,4 @@
c [sourceSetHolder]
pJvm [compilationAndSourceSetHolder, jvm]
pJvm -> c [include]
pJs [compilationAndSourceSetHolder, js]
pJs -> c [include]
pJvm -> c [include]
@@ -1,34 +1,6 @@
================ Step #1 make compilation fail =================
Building c
Building pJs
Cleaning output files:
out/production/pJs/pJs.js
out/production/pJs/pJs.meta.js
out/production/pJs/pJs/root-package.kjsm
End of files
Complementary files. Marked as dirty by Kotlin:
pJs/src/fJs.kt
Compiling files:
c/src/f.kt
pJs/src/fJs.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
[pJs] Expecting a top level declaration
[pJs] Expecting a top level declaration
================ Step #2 fix error =================
Building c
Building pJs
Compiling files:
c/src/f.kt
pJs/src/fJs.kt
End of files
Exit code: OK
------------------------------------------
Building pJvm
Cleaning output files:
out/production/pJvm/META-INF/pJvm.kotlin_module
@@ -42,5 +14,17 @@ Compiling files:
c/src/f.kt
pJvm/src/fJvm.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
================ Step #2 fix error =================
Building c
Building pJvm
Compiling files:
c/src/f.kt
pJvm/src/fJvm.kt
End of files
Exit code: OK
------------------------------------------
@@ -1,7 +1,4 @@
c [sourceSetHolder]
pJvm [compilationAndSourceSetHolder, jvm]
pJvm -> c [include]
pJs [compilationAndSourceSetHolder, js]
pJs -> c [include]
pJvm -> c [include]
@@ -1,41 +1,6 @@
================ Step #1 make compilation fail =================
Building c
Building pJs
Cleaning output files:
out/production/pJs/pJs.js
out/production/pJs/pJs.meta.js
out/production/pJs/pJs/root-package.kjsm
End of files
Complementary files. Marked as dirty by Kotlin:
c/src/g.kt
pJs/src/fg.kt
Compiling files:
c/src/f.kt
c/src/g.kt
pJs/src/fg.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
[pJs] Expecting a top level declaration
[pJs] Expecting a top level declaration
================ Step #2 fix error =================
Building c
Building pJs
Complementary files. Marked as dirty by Kotlin:
c/src/g.kt
Compiling files:
c/src/f.kt
c/src/g.kt
pJs/src/fg.kt
End of files
Exit code: OK
------------------------------------------
ChunkBuildStarted. Marked as dirty by Kotlin:
c/src/g.kt
Building pJvm
Cleaning output files:
out/production/pJvm/META-INF/pJvm.kotlin_module
@@ -51,5 +16,20 @@ Compiling files:
c/src/g.kt
pJvm/src/fg.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
================ Step #2 fix error =================
Building c
Building pJvm
Complementary files. Marked as dirty by Kotlin:
c/src/g.kt
Compiling files:
c/src/f.kt
c/src/g.kt
pJvm/src/fg.kt
End of files
Exit code: OK
------------------------------------------
@@ -21,7 +21,8 @@ dependencies {
}
tasks.named("compileKotlinJs", Kotlin2JsCompile) {
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
it.destinationDirectory = new File(buildDir, "kotlin2js/main")
it.kotlinOptions.moduleName = "module"
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
}
@@ -29,7 +29,8 @@ artifacts {
def outDir = "${buildDir}/kotlin2js/main/"
compileKotlin2Js.kotlinOptions.outputFile = outDir + "test-library.js"
compileKotlin2Js.destinationDirectory = new File(outDir)
compileKotlin2Js.kotlinOptions.moduleName = "test-library"
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"]
@@ -21,7 +21,8 @@ dependencies {
}
compileKotlin2Js.kotlinOptions.sourceMap = true
compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/app.js"
compileKotlin2Js.destinationDirectory = new File(projectDir, "web/js")
compileKotlin2Js.kotlinOptions.moduleName = "app"
compileKotlin2Js.kotlinOptions.suppressWarnings = true
compileKotlin2Js.kotlinOptions.verbose = true
@@ -100,9 +100,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
@Override
protected void configureSpecificCompilerArguments(@NotNull K2JSCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
arguments.setOutputFile(outputFile);
arguments.setNoStdlib(true);
arguments.setMetaInfo(metaInfo);
arguments.setOutputDir(new File(outputFile).getParent());
arguments.setModuleKind(moduleKind);
arguments.setMain(main);
arguments.setIrOnly(useIrBackend);
@@ -86,8 +86,7 @@ public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo {
super.configureSpecificCompilerArguments(arguments, sourceRoots);
arguments.setOutputFile(outputFile);
arguments.setMetaInfo(metaInfo);
arguments.setOutputDir(new File(outputFile).getParent());
}
@Override
@@ -45,8 +45,4 @@ publishing {
}
}
configureDefaultPublishing()
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
}
configureDefaultPublishing()