[Gradle, K/N] Stop using enableEndorsedLibs Gradle flag, make it Error
#KT-54098 Fixed
This commit is contained in:
committed by
Space Team
parent
3b75658113
commit
67c4dc3cce
@@ -13,9 +13,16 @@ kotlin {
|
||||
hostOs.startsWith("Windows") -> mingwX64("csvParser")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
compilations["main"].enableEndorsedLibs = true
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.csvparser.main"
|
||||
|
||||
@@ -45,8 +45,14 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compilations["main"].enableEndorsedLibs = true
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable experimental stdlib API used by the sample.
|
||||
|
||||
+7
-4
@@ -162,10 +162,13 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
|
||||
|
||||
protected fun Project.configureNativeTarget(hostPreset: AbstractKotlinNativeTargetPreset<*>) {
|
||||
kotlin.targetFromPreset(hostPreset, NATIVE_TARGET_NAME) {
|
||||
@Suppress("DEPRECATION")
|
||||
compilations.getByName("main").kotlinOptions.freeCompilerArgs = benchmark.compilerOpts + project.compilerArgs
|
||||
@Suppress("DEPRECATION") // enableEndorsedLibs is scheduled to be removed in 1.9.0, see KT-54098
|
||||
compilations.getByName("main").enableEndorsedLibs = true
|
||||
compilations.named("main").configure {
|
||||
@Suppress("DEPRECATION")
|
||||
kotlinOptions.freeCompilerArgs = benchmark.compilerOpts + project.compilerArgs
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
|
||||
}
|
||||
}
|
||||
configureNativeOutput(this@configureNativeTarget)
|
||||
}
|
||||
}
|
||||
|
||||
-17
@@ -139,23 +139,6 @@ class GeneralNativeIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEndorsedLibsController() {
|
||||
with(
|
||||
transformNativeTestProjectWithPluginDsl("native-endorsed")
|
||||
) {
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
gradleBuildScript().modify {
|
||||
it.replace("enableEndorsedLibs = true", "")
|
||||
}
|
||||
build("build") {
|
||||
assertFailed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCanProduceNativeLibraries() = with(transformNativeTestProjectWithPluginDsl("libraries", directoryPrefix = "native-binaries")) {
|
||||
val baseName = "native_library"
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform").version("<pluginMarkerVersion>")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
<SingleNativeTarget>("host") {
|
||||
compilations.all {
|
||||
kotlinOptions.verbose = true
|
||||
enableEndorsedLibs = true
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
rootProject.name = "native-endorsed"
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
import kotlinx.cli.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val argParser = ArgParser("test")
|
||||
val size by argParser.option(ArgType.Int, shortName = "s", description = "Required size of videoplayer window")
|
||||
.delimiter(",")
|
||||
val fileName by argParser.argument(ArgType.String, description = "File to play")
|
||||
argParser.parse(args)
|
||||
}
|
||||
+4
-1
@@ -183,7 +183,10 @@ internal open class GradleKpmNativeFragmentMetadataCompilationDataImpl(
|
||||
}
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
override val enableEndorsedLibs: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
+7
-3
@@ -17,10 +17,14 @@ internal class GradleKpmNativeVariantCompilationData(
|
||||
override val konanTarget: KonanTarget
|
||||
get() = variant.konanTarget
|
||||
|
||||
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
override val enableEndorsedLibs: Boolean
|
||||
get() = variant.enableEndorsedLibraries
|
||||
get() = false
|
||||
|
||||
override val project: Project
|
||||
get() = variant.containingModule.project
|
||||
|
||||
+4
-1
@@ -48,6 +48,9 @@ abstract class GradleKpmNativeVariantInternal(
|
||||
interface GradleKpmNativeCompilationData<T : KotlinCommonOptions> : GradleKpmCompilationData<T> {
|
||||
val konanTarget: KonanTarget
|
||||
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
val enableEndorsedLibs: Boolean
|
||||
}
|
||||
|
||||
+5
-1
@@ -42,7 +42,11 @@ abstract class AbstractKotlinNativeCompilation internal constructor(
|
||||
get() = project.nativeUseEmbeddableCompilerJar
|
||||
|
||||
// Endorsed library controller.
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
@Suppress("unused")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
var enableEndorsedLibs: Boolean = false
|
||||
}
|
||||
|
||||
|
||||
+4
-8
@@ -37,7 +37,6 @@ internal fun buildKotlinNativeKlibCompilerArgs(
|
||||
libraries: List<File>,
|
||||
|
||||
languageSettings: LanguageSettings,
|
||||
enableEndorsedLibs: Boolean,
|
||||
compilerOptions: KotlinCommonCompilerOptions,
|
||||
compilerPlugins: List<CompilerPluginData>,
|
||||
|
||||
@@ -77,7 +76,7 @@ internal fun buildKotlinNativeKlibCompilerArgs(
|
||||
}
|
||||
}
|
||||
|
||||
addAll(buildKotlinNativeCompileCommonArgs(enableEndorsedLibs, languageSettings, compilerOptions, compilerPlugins))
|
||||
addAll(buildKotlinNativeCompileCommonArgs(languageSettings, compilerOptions, compilerPlugins))
|
||||
|
||||
addAll(source.map { it.absolutePath })
|
||||
if (!commonSourcesTree.isEmpty) {
|
||||
@@ -94,7 +93,6 @@ internal fun buildKotlinNativeBinaryLinkerArgs(
|
||||
libraries: List<File>,
|
||||
friendModules: List<File>,
|
||||
|
||||
enableEndorsedLibs: Boolean,
|
||||
toolOptions: KotlinCommonCompilerToolOptions,
|
||||
compilerPlugins: List<CompilerPluginData>,
|
||||
|
||||
@@ -122,7 +120,7 @@ internal fun buildKotlinNativeBinaryLinkerArgs(
|
||||
binaryOptions.forEach { (name, value) -> add("-Xbinary=$name=$value") }
|
||||
addKey("-Xstatic-framework", isStaticFramework)
|
||||
|
||||
addAll(buildKotlinNativeCommonArgs(enableEndorsedLibs, toolOptions, compilerPlugins))
|
||||
addAll(buildKotlinNativeCommonArgs(toolOptions, compilerPlugins))
|
||||
|
||||
exportLibraries.forEach { add("-Xexport-library=${it.absolutePath}") }
|
||||
includeLibraries.forEach { add("-Xinclude=${it.absolutePath}") }
|
||||
@@ -150,13 +148,12 @@ private fun buildKotlinNativeMainArgs(
|
||||
}
|
||||
|
||||
internal fun buildKotlinNativeCompileCommonArgs(
|
||||
enableEndorsedLibs: Boolean,
|
||||
languageSettings: LanguageSettings,
|
||||
compilerOptions: KotlinCommonCompilerOptions,
|
||||
compilerPlugins: List<CompilerPluginData>
|
||||
): List<String> = mutableListOf<String>().apply {
|
||||
add("-Xmulti-platform")
|
||||
addKey("-no-endorsed-libs", !enableEndorsedLibs)
|
||||
addKey("-no-endorsed-libs", true)
|
||||
|
||||
compilerPlugins.forEach { plugin ->
|
||||
plugin.files.map { it.canonicalPath }.sorted().forEach { add("-Xplugin=$it") }
|
||||
@@ -179,12 +176,11 @@ internal fun buildKotlinNativeCompileCommonArgs(
|
||||
}
|
||||
|
||||
internal fun buildKotlinNativeCommonArgs(
|
||||
enableEndorsedLibs: Boolean,
|
||||
toolOptions: KotlinCommonCompilerToolOptions,
|
||||
compilerPlugins: List<CompilerPluginData>
|
||||
): List<String> = mutableListOf<String>().apply {
|
||||
add("-Xmulti-platform")
|
||||
addKey("-no-endorsed-libs", !enableEndorsedLibs)
|
||||
addKey("-no-endorsed-libs", true)
|
||||
|
||||
compilerPlugins.forEach { plugin ->
|
||||
plugin.files.map { it.canonicalPath }.sorted().forEach { add("-Xplugin=$it") }
|
||||
|
||||
+7
-6
@@ -263,10 +263,14 @@ constructor(
|
||||
objectFactory.property(it.file(filename).asFile)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
@Suppress("unused", "DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@get:Input
|
||||
val enableEndorsedLibs: Boolean by lazy { compilation.enableEndorsedLibs }
|
||||
val enableEndorsedLibs: Boolean
|
||||
get() = false
|
||||
|
||||
@Internal
|
||||
val compilerPluginOptions = CompilerPluginOptions()
|
||||
@@ -313,8 +317,6 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION") val enableEndorsedLibs = this.enableEndorsedLibs // TODO: remove before 1.9.0, see KT-54098
|
||||
|
||||
val buildArgs = buildKotlinNativeBinaryLinkerArgs(
|
||||
output,
|
||||
optimized,
|
||||
@@ -323,7 +325,6 @@ constructor(
|
||||
outputKind,
|
||||
libraries.files.filterKlibsPassedToCompiler(),
|
||||
friendModule.files.toList(),
|
||||
enableEndorsedLibs,
|
||||
toolOptions,
|
||||
plugins,
|
||||
processTests,
|
||||
|
||||
+7
-6
@@ -203,11 +203,14 @@ abstract class AbstractKotlinNativeCompile<
|
||||
get() = languageSettings.progressiveMode
|
||||
// endregion.
|
||||
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@get:Input
|
||||
val enableEndorsedLibs: Boolean by project.provider {
|
||||
compilation.tcsOrNull?.compilation?.run { this as? KotlinNativeCompilation }?.enableEndorsedLibs ?: false
|
||||
}
|
||||
val enableEndorsedLibs: Boolean
|
||||
get() = false
|
||||
|
||||
@get:Input
|
||||
val kotlinNativeVersion: String
|
||||
@@ -425,7 +428,6 @@ internal constructor(
|
||||
)
|
||||
|
||||
return buildKotlinNativeCompileCommonArgs(
|
||||
enableEndorsedLibs,
|
||||
languageSettings,
|
||||
compilerOptions,
|
||||
plugins
|
||||
@@ -467,7 +469,6 @@ internal constructor(
|
||||
konanTarget,
|
||||
libraries.files.filterKlibsPassedToCompiler(),
|
||||
languageSettings,
|
||||
enableEndorsedLibs,
|
||||
compilerOptions,
|
||||
plugins,
|
||||
moduleName,
|
||||
|
||||
+6
-3
@@ -55,7 +55,10 @@ abstract class KotlinNativeLinkArtifactTask @Inject constructor(
|
||||
@get:Input
|
||||
abstract val debuggable: Property<Boolean>
|
||||
|
||||
@Deprecated("Please declare explicit dependency on kotlinx-cli. This option is scheduled to be removed in 1.9.0")
|
||||
@Deprecated(
|
||||
"Please declare explicit dependency on kotlinx-cli. This option has no longer effect since 1.9.0",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
@get:Input
|
||||
abstract val enableEndorsedLibs: Property<Boolean>
|
||||
|
||||
@@ -156,7 +159,8 @@ abstract class KotlinNativeLinkArtifactTask @Inject constructor(
|
||||
baseName.convention(project.name)
|
||||
debuggable.convention(true)
|
||||
optimized.convention(false)
|
||||
enableEndorsedLibs.convention(false)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
enableEndorsedLibs.value(false).finalizeValue()
|
||||
processTests.convention(false)
|
||||
staticFramework.convention(false)
|
||||
embedBitcode.convention(BitcodeEmbeddingMode.DISABLE)
|
||||
@@ -183,7 +187,6 @@ abstract class KotlinNativeLinkArtifactTask @Inject constructor(
|
||||
outputKind = outputKind,
|
||||
libraries = libraries.klibs(),
|
||||
friendModules = emptyList(), //FriendModules aren't needed here because it's no test artifact
|
||||
enableEndorsedLibs = enableEndorsedLibs.get(), // TODO: remove before 1.9.0, see KT-54098
|
||||
toolOptions = toolOptions,
|
||||
compilerPlugins = emptyList(),//CompilerPlugins aren't needed here because it's no compilation but linking
|
||||
processTests = processTests.get(),
|
||||
|
||||
Reference in New Issue
Block a user