Remove optionalExpectation hacks
Add common sources to Generate IR Runtime
This commit is contained in:
@@ -56,18 +56,8 @@ val fullRuntimeSources by task<Sync> {
|
||||
// stdlib/js/src/generated is used exclusively for current `js-v1` backend.
|
||||
"libraries/stdlib/js/src/generated/**",
|
||||
|
||||
"libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt",
|
||||
"libraries/stdlib/src/kotlin/annotations/Multiplatform.kt",
|
||||
"libraries/stdlib/common/src/kotlin/NativeAnnotationsH.kt",
|
||||
|
||||
// Fails with: EXPERIMENTAL_IS_NOT_ENABLED
|
||||
"libraries/stdlib/common/src/kotlin/annotations/Annotations.kt",
|
||||
|
||||
// JS-specific optimized version of emptyArray() already defined
|
||||
"core/builtins/src/kotlin/ArrayIntrinsics.kt",
|
||||
|
||||
// Expect declarations get thrown away and libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Assertions.kt doesn't compile
|
||||
"libraries/stdlib/common/src/kotlin/NativeAnnotationsH.kt"
|
||||
"core/builtins/src/kotlin/ArrayIntrinsics.kt"
|
||||
)
|
||||
|
||||
sources.forEach { path ->
|
||||
@@ -152,14 +142,14 @@ val reducedRuntimeSources by task<Sync> {
|
||||
}
|
||||
|
||||
|
||||
fun JavaExec.buildKLib(sources: List<String>, dependencies: List<String>, outPath: String) {
|
||||
fun JavaExec.buildKLib(sources: List<String>, dependencies: List<String>, outPath: String, commonSources: List<String>) {
|
||||
inputs.files(sources)
|
||||
outputs.dir(file(outPath).parent)
|
||||
|
||||
classpath = sourceSets.test.get().runtimeClasspath
|
||||
main = "org.jetbrains.kotlin.ir.backend.js.GenerateIrRuntimeKt"
|
||||
workingDir = rootDir
|
||||
args = sources.toList() + listOf("-o", outPath) + dependencies.flatMap { listOf("-d", it) }
|
||||
args = sources.toList() + listOf("-o", outPath) + dependencies.flatMap { listOf("-d", it) } + commonSources.flatMap { listOf("-c", it) }
|
||||
|
||||
passClasspathInJar()
|
||||
}
|
||||
@@ -169,7 +159,9 @@ val generateFullRuntimeKLib by task<NoDebugJavaExec> {
|
||||
|
||||
buildKLib(sources = listOf(fullRuntimeSources.outputs.files.singleFile.path),
|
||||
dependencies = emptyList(),
|
||||
outPath = "$buildDir/fullRuntime/klib/JS_IR_RUNTIME.klm")
|
||||
outPath = "$buildDir/fullRuntime/klib/JS_IR_RUNTIME.klm",
|
||||
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/fullRuntime/src/libraries/stdlib/$it" }
|
||||
)
|
||||
}
|
||||
|
||||
val generateReducedRuntimeKLib by task<NoDebugJavaExec> {
|
||||
@@ -177,20 +169,23 @@ val generateReducedRuntimeKLib by task<NoDebugJavaExec> {
|
||||
|
||||
buildKLib(sources = listOf(reducedRuntimeSources.outputs.files.singleFile.path),
|
||||
dependencies = emptyList(),
|
||||
outPath = "$buildDir/reducedRuntime/klib/JS_IR_RUNTIME.klm")
|
||||
outPath = "$buildDir/reducedRuntime/klib/JS_IR_RUNTIME.klm",
|
||||
commonSources = listOf("common", "src", "unsigned").map { "$buildDir/reducedRuntime/src/libraries/stdlib/$it" }
|
||||
)
|
||||
}
|
||||
|
||||
val kotlinTestCommonSources = listOf(
|
||||
"$rootDir/libraries/kotlin.test/annotations-common/src/main",
|
||||
"$rootDir/libraries/kotlin.test/common/src/main"
|
||||
)
|
||||
val generateKotlinTestKLib by task<NoDebugJavaExec> {
|
||||
dependsOn(generateFullRuntimeKLib)
|
||||
|
||||
buildKLib(
|
||||
sources = listOf(
|
||||
"$rootDir/libraries/kotlin.test/annotations-common/src/main",
|
||||
"$rootDir/libraries/kotlin.test/common/src/main",
|
||||
"$rootDir/libraries/kotlin.test/js/src/main"
|
||||
),
|
||||
sources = listOf("$rootDir/libraries/kotlin.test/js/src/main") + kotlinTestCommonSources,
|
||||
dependencies = listOf("${generateFullRuntimeKLib.outputs.files.singleFile.path}/JS_IR_RUNTIME.klm"),
|
||||
outPath = "$buildDir/kotlin.test/klib/kotlin.test.klm"
|
||||
outPath = "$buildDir/kotlin.test/klib/kotlin.test.klm",
|
||||
commonSources = kotlinTestCommonSources
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.isCommonSource
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
import java.io.File
|
||||
|
||||
@@ -29,7 +30,11 @@ fun buildConfiguration(environment: KotlinCoreEnvironment, moduleName: String):
|
||||
LanguageFeature.MultiPlatformProjects to LanguageFeature.State.ENABLED
|
||||
),
|
||||
analysisFlags = mapOf(
|
||||
AnalysisFlags.useExperimental to listOf("kotlin.contracts.ExperimentalContracts", "kotlin.Experimental"),
|
||||
AnalysisFlags.useExperimental to listOf(
|
||||
"kotlin.contracts.ExperimentalContracts",
|
||||
"kotlin.Experimental",
|
||||
"kotlin.ExperimentalMultiplatform"
|
||||
),
|
||||
AnalysisFlags.allowResultReturnType to true
|
||||
)
|
||||
)
|
||||
@@ -49,10 +54,22 @@ fun createPsiFile(fileName: String): KtFile {
|
||||
}
|
||||
|
||||
|
||||
fun buildKLib(moduleName: String, sources: List<String>, outputPath: String, dependencies: List<KlibModuleRef>): KlibModuleRef {
|
||||
fun buildKLib(
|
||||
moduleName: String,
|
||||
sources: List<String>,
|
||||
outputPath: String,
|
||||
dependencies: List<KlibModuleRef>,
|
||||
commonSources: List<String>
|
||||
): KlibModuleRef {
|
||||
return generateKLib(
|
||||
project = environment.project,
|
||||
files = sources.map(::createPsiFile),
|
||||
files = sources.map { source ->
|
||||
val file = createPsiFile(source)
|
||||
if (source in commonSources) {
|
||||
file.isCommonSource = true
|
||||
}
|
||||
file
|
||||
},
|
||||
configuration = buildConfiguration(environment, moduleName),
|
||||
immediateDependencies = dependencies,
|
||||
allDependencies = dependencies,
|
||||
@@ -76,6 +93,7 @@ fun main(args: Array<String>) {
|
||||
val inputFiles = mutableListOf<String>()
|
||||
var outputPath: String? = null
|
||||
val dependencies = mutableListOf<String>()
|
||||
val commonSources = mutableListOf<String>()
|
||||
|
||||
var index = 0
|
||||
while (index < args.size) {
|
||||
@@ -84,6 +102,7 @@ fun main(args: Array<String>) {
|
||||
when (arg) {
|
||||
"-o" -> outputPath = args[index++]
|
||||
"-d" -> dependencies += args[index++]
|
||||
"-c" -> commonSources += args[index++]
|
||||
else -> inputFiles += arg
|
||||
}
|
||||
}
|
||||
@@ -101,5 +120,5 @@ fun main(args: Array<String>) {
|
||||
KlibModuleRef(file.name.dropLast(4), file.parent)
|
||||
}
|
||||
|
||||
buildKLib(name.dropLast(4), listOfKtFilesFrom(inputFiles), File(outputPath).parent, dependencyKLibs)
|
||||
buildKLib(name.dropLast(4), listOfKtFilesFrom(inputFiles), File(outputPath).parent, dependencyKLibs, listOfKtFilesFrom(commonSources))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalMultiplatform
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// WITH_RUNTIME
|
||||
// MODULE: library
|
||||
// FILE: expected.kt
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-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.
|
||||
*/
|
||||
|
||||
package kotlin.jvm
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
internal annotation class JvmOverloads
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmName(public val name: String)
|
||||
|
||||
@Target(AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmMultifileClass
|
||||
|
||||
@Target(AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmPackageName(val name: String)
|
||||
|
||||
@Target(AnnotationTarget.FIELD)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmField
|
||||
|
||||
|
||||
@Target(FIELD)
|
||||
@MustBeDocumented
|
||||
@OptionalExpectation
|
||||
public expect annotation class Volatile()
|
||||
|
||||
@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
|
||||
@MustBeDocumented
|
||||
@OptionalExpectation
|
||||
public expect annotation class Synchronized()
|
||||
@@ -1,7 +0,0 @@
|
||||
package kotlin
|
||||
|
||||
|
||||
annotation class OptionalExpectationDummy()
|
||||
|
||||
// in order to make the compiler ignore semantics of the real OptionalExpectation
|
||||
typealias OptionalExpectation = OptionalExpectationDummy
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.
|
||||
*/
|
||||
|
||||
package kotlin.native.concurrent
|
||||
|
||||
// Current serialization removes expect declarations, so some dummy annotations are needed
|
||||
// Expect declarations: libraries/stdlib/common/src/kotlin/NativeAnnotationsH.kt
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@OptionalExpectation
|
||||
public annotation class ThreadLocal()
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@OptionalExpectation
|
||||
public annotation class SharedImmutable()
|
||||
Reference in New Issue
Block a user