[Gradle] Replace FakeK2NativeCompilerArguments with K2NativeCompilerArguments
KTIJ-24976
This commit is contained in:
committed by
Space Team
parent
c5e154a325
commit
2b893365aa
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.arguments.CompilerArgumentsSerializerV5
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.platform.*
|
import org.jetbrains.kotlin.platform.*
|
||||||
import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
||||||
import org.jetbrains.kotlin.platform.jvm.JdkPlatform
|
import org.jetbrains.kotlin.platform.jvm.JdkPlatform
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
@@ -43,7 +42,7 @@ fun TargetPlatform.createArguments(init: (CommonCompilerArguments).() -> Unit =
|
|||||||
jvmTarget = (single() as? JdkPlatform)?.targetVersion?.description ?: JvmTarget.DEFAULT.description
|
jvmTarget = (single() as? JdkPlatform)?.targetVersion?.description ?: JvmTarget.DEFAULT.description
|
||||||
}
|
}
|
||||||
isJs() -> K2JSCompilerArguments().apply { init() }
|
isJs() -> K2JSCompilerArguments().apply { init() }
|
||||||
isNative() -> FakeK2NativeCompilerArguments().apply { init() }
|
isNative() -> K2NativeCompilerArguments().apply { init() }
|
||||||
else -> error("Unknown platform $this")
|
else -> error("Unknown platform $this")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package org.jetbrains.kotlin.platform.impl
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.Freezable
|
import org.jetbrains.kotlin.cli.common.arguments.Freezable
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.copyCommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.copyCommonCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||||
import org.jetbrains.kotlin.platform.IdePlatform
|
import org.jetbrains.kotlin.platform.IdePlatform
|
||||||
import org.jetbrains.kotlin.platform.IdePlatformKind
|
import org.jetbrains.kotlin.platform.IdePlatformKind
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
@@ -22,14 +23,14 @@ object NativeIdePlatformKind : IdePlatformKind() {
|
|||||||
override fun supportsTargetPlatform(platform: TargetPlatform): Boolean = platform.isNative()
|
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 K2NativeCompilerArguments)
|
||||||
NativePlatforms.unspecifiedNativePlatform
|
NativePlatforms.unspecifiedNativePlatform
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createArguments(): CommonCompilerArguments {
|
override fun createArguments(): K2NativeCompilerArguments {
|
||||||
return FakeK2NativeCompilerArguments()
|
return K2NativeCompilerArguments()
|
||||||
}
|
}
|
||||||
|
|
||||||
override val defaultPlatform: TargetPlatform
|
override val defaultPlatform: TargetPlatform
|
||||||
@@ -42,7 +43,7 @@ object NativeIdePlatformKind : IdePlatformKind() {
|
|||||||
override fun getDefaultPlatform(): IdePlatform<*, *> = Platform
|
override fun getDefaultPlatform(): IdePlatform<*, *> = Platform
|
||||||
|
|
||||||
override val argumentsClass
|
override val argumentsClass
|
||||||
get() = FakeK2NativeCompilerArguments::class.java
|
get() = K2NativeCompilerArguments::class.java
|
||||||
|
|
||||||
override val name
|
override val name
|
||||||
get() = "Native"
|
get() = "Native"
|
||||||
@@ -51,14 +52,18 @@ object NativeIdePlatformKind : IdePlatformKind() {
|
|||||||
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",
|
||||||
level = DeprecationLevel.ERROR
|
level = DeprecationLevel.ERROR
|
||||||
)
|
)
|
||||||
object Platform : IdePlatform<NativeIdePlatformKind, FakeK2NativeCompilerArguments>() {
|
object Platform : IdePlatform<NativeIdePlatformKind, K2NativeCompilerArguments>() {
|
||||||
override val kind get() = NativeIdePlatformKind
|
override val kind get() = NativeIdePlatformKind
|
||||||
override val version get() = TargetPlatformVersion.NoVersion
|
override val version get() = TargetPlatformVersion.NoVersion
|
||||||
override fun createArguments(init: FakeK2NativeCompilerArguments.() -> Unit) = FakeK2NativeCompilerArguments().apply(init)
|
override fun createArguments(init: K2NativeCompilerArguments.() -> Unit) = K2NativeCompilerArguments().apply(init)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are fake compiler arguments for Kotlin/Native - only for usage within IDEA plugin:
|
// These are fake compiler arguments for Kotlin/Native - only for usage within IDEA plugin:
|
||||||
|
@Deprecated(
|
||||||
|
message = "Use K2NativeCompilerArguments instead",
|
||||||
|
level = DeprecationLevel.ERROR
|
||||||
|
)
|
||||||
class FakeK2NativeCompilerArguments : CommonCompilerArguments() {
|
class FakeK2NativeCompilerArguments : CommonCompilerArguments() {
|
||||||
override fun copyOf(): Freezable = copyCommonCompilerArguments(this, FakeK2NativeCompilerArguments())
|
override fun copyOf(): Freezable = copyCommonCompilerArguments(this, FakeK2NativeCompilerArguments())
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -10,13 +10,13 @@ import org.jetbrains.jps.model.module.JpsModule
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.CompilerSettings
|
import org.jetbrains.kotlin.config.CompilerSettings
|
||||||
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||||
import org.jetbrains.kotlin.config.KotlinModuleKind.COMPILATION_AND_SOURCE_SET_HOLDER
|
import org.jetbrains.kotlin.config.KotlinModuleKind.COMPILATION_AND_SOURCE_SET_HOLDER
|
||||||
import org.jetbrains.kotlin.config.KotlinModuleKind.SOURCE_SET_HOLDER
|
import org.jetbrains.kotlin.config.KotlinModuleKind.SOURCE_SET_HOLDER
|
||||||
import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt.Dependency.Kind.*
|
import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt.Dependency.Kind.*
|
||||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||||
import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.platform.isCommon
|
import org.jetbrains.kotlin.platform.isCommon
|
||||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
@@ -267,7 +267,7 @@ class ModulesTxtBuilder {
|
|||||||
it.forceDeprecatedLegacyCompilerUsage = true
|
it.forceDeprecatedLegacyCompilerUsage = true
|
||||||
}
|
}
|
||||||
"native" -> settings.compilerArguments =
|
"native" -> settings.compilerArguments =
|
||||||
FakeK2NativeCompilerArguments().also { settings.targetPlatform = NativePlatforms.unspecifiedNativePlatform }
|
K2NativeCompilerArguments().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)
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.plugin.ide
|
package org.jetbrains.kotlin.gradle.plugin.ide
|
||||||
|
|
||||||
import org.jetbrains.kotlin.compilerRunner.toArgumentStrings
|
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.CreateCompilerArgumentsContext
|
import org.jetbrains.kotlin.gradle.plugin.CreateCompilerArgumentsContext
|
||||||
@@ -43,6 +43,6 @@ internal class IdeCompilerArgumentsResolverImpl(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return compilerArguments.toArgumentStrings(useShortNames = true)
|
return ArgumentUtils.convertArgumentsToStringList(compilerArguments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user