Fix up-to-date checks for framework compilation
This commit is contained in:
committed by
Ilya Matveev
parent
73138073f1
commit
ee5bc95da5
+2
-37
@@ -437,41 +437,6 @@ open class KotlinNativeTargetConfigurator(
|
||||
compilerPluginClasspath = project.configurations.getByName(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME)
|
||||
}
|
||||
|
||||
private fun KotlinNativeCompile.registerOutputFiles(outputDirectory: File) {
|
||||
val konanTarget = compilation.target.konanTarget
|
||||
|
||||
val prefix = outputKind.prefix(konanTarget)
|
||||
val suffix = outputKind.suffix(konanTarget)
|
||||
val baseName = if (compilation.isMainCompilation) project.name else compilation.name
|
||||
|
||||
outputFile.set(project.provider {
|
||||
var filename = "$prefix$baseName$suffix"
|
||||
if (outputKind == CompilerOutputKind.FRAMEWORK ||
|
||||
outputKind == CompilerOutputKind.STATIC ||
|
||||
outputKind == CompilerOutputKind.DYNAMIC ||
|
||||
outputKind == CompilerOutputKind.PROGRAM && konanTarget == KonanTarget.WASM32
|
||||
) {
|
||||
filename = filename.replace('-', '_')
|
||||
}
|
||||
|
||||
outputDirectory.resolve(filename)
|
||||
})
|
||||
|
||||
// Register outputs
|
||||
if (outputKind == CompilerOutputKind.FRAMEWORK) {
|
||||
outputs.dir(outputFile)
|
||||
} else {
|
||||
outputs.file(outputFile)
|
||||
}
|
||||
|
||||
if (outputKind == CompilerOutputKind.STATIC || outputKind == CompilerOutputKind.DYNAMIC) {
|
||||
outputs.file(project.provider {
|
||||
val apiFileName = "$prefix${baseName}_api.h".replace('-', '_')
|
||||
outputDirectory.resolve(apiFileName)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.createBinaryLinkTasks(compilation: KotlinNativeCompilation) = whenEvaluated {
|
||||
val konanTarget = compilation.target.konanTarget
|
||||
val availableOutputKinds = compilation.outputKinds.filter { it.availableFor(konanTarget) }
|
||||
@@ -495,7 +460,7 @@ open class KotlinNativeTargetConfigurator(
|
||||
optimized = buildType.optimized
|
||||
debuggable = buildType.debuggable
|
||||
|
||||
registerOutputFiles(binaryOutputDirectory(buildType, kind, compilation))
|
||||
destinationDir = binaryOutputDirectory(buildType, kind, compilation)
|
||||
addCompilerPlugins()
|
||||
|
||||
linkAll.dependsOn(this)
|
||||
@@ -582,7 +547,7 @@ open class KotlinNativeTargetConfigurator(
|
||||
"compilation for target '${compilation.platformType.name}'."
|
||||
enabled = compilation.target.konanTarget.enabledOnCurrentHost
|
||||
|
||||
registerOutputFiles(klibOutputDirectory(compilation))
|
||||
destinationDir = klibOutputDirectory(compilation)
|
||||
addCompilerPlugins()
|
||||
compilation.output.tryAddClassesDir {
|
||||
project.files(this.outputFile).builtBy(this)
|
||||
|
||||
+18
-10
@@ -20,6 +20,10 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.defaultSourceSetName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.isMainCompilation
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind.DYNAMIC
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind.FRAMEWORK
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind.PROGRAM
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind.STATIC
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
|
||||
@@ -78,19 +82,11 @@ private fun FileCollection.filterOutPublishableInteropLibs(project: Project): Fi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// endregion
|
||||
|
||||
|
||||
open class KotlinNativeCompile : AbstractCompile() {
|
||||
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
setDestinationDir(project.provider {
|
||||
val output = outputFile.get()
|
||||
if (output.isDirectory) output else output.parentFile
|
||||
})
|
||||
|
||||
sourceCompatibility = "1.6"
|
||||
targetCompatibility = "1.6"
|
||||
}
|
||||
@@ -178,9 +174,21 @@ open class KotlinNativeCompile : AbstractCompile() {
|
||||
val kotlinNativeVersion: String
|
||||
@Input get() = project.konanVersion.toString()
|
||||
|
||||
// We manually register this property as output file or directory depending on output kind.
|
||||
// OutputFile is located under the destinationDir, so there is no need to register it as a separate output.
|
||||
@Internal
|
||||
val outputFile: Property<File> = project.objects.property(File::class.java)
|
||||
val outputFile: Provider<File> = project.provider {
|
||||
val konanTarget = compilation.target.konanTarget
|
||||
|
||||
val prefix = outputKind.prefix(konanTarget)
|
||||
val suffix = outputKind.suffix(konanTarget)
|
||||
val baseName = if (compilation.isMainCompilation) project.name else compilation.name
|
||||
var filename = "$prefix$baseName$suffix"
|
||||
if (outputKind in listOf(FRAMEWORK, STATIC, DYNAMIC) || outputKind == PROGRAM && konanTarget == KonanTarget.WASM32) {
|
||||
filename = filename.replace('-', '_')
|
||||
}
|
||||
|
||||
destinationDir.resolve(filename)
|
||||
}
|
||||
|
||||
// endregion
|
||||
@Internal
|
||||
|
||||
Reference in New Issue
Block a user