HMPP: Parameterize NativePlatform with KonanTarget
This commit is contained in:
@@ -8,6 +8,7 @@ dependencies {
|
|||||||
compile(project(":compiler:config"))
|
compile(project(":compiler:config"))
|
||||||
compile(project(":compiler:config.jvm"))
|
compile(project(":compiler:config.jvm"))
|
||||||
compile(project(":js:js.config"))
|
compile(project(":js:js.config"))
|
||||||
|
compile(project(":native:kotlin-native-utils"))
|
||||||
compileOnly(project(":kotlin-reflect-api"))
|
compileOnly(project(":kotlin-reflect-api"))
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.platform.js.JsPlatforms.defaultJsPlatform
|
|||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.allJvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.allJvmPlatforms
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.unspecifiedJvmPlatform
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.unspecifiedJvmPlatform
|
||||||
import org.jetbrains.kotlin.platform.konan.NativePlatforms.allNativePlatforms
|
import org.jetbrains.kotlin.platform.konan.NativePlatforms.allNativePlatforms
|
||||||
import org.jetbrains.kotlin.platform.konan.NativePlatforms.defaultNativePlatform
|
import org.jetbrains.kotlin.platform.konan.NativePlatforms.unspecifiedNativePlatform
|
||||||
|
|
||||||
@Suppress("DEPRECATION_ERROR")
|
@Suppress("DEPRECATION_ERROR")
|
||||||
object CommonPlatforms {
|
object CommonPlatforms {
|
||||||
@@ -23,7 +23,7 @@ object CommonPlatforms {
|
|||||||
setOf(
|
setOf(
|
||||||
unspecifiedJvmPlatform.single(),
|
unspecifiedJvmPlatform.single(),
|
||||||
defaultJsPlatform.single(),
|
defaultJsPlatform.single(),
|
||||||
defaultNativePlatform.single()
|
unspecifiedNativePlatform.single()
|
||||||
)
|
)
|
||||||
), org.jetbrains.kotlin.analyzer.common.CommonPlatform {
|
), org.jetbrains.kotlin.analyzer.common.CommonPlatform {
|
||||||
override val platformName: String
|
override val platformName: String
|
||||||
|
|||||||
@@ -5,33 +5,62 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.platform.konan
|
package org.jetbrains.kotlin.platform.konan
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.platform.SimplePlatform
|
import org.jetbrains.kotlin.platform.SimplePlatform
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
|
import org.jetbrains.kotlin.platform.toTargetPlatform
|
||||||
|
|
||||||
|
sealed class NativePlatform : SimplePlatform("Native")
|
||||||
|
|
||||||
|
object NativePlatformUnspecifiedTarget : NativePlatform() {
|
||||||
|
override fun toString() = "$platformName (general)"
|
||||||
|
|
||||||
abstract class NativePlatform : SimplePlatform("Native") {
|
|
||||||
override val oldFashionedDescription: String
|
override val oldFashionedDescription: String
|
||||||
get() = "Native "
|
get() = "Native (general) "
|
||||||
|
}
|
||||||
|
|
||||||
|
data class NativePlatformWithTarget(val target: KonanTarget) : NativePlatform() {
|
||||||
|
override fun toString() = "$platformName ($target)"
|
||||||
|
|
||||||
|
override val oldFashionedDescription: String
|
||||||
|
get() = "Native ($target) "
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION_ERROR")
|
@Suppress("DEPRECATION_ERROR")
|
||||||
object NativePlatforms {
|
object NativePlatforms {
|
||||||
private object DefaultSimpleNativePlatform : NativePlatform()
|
private val predefinedNativeTargetToSimpleNativePlatform: Map<KonanTarget, NativePlatformWithTarget> =
|
||||||
|
KonanTarget.predefinedTargets.values.associateWith { NativePlatformWithTarget(it) }
|
||||||
|
|
||||||
|
private val predefinedNativeTargetToNativePlatform: Map<KonanTarget, TargetPlatform> =
|
||||||
|
predefinedNativeTargetToSimpleNativePlatform.mapValues { (_, simplePlatform) -> simplePlatform.toTargetPlatform() }
|
||||||
|
|
||||||
|
val unspecifiedNativePlatform: TargetPlatform
|
||||||
|
get() = CompatNativePlatform
|
||||||
|
|
||||||
|
val allNativePlatforms: List<TargetPlatform> = listOf(unspecifiedNativePlatform) + predefinedNativeTargetToNativePlatform.values
|
||||||
|
|
||||||
|
fun nativePlatformBySingleTarget(target: KonanTarget): TargetPlatform =
|
||||||
|
predefinedNativeTargetToNativePlatform[target] ?: unspecifiedNativePlatform
|
||||||
|
|
||||||
|
fun nativePlatformByTargets(targets: Collection<KonanTarget>): TargetPlatform {
|
||||||
|
val simplePlatforms = targets.mapNotNullTo(HashSet()) { predefinedNativeTargetToSimpleNativePlatform[it] }
|
||||||
|
return when (simplePlatforms.size) {
|
||||||
|
0 -> unspecifiedNativePlatform
|
||||||
|
1 -> nativePlatformBySingleTarget(simplePlatforms.first().target)
|
||||||
|
else -> TargetPlatform(simplePlatforms)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
message = "Should be accessed only by compatibility layer, other clients should use 'defaultNativePlatform'",
|
message = "Should be accessed only by compatibility layer, other clients should use 'unspecifiedNativePlatform'",
|
||||||
level = DeprecationLevel.ERROR
|
level = DeprecationLevel.ERROR
|
||||||
)
|
)
|
||||||
object CompatNativePlatform : TargetPlatform(setOf(DefaultSimpleNativePlatform)),
|
object CompatNativePlatform : TargetPlatform(setOf(NativePlatformUnspecifiedTarget)),
|
||||||
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
|
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
|
||||||
org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform {
|
org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform {
|
||||||
override val platformName: String
|
override val platformName: String
|
||||||
get() = "Native"
|
get() = "Native"
|
||||||
}
|
}
|
||||||
|
|
||||||
val defaultNativePlatform: TargetPlatform
|
|
||||||
get() = CompatNativePlatform
|
|
||||||
|
|
||||||
val allNativePlatforms: List<TargetPlatform> = listOf(defaultNativePlatform)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TargetPlatform?.isNative(): Boolean = this?.singleOrNull() is NativePlatform
|
fun TargetPlatform?.isNative(): Boolean = this?.isNotEmpty() == true && all { it is NativePlatform }
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
|||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
|
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
|
||||||
replaceWith = ReplaceWith("NativePlatforms.defaultNativePlatform", "org.jetbrains.kotlin.platform.konan.NativePlatforms"),
|
replaceWith = ReplaceWith("NativePlatforms.unspecifiedNativePlatform", "org.jetbrains.kotlin.platform.konan.NativePlatforms"),
|
||||||
level = DeprecationLevel.ERROR
|
level = DeprecationLevel.ERROR
|
||||||
)
|
)
|
||||||
interface KonanPlatform : TargetPlatform {
|
interface KonanPlatform : TargetPlatform {
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,7 @@ private fun createFakeTopDownAnalyzerForNative(
|
|||||||
): LazyTopDownAnalyzer = createContainer("FakeTopDownAnalyzerForNative", NativePlatformAnalyzerServices) {
|
): LazyTopDownAnalyzer = createContainer("FakeTopDownAnalyzerForNative", NativePlatformAnalyzerServices) {
|
||||||
configureModule(
|
configureModule(
|
||||||
moduleContext,
|
moduleContext,
|
||||||
NativePlatforms.defaultNativePlatform,
|
NativePlatforms.unspecifiedNativePlatform,
|
||||||
NativePlatformAnalyzerServices,
|
NativePlatformAnalyzerServices,
|
||||||
bindingTrace,
|
bindingTrace,
|
||||||
languageVersionSettings
|
languageVersionSettings
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
|||||||
nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform
|
nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform
|
||||||
nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely
|
nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely
|
||||||
nameSuffix == "JS" -> JsPlatforms.defaultJsPlatform
|
nameSuffix == "JS" -> JsPlatforms.defaultJsPlatform
|
||||||
nameSuffix == "NATIVE" -> NativePlatforms.defaultNativePlatform
|
nameSuffix == "NATIVE" -> NativePlatforms.unspecifiedNativePlatform
|
||||||
nameSuffix.isEmpty() -> null // TODO(dsavvinov): this leads to 'null'-platform in ModuleDescriptor
|
nameSuffix.isEmpty() -> null // TODO(dsavvinov): this leads to 'null'-platform in ModuleDescriptor
|
||||||
else -> throw IllegalStateException("Can't determine platform by name $nameSuffix")
|
else -> throw IllegalStateException("Can't determine platform by name $nameSuffix")
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -31,7 +31,8 @@ internal class KlibModuleDescriptorFactoryImpl(val createBuiltIns: (StorageManag
|
|||||||
KlibModuleOrigin.CAPABILITY to origin,
|
KlibModuleOrigin.CAPABILITY to origin,
|
||||||
ImplicitIntegerCoercion.MODULE_CAPABILITY to origin.isInteropLibrary()
|
ImplicitIntegerCoercion.MODULE_CAPABILITY to origin.isInteropLibrary()
|
||||||
),
|
),
|
||||||
platform = NativePlatforms.defaultNativePlatform
|
// TODO: detect native platform by ???
|
||||||
|
platform = NativePlatforms.unspecifiedNativePlatform
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createDescriptorAndNewBuiltIns(
|
override fun createDescriptorAndNewBuiltIns(
|
||||||
|
|||||||
+3
-3
@@ -104,7 +104,7 @@ class CompositeResolverForModuleFactory(
|
|||||||
yieldAll(getCommonProvidersIfAny(moduleInfo, moduleContext, moduleDescriptor, container)) // todo: module context
|
yieldAll(getCommonProvidersIfAny(moduleInfo, moduleContext, moduleDescriptor, container)) // todo: module context
|
||||||
yieldAll(getJsProvidersIfAny(moduleInfo, moduleContext, moduleDescriptor, container))
|
yieldAll(getJsProvidersIfAny(moduleInfo, moduleContext, moduleDescriptor, container))
|
||||||
yieldAll(getJvmProvidersIfAny(container))
|
yieldAll(getJvmProvidersIfAny(container))
|
||||||
yieldAll(getKonanProvidersIfAny(moduleInfo, container))
|
yieldAll(getNativeProvidersIfAny(moduleInfo, container))
|
||||||
}.toList()
|
}.toList()
|
||||||
|
|
||||||
return ResolverForModule(CompositePackageFragmentProvider(packageFragmentProviders), container)
|
return ResolverForModule(CompositePackageFragmentProvider(packageFragmentProviders), container)
|
||||||
@@ -133,11 +133,11 @@ class CompositeResolverForModuleFactory(
|
|||||||
private fun getJvmProvidersIfAny(container: StorageComponentContainer): List<PackageFragmentProvider> =
|
private fun getJvmProvidersIfAny(container: StorageComponentContainer): List<PackageFragmentProvider> =
|
||||||
if (targetPlatform.has<JvmPlatform>()) listOf(container.get<JavaDescriptorResolver>().packageFragmentProvider) else emptyList()
|
if (targetPlatform.has<JvmPlatform>()) listOf(container.get<JavaDescriptorResolver>().packageFragmentProvider) else emptyList()
|
||||||
|
|
||||||
private fun getKonanProvidersIfAny(moduleInfo: ModuleInfo, container: StorageComponentContainer): List<PackageFragmentProvider> {
|
private fun getNativeProvidersIfAny(moduleInfo: ModuleInfo, container: StorageComponentContainer): List<PackageFragmentProvider> {
|
||||||
if (!targetPlatform.has<NativePlatform>()) return emptyList()
|
if (!targetPlatform.has<NativePlatform>()) return emptyList()
|
||||||
|
|
||||||
return listOfNotNull(
|
return listOfNotNull(
|
||||||
NativePlatforms.defaultNativePlatform.idePlatformKind.resolution.createKlibPackageFragmentProvider(
|
NativePlatforms.unspecifiedNativePlatform.idePlatformKind.resolution.createKlibPackageFragmentProvider(
|
||||||
moduleInfo,
|
moduleInfo,
|
||||||
container.get<StorageManager>(),
|
container.get<StorageManager>(),
|
||||||
container.get<LanguageVersionSettings>(),
|
container.get<LanguageVersionSettings>(),
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ open class KotlinNativeGradleConfigurator : KotlinWithGradleConfigurator() {
|
|||||||
|
|
||||||
override val name: String get() = NAME
|
override val name: String get() = NAME
|
||||||
|
|
||||||
override val targetPlatform get() = NativePlatforms.defaultNativePlatform
|
override val targetPlatform get() = NativePlatforms.unspecifiedNativePlatform
|
||||||
|
|
||||||
@Suppress("DEPRECATION_ERROR")
|
@Suppress("DEPRECATION_ERROR")
|
||||||
override fun getTargetPlatform() = NativePlatforms.CompatNativePlatform
|
override fun getTargetPlatform() = NativePlatforms.CompatNativePlatform
|
||||||
|
|||||||
+6
-6
@@ -60,7 +60,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
|||||||
module("my-app")
|
module("my-app")
|
||||||
module("project.my-app.commonMain") {
|
module("project.my-app.commonMain") {
|
||||||
isHMPP(true)
|
isHMPP(true)
|
||||||
targetPlatform(JsPlatforms.defaultJsPlatform, JvmPlatforms.jvm16, NativePlatforms.defaultNativePlatform)
|
targetPlatform(JsPlatforms.defaultJsPlatform, JvmPlatforms.jvm16, NativePlatforms.unspecifiedNativePlatform)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.COMPILE)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.COMPILE)
|
||||||
sourceFolder("src/commonMain/kotlin", SourceKotlinRootType)
|
sourceFolder("src/commonMain/kotlin", SourceKotlinRootType)
|
||||||
sourceFolder("src/commonMain/resources", ResourceKotlinRootType)
|
sourceFolder("src/commonMain/resources", ResourceKotlinRootType)
|
||||||
@@ -68,7 +68,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
|||||||
|
|
||||||
module("project.my-app.commonTest") {
|
module("project.my-app.commonTest") {
|
||||||
isHMPP(true)
|
isHMPP(true)
|
||||||
targetPlatform(JsPlatforms.defaultJsPlatform, JvmPlatforms.jvm16, NativePlatforms.defaultNativePlatform)
|
targetPlatform(JsPlatforms.defaultJsPlatform, JvmPlatforms.jvm16, NativePlatforms.unspecifiedNativePlatform)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-annotations-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-annotations-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
@@ -165,7 +165,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
|||||||
|
|
||||||
module("project.my-app.linuxAndJsMain") {
|
module("project.my-app.linuxAndJsMain") {
|
||||||
isHMPP(true)
|
isHMPP(true)
|
||||||
targetPlatform(JsPlatforms.defaultJsPlatform, NativePlatforms.defaultNativePlatform)
|
targetPlatform(JsPlatforms.defaultJsPlatform, NativePlatforms.unspecifiedNativePlatform)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.COMPILE)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.COMPILE)
|
||||||
moduleDependency("project.my-app.commonMain", DependencyScope.COMPILE)
|
moduleDependency("project.my-app.commonMain", DependencyScope.COMPILE)
|
||||||
sourceFolder("src/linuxAndJsMain/kotlin", SourceKotlinRootType)
|
sourceFolder("src/linuxAndJsMain/kotlin", SourceKotlinRootType)
|
||||||
@@ -174,7 +174,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
|||||||
|
|
||||||
module("project.my-app.linuxAndJsTest") {
|
module("project.my-app.linuxAndJsTest") {
|
||||||
isHMPP(true)
|
isHMPP(true)
|
||||||
targetPlatform(JsPlatforms.defaultJsPlatform, NativePlatforms.defaultNativePlatform)
|
targetPlatform(JsPlatforms.defaultJsPlatform, NativePlatforms.unspecifiedNativePlatform)
|
||||||
sourceFolder("src/linuxAndJsTest/kotlin", TestSourceKotlinRootType)
|
sourceFolder("src/linuxAndJsTest/kotlin", TestSourceKotlinRootType)
|
||||||
sourceFolder("src/linuxAndJsTest/resources", TestResourceKotlinRootType)
|
sourceFolder("src/linuxAndJsTest/resources", TestResourceKotlinRootType)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
@@ -187,7 +187,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
|||||||
|
|
||||||
module("project.my-app.linuxX64Main") {
|
module("project.my-app.linuxX64Main") {
|
||||||
isHMPP(true)
|
isHMPP(true)
|
||||||
targetPlatform(NativePlatforms.defaultNativePlatform)
|
targetPlatform(NativePlatforms.unspecifiedNativePlatform)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.COMPILE)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.COMPILE)
|
||||||
libraryDependency("Kotlin/Native ${gradleKotlinPluginVersion} - builtin [linux_x64]", DependencyScope.PROVIDED)
|
libraryDependency("Kotlin/Native ${gradleKotlinPluginVersion} - builtin [linux_x64]", DependencyScope.PROVIDED)
|
||||||
libraryDependency("Kotlin/Native ${gradleKotlinPluginVersion} - iconv [linux_x64]", DependencyScope.PROVIDED)
|
libraryDependency("Kotlin/Native ${gradleKotlinPluginVersion} - iconv [linux_x64]", DependencyScope.PROVIDED)
|
||||||
@@ -203,7 +203,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
|
|||||||
|
|
||||||
module("project.my-app.linuxX64Test") {
|
module("project.my-app.linuxX64Test") {
|
||||||
isHMPP(true)
|
isHMPP(true)
|
||||||
targetPlatform(NativePlatforms.defaultNativePlatform)
|
targetPlatform(NativePlatforms.unspecifiedNativePlatform)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-annotations-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-annotations-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-test-common:${gradleKotlinPluginVersion}", DependencyScope.TEST)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ fun IdePlatform<*, *>.toNewPlatform(): NewPlatform = when (this) {
|
|||||||
is CommonIdePlatformKind.Platform -> CommonPlatforms.defaultCommonPlatform
|
is CommonIdePlatformKind.Platform -> CommonPlatforms.defaultCommonPlatform
|
||||||
is JvmIdePlatformKind.Platform -> JvmPlatforms.jvmPlatformByTargetVersion(this.version)
|
is JvmIdePlatformKind.Platform -> JvmPlatforms.jvmPlatformByTargetVersion(this.version)
|
||||||
is JsIdePlatformKind.Platform -> JsPlatforms.defaultJsPlatform
|
is JsIdePlatformKind.Platform -> JsPlatforms.defaultJsPlatform
|
||||||
is NativeIdePlatformKind.Platform -> NativePlatforms.defaultNativePlatform
|
is NativeIdePlatformKind.Platform -> NativePlatforms.unspecifiedNativePlatform
|
||||||
else -> error("Unknown platform $this")
|
else -> error("Unknown platform $this")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -14,13 +14,14 @@ import org.jetbrains.kotlin.platform.IdePlatformKind
|
|||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
||||||
import org.jetbrains.kotlin.platform.konan.NativePlatforms
|
import org.jetbrains.kotlin.platform.konan.NativePlatforms
|
||||||
|
import org.jetbrains.kotlin.platform.konan.isNative
|
||||||
|
|
||||||
object NativeIdePlatformKind : IdePlatformKind<NativeIdePlatformKind>() {
|
object NativeIdePlatformKind : IdePlatformKind<NativeIdePlatformKind>() {
|
||||||
override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform == NativePlatforms.defaultNativePlatform
|
override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isNative()
|
||||||
|
|
||||||
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? {
|
override fun platformByCompilerArguments(arguments: CommonCompilerArguments): TargetPlatform? {
|
||||||
return if (arguments is FakeK2NativeCompilerArguments)
|
return if (arguments is FakeK2NativeCompilerArguments)
|
||||||
NativePlatforms.defaultNativePlatform
|
NativePlatforms.unspecifiedNativePlatform
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,7 @@ object NativeIdePlatformKind : IdePlatformKind<NativeIdePlatformKind>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val defaultPlatform: TargetPlatform
|
override val defaultPlatform: TargetPlatform
|
||||||
get() = NativePlatforms.defaultNativePlatform
|
get() = NativePlatforms.unspecifiedNativePlatform
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform",
|
message = "IdePlatform is deprecated and will be removed soon, please, migrate to org.jetbrains.kotlin.platform.TargetPlatform",
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ class NativeIdePlatformKindTooling : IdePlatformKindTooling() {
|
|||||||
|
|
||||||
object NativeLibraryKind : PersistentLibraryKind<DummyLibraryProperties>("kotlin.native"), KotlinLibraryKind {
|
object NativeLibraryKind : PersistentLibraryKind<DummyLibraryProperties>("kotlin.native"), KotlinLibraryKind {
|
||||||
override val compilerPlatform: TargetPlatform
|
override val compilerPlatform: TargetPlatform
|
||||||
get() = NativePlatforms.defaultNativePlatform
|
// TODO: detect native platform by ???
|
||||||
|
get() = NativePlatforms.unspecifiedNativePlatform
|
||||||
|
|
||||||
override fun createDefaultProperties() = DummyLibraryProperties.INSTANCE!!
|
override fun createDefaultProperties() = DummyLibraryProperties.INSTANCE!!
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ object NativeLibraryType : LibraryType<DummyLibraryProperties>(NativeLibraryKind
|
|||||||
// However this does not work for libraries that are to be just created during project build, e.g. C-interop Kotlin/Native KLIBs.
|
// However this does not work for libraries that are to be just created during project build, e.g. C-interop Kotlin/Native KLIBs.
|
||||||
// The code below helps to perform postponed detection of Kotlin/Native libraries.
|
// The code below helps to perform postponed detection of Kotlin/Native libraries.
|
||||||
override fun detect(classesRoots: List<VirtualFile>): DummyLibraryProperties? =
|
override fun detect(classesRoots: List<VirtualFile>): DummyLibraryProperties? =
|
||||||
if (classesRoots.firstOrNull()?.isKlibLibraryRootForPlatform(NativePlatforms.defaultNativePlatform) == true)
|
if (classesRoots.firstOrNull()?.isKlibLibraryRootForPlatform(NativePlatforms.unspecifiedNativePlatform) == true)
|
||||||
DummyLibraryProperties.INSTANCE!!
|
DummyLibraryProperties.INSTANCE!!
|
||||||
else null
|
else null
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class NativePlatformKindResolution : IdePlatformKindResolution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun isLibraryFileForPlatform(virtualFile: VirtualFile): Boolean =
|
override fun isLibraryFileForPlatform(virtualFile: VirtualFile): Boolean =
|
||||||
virtualFile.isKlibLibraryRootForPlatform(NativePlatforms.defaultNativePlatform)
|
virtualFile.isKlibLibraryRootForPlatform(NativePlatforms.unspecifiedNativePlatform)
|
||||||
|
|
||||||
override fun createResolverForModuleFactory(
|
override fun createResolverForModuleFactory(
|
||||||
settings: PlatformAnalysisParameters,
|
settings: PlatformAnalysisParameters,
|
||||||
@@ -162,5 +162,6 @@ class NativeKlibLibraryInfo(project: Project, library: Library, libraryRoot: Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val platform: TargetPlatform
|
override val platform: TargetPlatform
|
||||||
get() = NativePlatforms.defaultNativePlatform
|
// TODO: detect native platform by library
|
||||||
|
get() = NativePlatforms.unspecifiedNativePlatform
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -47,7 +47,7 @@ class NativeResolverForModuleFactory(
|
|||||||
moduleContext,
|
moduleContext,
|
||||||
declarationProviderFactory,
|
declarationProviderFactory,
|
||||||
CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(),
|
CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(),
|
||||||
NativePlatforms.defaultNativePlatform,
|
moduleDescriptor.platform!!,
|
||||||
NativePlatformAnalyzerServices,
|
NativePlatformAnalyzerServices,
|
||||||
targetEnvironment,
|
targetEnvironment,
|
||||||
languageVersionSettings
|
languageVersionSettings
|
||||||
@@ -56,7 +56,7 @@ class NativeResolverForModuleFactory(
|
|||||||
var packageFragmentProvider = container.get<ResolveSession>().packageFragmentProvider
|
var packageFragmentProvider = container.get<ResolveSession>().packageFragmentProvider
|
||||||
|
|
||||||
val klibPackageFragmentProvider =
|
val klibPackageFragmentProvider =
|
||||||
NativePlatforms.defaultNativePlatform.idePlatformKind.resolution.createKlibPackageFragmentProvider(
|
NativePlatforms.unspecifiedNativePlatform.idePlatformKind.resolution.createKlibPackageFragmentProvider(
|
||||||
moduleContent.moduleInfo,
|
moduleContent.moduleInfo,
|
||||||
moduleContext.storageManager,
|
moduleContext.storageManager,
|
||||||
languageVersionSettings,
|
languageVersionSettings,
|
||||||
|
|||||||
+1
-1
@@ -264,7 +264,7 @@ class ModulesTxtBuilder {
|
|||||||
"js" -> settings.compilerArguments =
|
"js" -> settings.compilerArguments =
|
||||||
K2JSCompilerArguments().also { settings.targetPlatform = JsPlatforms.defaultJsPlatform }
|
K2JSCompilerArguments().also { settings.targetPlatform = JsPlatforms.defaultJsPlatform }
|
||||||
"native" -> settings.compilerArguments =
|
"native" -> settings.compilerArguments =
|
||||||
FakeK2NativeCompilerArguments().also { settings.targetPlatform = NativePlatforms.defaultNativePlatform }
|
FakeK2NativeCompilerArguments().also { settings.targetPlatform = NativePlatforms.unspecifiedNativePlatform }
|
||||||
else -> {
|
else -> {
|
||||||
val flagProperty = ModulesTxt.Module.flags[flag]
|
val flagProperty = ModulesTxt.Module.flags[flag]
|
||||||
if (flagProperty != null) flagProperty.set(module, true)
|
if (flagProperty != null) flagProperty.set(module, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user