Support friend modules in native mpp
This commit is contained in:
committed by
Ilya Matveev
parent
595a7700df
commit
03e1e8d19d
+1
@@ -86,6 +86,7 @@ class KotlinNativeCompilationFactory(
|
||||
override fun create(name: String): KotlinNativeCompilation =
|
||||
KotlinNativeCompilation(target, name, target.createCompilationOutput(name)).apply {
|
||||
if (name == KotlinCompilation.TEST_COMPILATION_NAME) {
|
||||
friendCompilationName = KotlinCompilation.MAIN_COMPILATION_NAME
|
||||
outputKinds = mutableListOf(NativeOutputKind.EXECUTABLE)
|
||||
buildTypes = mutableListOf(NativeBuildType.DEBUG)
|
||||
isTestCompilation = true
|
||||
|
||||
+7
@@ -281,6 +281,13 @@ class KotlinNativeCompilation(
|
||||
|
||||
var isTestCompilation = false
|
||||
|
||||
var friendCompilationName: String? = null
|
||||
|
||||
internal val friendCompilation: KotlinNativeCompilation?
|
||||
get() = friendCompilationName?.let {
|
||||
target.compilations.getByName(it)
|
||||
}
|
||||
|
||||
// Native-specific DSL.
|
||||
val extraOpts = mutableListOf<String>()
|
||||
|
||||
|
||||
+9
@@ -42,6 +42,10 @@ open class KotlinNativeCompile : DefaultTask() {
|
||||
val libraries: FileCollection
|
||||
@InputFiles get() = compilation.compileDependencyFiles
|
||||
|
||||
val friendModule: FileCollection?
|
||||
// It's already taken into account in libraries
|
||||
@Internal get() = compilation.friendCompilation?.output
|
||||
|
||||
@Input
|
||||
var optimized = false
|
||||
@Input
|
||||
@@ -138,6 +142,11 @@ open class KotlinNativeCompile : DefaultTask() {
|
||||
addArg("-l", library.nameWithoutExtension)
|
||||
}
|
||||
|
||||
val friends = friendModule?.files
|
||||
if (friends != null && friends.isNotEmpty()) {
|
||||
addArg("-friend-modules", friends.map { it.absolutePath }.joinToString(File.pathSeparator))
|
||||
}
|
||||
|
||||
// TODO: Filter only kt files?
|
||||
addAll(sources.files.map { it.absolutePath })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user