[Gradle] Include native platform dependencies explicitly
They are now also exposed via KotlinCompilation.compileDependencyFiles Which is useful for tools like dokka that relies on exhaustive list of dependencies for given source set/compilation. ^KT-61559 Verification Pending
This commit is contained in:
committed by
Space Team
parent
43acc6516b
commit
639e048438
+9
-5
@@ -10,6 +10,7 @@ import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.util.GradleVersion
|
||||
import java.util.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
/**
|
||||
* Asserts Gradle output contains [expectedSubString] string.
|
||||
@@ -422,12 +423,15 @@ fun BuildResult.assertOutputContainsNativeFrameworkVariant(variantName: String,
|
||||
* Asserts that the command line arguments do not contain any duplicates.
|
||||
*/
|
||||
fun CommandLineArguments.assertNoDuplicates() {
|
||||
assert(args.size == args.toSet().size) {
|
||||
buildResult.printBuildOutput()
|
||||
"Link task has duplicated arguments: ${args.joinToString()}"
|
||||
}
|
||||
}
|
||||
// -library can be duplicated as it represent compile dependencies
|
||||
val argsWithoutLibraries = args.filter { it != "-library" }
|
||||
|
||||
assertEquals(
|
||||
argsWithoutLibraries.joinToString("\n"),
|
||||
argsWithoutLibraries.toSet().joinToString("\n"),
|
||||
"Link task has duplicated arguments"
|
||||
)
|
||||
}
|
||||
|
||||
private fun BuildResult.extractNativeCustomEnvironment(taskPath: String, toolName: NativeToolKind): Map<String, String> =
|
||||
extractNativeToolSettings(getOutputForTask(taskPath, LogLevel.INFO), toolName, NativeToolSettingsKind.CUSTOM_ENV_VARIABLES).map {
|
||||
|
||||
+1
@@ -80,5 +80,6 @@ interface CompilerArgumentAware<T : CommonToolArguments> : KotlinCompilerArgumen
|
||||
|
||||
private val includedArgumentTypes = setOf(
|
||||
ArgumentType.Primitive,
|
||||
ArgumentType.DependencyClasspath,
|
||||
ArgumentType.PluginClasspath,
|
||||
)
|
||||
|
||||
+7
-3
@@ -16,8 +16,7 @@ import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP
|
||||
import org.jetbrains.kotlin.gradle.internal.PLATFORM_INTEGERS_SUPPORT_LIBRARY
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.ideaImportDependsOn
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.getVisibleSourceSetsFromAssociateCompilations
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.findMetadataCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||
@@ -90,11 +89,16 @@ private fun getCommonizedPlatformLibrariesFor(rootOutputDirectory: File, target:
|
||||
return targetOutputDirectory.listLibraryFiles()
|
||||
}
|
||||
|
||||
private suspend fun InternalKotlinSourceSet.singlePlatformCompilationOrNull(): KotlinCompilation<*>? {
|
||||
return awaitPlatformCompilations().distinctBy { it.target }.singleOrNull()
|
||||
}
|
||||
|
||||
private suspend fun Project.addDependencies(
|
||||
sourceSet: KotlinSourceSet, libraries: FileCollection, isCompilationDependency: Boolean = true, isIdeDependency: Boolean = true
|
||||
) {
|
||||
if (isCompilationDependency) {
|
||||
findMetadataCompilation(sourceSet)?.let { compilation ->
|
||||
val compilation = findMetadataCompilation(sourceSet) ?: sourceSet.internal.singlePlatformCompilationOrNull()
|
||||
if (compilation != null) {
|
||||
compilation.compileDependencyFiles += libraries
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -239,6 +239,7 @@ constructor(
|
||||
args.produce = outputKind.name.toLowerCaseAsciiOnly()
|
||||
args.multiPlatform = true
|
||||
args.noendorsedlibs = true
|
||||
args.nodefaultlibs = true
|
||||
args.pluginOptions = compilerPlugins.flatMap { it.options.arguments }.toTypedArray()
|
||||
args.generateTestRunner = processTests
|
||||
args.mainPackage = entryPoint
|
||||
|
||||
+1
-1
@@ -452,7 +452,7 @@ internal constructor(
|
||||
args.target = konanTarget.name
|
||||
args.produce = outputKind.name.toLowerCaseAsciiOnly()
|
||||
args.metadataKlib = sharedCompilationData != null
|
||||
args.nodefaultlibs = sharedCompilationData != null
|
||||
args.nodefaultlibs = true
|
||||
args.manifestFile = sharedCompilationData?.manifestFile?.absolutePath
|
||||
args.nopack = produceUnpackedKlib.get()
|
||||
|
||||
|
||||
+2
-3
@@ -10,8 +10,7 @@ package org.jetbrains.kotlin.gradle.unitTests.compilerArgumetns
|
||||
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.CreateCompilerArgumentsContext
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.PluginClasspath
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.Primitive
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.default
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.lenient
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR
|
||||
@@ -36,7 +35,7 @@ class Kotlin2JsCompileArgumentsTest {
|
||||
val jsMainCompileTask = jsMainCompilation.compileTaskProvider.get()
|
||||
val argumentsFromCompilerArgumentsProducer = jsMainCompileTask.createCompilerArguments(
|
||||
CreateCompilerArgumentsContext(
|
||||
includeArgumentTypes = setOf(Primitive, PluginClasspath),
|
||||
includeArgumentTypes = setOf(Primitive, DependencyClasspath, PluginClasspath),
|
||||
isLenient = true
|
||||
)
|
||||
)
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinJvmExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.CreateCompilerArgumentsContext
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.PluginClasspath
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.Primitive
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ArgumentType.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.CreateCompilerArgumentsContext.Companion.lenient
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.util.assertNotNull
|
||||
@@ -50,7 +50,7 @@ class KotlinCompileArgumentsTest {
|
||||
val mainCompilationTask = mainCompilation.compileTaskProvider.get() as KotlinCompile
|
||||
val argumentsFromKotlinCompilerArgumentsAware = mainCompilationTask.createCompilerArguments(
|
||||
CreateCompilerArgumentsContext(
|
||||
includeArgumentTypes = setOf(Primitive, PluginClasspath),
|
||||
includeArgumentTypes = setOf(Primitive, DependencyClasspath, PluginClasspath),
|
||||
isLenient = true
|
||||
)
|
||||
)
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ class KotlinNativeCompileArgumentsTest {
|
||||
val argumentsFromCompilerArgumentsProducer = compile.createCompilerArguments(lenient)
|
||||
val argumentsFromBuildCompilerArgs = K2NativeCompilerArguments().apply {
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
compile.setupCompilerArgs(this, true)
|
||||
compile.setupCompilerArgs(this, false, true)
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
|
||||
Reference in New Issue
Block a user