Fix capitalization related deprecation warnings
This commit is contained in:
committed by
teamcity
parent
40d62bf1a7
commit
dcd17e41a4
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
import org.jetbrains.kotlin.project.model.KotlinPlatformTypeAttribute
|
import org.jetbrains.kotlin.project.model.KotlinPlatformTypeAttribute
|
||||||
import plugins.configureDefaultPublishing
|
import plugins.configureDefaultPublishing
|
||||||
import plugins.configureKotlinPomAttributes
|
import plugins.configureKotlinPomAttributes
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gradle plugins common variants.
|
* Gradle plugins common variants.
|
||||||
@@ -130,7 +131,7 @@ fun Project.createGradleCommonSourceSet(): SourceSet {
|
|||||||
|
|
||||||
// Common outputs will also produce '${project.name}.kotlin_module' file, so we need to avoid
|
// Common outputs will also produce '${project.name}.kotlin_module' file, so we need to avoid
|
||||||
// files clash
|
// files clash
|
||||||
tasks.named<KotlinCompile>("compile${commonSourceSet.name.capitalize()}Kotlin") {
|
tasks.named<KotlinCompile>("compile${commonSourceSet.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}Kotlin") {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
moduleName = "${this@createGradleCommonSourceSet.name}_${commonSourceSet.name}"
|
moduleName = "${this@createGradleCommonSourceSet.name}_${commonSourceSet.name}"
|
||||||
}
|
}
|
||||||
@@ -357,7 +358,14 @@ fun Project.createGradlePluginVariant(
|
|||||||
|
|
||||||
if (kotlinBuildProperties.publishGradlePluginsJavadoc) {
|
if (kotlinBuildProperties.publishGradlePluginsJavadoc) {
|
||||||
plugins.withId("org.jetbrains.dokka") {
|
plugins.withId("org.jetbrains.dokka") {
|
||||||
val dokkaTask = tasks.register<DokkaTask>("dokka${variantSourceSet.javadocTaskName.capitalize()}") {
|
val dokkaTask = tasks.register<DokkaTask>(
|
||||||
|
"dokka${
|
||||||
|
variantSourceSet.javadocTaskName.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(
|
||||||
|
Locale.getDefault()
|
||||||
|
) else it.toString()
|
||||||
|
}
|
||||||
|
}") {
|
||||||
description = "Generates documentation in 'javadoc' format for '${variantSourceSet.javadocTaskName}' variant"
|
description = "Generates documentation in 'javadoc' format for '${variantSourceSet.javadocTaskName}' variant"
|
||||||
|
|
||||||
plugins.dependencies.add(
|
plugins.dependencies.add(
|
||||||
@@ -402,7 +410,7 @@ fun Project.createGradlePluginVariant(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KT-52138: Make module name the same for all variants, so KSP could access internal methods/properties
|
// KT-52138: Make module name the same for all variants, so KSP could access internal methods/properties
|
||||||
tasks.named<KotlinCompile>("compile${variantSourceSet.name.capitalize()}Kotlin") {
|
tasks.named<KotlinCompile>("compile${variantSourceSet.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}Kotlin") {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
moduleName = this@createGradlePluginVariant.name
|
moduleName = this@createGradlePluginVariant.name
|
||||||
}
|
}
|
||||||
@@ -462,7 +470,7 @@ fun Project.publishShadowedJar(
|
|||||||
val jarTask = tasks.named<Jar>(sourceSet.jarTaskName)
|
val jarTask = tasks.named<Jar>(sourceSet.jarTaskName)
|
||||||
|
|
||||||
val shadowJarTask = embeddableCompilerDummyForDependenciesRewriting(
|
val shadowJarTask = embeddableCompilerDummyForDependenciesRewriting(
|
||||||
taskName = "$EMBEDDABLE_COMPILER_TASK_NAME${sourceSet.jarTaskName.capitalize()}"
|
taskName = "$EMBEDDABLE_COMPILER_TASK_NAME${sourceSet.jarTaskName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
|
||||||
) {
|
) {
|
||||||
setupPublicJar(
|
setupPublicJar(
|
||||||
jarTask.flatMap { it.archiveBaseName },
|
jarTask.flatMap { it.archiveBaseName },
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
package org.jetbrains.kotlin
|
package org.jetbrains.kotlin
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
||||||
|
|
||||||
@@ -8,6 +9,6 @@ data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
|||||||
get() = project.name
|
get() = project.name
|
||||||
|
|
||||||
val taskName: String by lazy {
|
val taskName: String by lazy {
|
||||||
projectName.split('.').joinToString(separator = "") { it.capitalize() }
|
projectName.split('.').joinToString(separator = "") { it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ import java.io.Serializable
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test task for -produce framework testing. Requires a framework to be built by the Konan plugin
|
* Test task for -produce framework testing. Requires a framework to be built by the Konan plugin
|
||||||
@@ -145,7 +146,10 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
|||||||
val provider = Paths.get(testOutput, name, "provider.swift")
|
val provider = Paths.get(testOutput, name, "provider.swift")
|
||||||
FileWriter(provider.toFile()).use { writer ->
|
FileWriter(provider.toFile()).use { writer ->
|
||||||
val providers = swiftSources.toFiles(Language.Swift)
|
val providers = swiftSources.toFiles(Language.Swift)
|
||||||
.map { it.name.toString().removeSuffix(".swift").capitalize() }
|
.map {
|
||||||
|
it.name.toString().removeSuffix(".swift")
|
||||||
|
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||||
|
}
|
||||||
.map { "${it}Tests" }
|
.map { "${it}Tests" }
|
||||||
|
|
||||||
writer.write("""
|
writer.write("""
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.io.File
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.Base64
|
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import org.jetbrains.kotlin.konan.file.File as KFile
|
import org.jetbrains.kotlin.konan.file.File as KFile
|
||||||
import org.gradle.nativeplatform.toolchain.internal.*
|
import org.gradle.nativeplatform.toolchain.internal.*
|
||||||
@@ -53,6 +52,8 @@ import org.gradle.nativeplatform.toolchain.internal.tools.ToolSearchPath
|
|||||||
import org.gradle.process.internal.ExecActionFactory
|
import org.gradle.process.internal.ExecActionFactory
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.HashSet
|
||||||
|
|
||||||
//region Project properties.
|
//region Project properties.
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ val Project.testTarget
|
|||||||
get() = findProperty("target") as? KonanTarget ?: HostManager.host
|
get() = findProperty("target") as? KonanTarget ?: HostManager.host
|
||||||
|
|
||||||
val Project.testTargetSuffix
|
val Project.testTargetSuffix
|
||||||
get() = (findProperty("target") as KonanTarget).name.capitalize()
|
get() = (findProperty("target") as KonanTarget).name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||||
|
|
||||||
val Project.verboseTest
|
val Project.verboseTest
|
||||||
get() = hasProperty("test_verbose")
|
get() = hasProperty("test_verbose")
|
||||||
@@ -89,15 +90,17 @@ val Project.cacheRedirectorEnabled
|
|||||||
val Project.compileOnlyTests: Boolean
|
val Project.compileOnlyTests: Boolean
|
||||||
get() = hasProperty("test_compile_only")
|
get() = hasProperty("test_compile_only")
|
||||||
|
|
||||||
fun Project.redirectIfEnabled(url: String):String = if (cacheRedirectorEnabled) {
|
fun Project.redirectIfEnabled(url: String): String = if (cacheRedirectorEnabled) {
|
||||||
val base = URL(url)
|
val base = URL(url)
|
||||||
"https://cache-redirector.jetbrains.com/${base.host}/${base.path}"
|
"https://cache-redirector.jetbrains.com/${base.host}/${base.path}"
|
||||||
} else
|
} else
|
||||||
url
|
url
|
||||||
|
|
||||||
val validPropertiesNames = listOf("konan.home",
|
val validPropertiesNames = listOf(
|
||||||
"org.jetbrains.kotlin.native.home",
|
"konan.home",
|
||||||
"kotlin.native.home")
|
"org.jetbrains.kotlin.native.home",
|
||||||
|
"kotlin.native.home"
|
||||||
|
)
|
||||||
|
|
||||||
val Project.kotlinNativeDist
|
val Project.kotlinNativeDist
|
||||||
get() = rootProject.currentKotlinNativeDist
|
get() = rootProject.currentKotlinNativeDist
|
||||||
@@ -137,10 +140,10 @@ fun Task.dependsOnPlatformLibs() {
|
|||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
private fun Project.groovyPropertyArrayToList(property: String): List<String> =
|
private fun Project.groovyPropertyArrayToList(property: String): List<String> =
|
||||||
with(findProperty(property)) {
|
with(findProperty(property)) {
|
||||||
if (this is Array<*>) this.toList() as List<String>
|
if (this is Array<*>) this.toList() as List<String>
|
||||||
else this as List<String>
|
else this as List<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
val Project.globalBuildArgs: List<String>
|
val Project.globalBuildArgs: List<String>
|
||||||
get() = project.groovyPropertyArrayToList("globalBuildArgs")
|
get() = project.groovyPropertyArrayToList("globalBuildArgs")
|
||||||
@@ -166,9 +169,12 @@ fun projectOrFiles(proj: Project, notation: String): Any? {
|
|||||||
*/
|
*/
|
||||||
fun codesign(project: Project, path: String) {
|
fun codesign(project: Project, path: String) {
|
||||||
check(HostManager.hostIsMac) { "Apple specific code signing" }
|
check(HostManager.hostIsMac) { "Apple specific code signing" }
|
||||||
val (stdOut, stdErr, exitCode) = runProcess(executor = localExecutor(project), executable = "/usr/bin/codesign",
|
val (stdOut, stdErr, exitCode) = runProcess(
|
||||||
args = listOf("--verbose", "-s", "-", path))
|
executor = localExecutor(project), executable = "/usr/bin/codesign",
|
||||||
check(exitCode == 0) { """
|
args = listOf("--verbose", "-s", "-", path)
|
||||||
|
)
|
||||||
|
check(exitCode == 0) {
|
||||||
|
"""
|
||||||
|Codesign failed with exitCode: $exitCode
|
|Codesign failed with exitCode: $exitCode
|
||||||
|stdout: $stdOut
|
|stdout: $stdOut
|
||||||
|stderr: $stdErr
|
|stderr: $stdErr
|
||||||
@@ -198,17 +204,24 @@ fun Project.getFilesToCompile(compile: List<String>, exclude: List<String>): Lis
|
|||||||
// create list of tests to compile
|
// create list of tests to compile
|
||||||
return compile.flatMap { f ->
|
return compile.flatMap { f ->
|
||||||
project.file(f)
|
project.file(f)
|
||||||
.walk()
|
.walk()
|
||||||
.filter { it.isFile && it.name.endsWith(".kt") && !excludeFiles.contains(it.absolutePath) }
|
.filter { it.isFile && it.name.endsWith(".kt") && !excludeFiles.contains(it.absolutePath) }
|
||||||
.map{ it.absolutePath }
|
.map { it.absolutePath }
|
||||||
.asIterable()
|
.asIterable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//region Task dependency.
|
//region Task dependency.
|
||||||
|
|
||||||
fun Project.findKonanBuildTask(artifact: String, target: KonanTarget): TaskProvider<Task> =
|
fun Project.findKonanBuildTask(artifact: String, target: KonanTarget): TaskProvider<Task> =
|
||||||
tasks.named("compileKonan${artifact.capitalize()}${target.name.capitalize()}")
|
tasks.named(
|
||||||
|
"compileKonan${artifact.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}${
|
||||||
|
target.name.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(
|
||||||
|
Locale.getDefault()
|
||||||
|
) else it.toString()
|
||||||
|
}
|
||||||
|
}")
|
||||||
|
|
||||||
fun Project.dependsOnDist(taskName: String) {
|
fun Project.dependsOnDist(taskName: String) {
|
||||||
project.tasks.getByName(taskName).dependsOnDist()
|
project.tasks.getByName(taskName).dependsOnDist()
|
||||||
@@ -234,7 +247,7 @@ private val Project.hasPlatformLibs: Boolean
|
|||||||
get() {
|
get() {
|
||||||
if (!isDefaultNativeHome) {
|
if (!isDefaultNativeHome) {
|
||||||
return File(buildDistribution(project.kotlinNativeDist.absolutePath).platformLibs(project.testTarget))
|
return File(buildDistribution(project.kotlinNativeDist.absolutePath).platformLibs(project.testTarget))
|
||||||
.exists()
|
.exists()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -243,7 +256,7 @@ private val Project.isCrossDist: Boolean
|
|||||||
get() {
|
get() {
|
||||||
if (!isDefaultNativeHome) {
|
if (!isDefaultNativeHome) {
|
||||||
return File(buildDistribution(project.kotlinNativeDist.absolutePath).runtime(project.testTarget))
|
return File(buildDistribution(project.kotlinNativeDist.absolutePath).runtime(project.testTarget))
|
||||||
.exists()
|
.exists()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -278,9 +291,9 @@ fun Task.dependsOnCrossDist(target: KonanTarget) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Task.konanOldPluginTaskDependenciesWalker(index:Int = 0, walker: Task.(Int)->Unit) {
|
fun Task.konanOldPluginTaskDependenciesWalker(index: Int = 0, walker: Task.(Int) -> Unit) {
|
||||||
walker(index + 1)
|
walker(index + 1)
|
||||||
dependsOn.forEach{
|
dependsOn.forEach {
|
||||||
val task = (it as? Task) ?: return@forEach
|
val task = (it as? Task) ?: return@forEach
|
||||||
if (task.name.startsWith("compileKonan"))
|
if (task.name.startsWith("compileKonan"))
|
||||||
task.konanOldPluginTaskDependenciesWalker(index + 1, walker)
|
task.konanOldPluginTaskDependenciesWalker(index + 1, walker)
|
||||||
@@ -320,17 +333,19 @@ fun Task.dependsOnKonanBuildingTask(artifact: String, target: KonanTarget) {
|
|||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
// Run command line from string.
|
// Run command line from string.
|
||||||
fun Array<String>.runCommand(workingDir: File = File("."),
|
fun Array<String>.runCommand(
|
||||||
timeoutAmount: Long = 60,
|
workingDir: File = File("."),
|
||||||
timeoutUnit: TimeUnit = TimeUnit.SECONDS): String {
|
timeoutAmount: Long = 60,
|
||||||
|
timeoutUnit: TimeUnit = TimeUnit.SECONDS
|
||||||
|
): String {
|
||||||
return try {
|
return try {
|
||||||
ProcessBuilder(*this)
|
ProcessBuilder(*this)
|
||||||
.directory(workingDir)
|
.directory(workingDir)
|
||||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||||
.start().apply {
|
.start().apply {
|
||||||
waitFor(timeoutAmount, timeoutUnit)
|
waitFor(timeoutAmount, timeoutUnit)
|
||||||
}.inputStream.bufferedReader().readText()
|
}.inputStream.bufferedReader().readText()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
println("Couldn't run command ${this.joinToString(" ")}")
|
println("Couldn't run command ${this.joinToString(" ")}")
|
||||||
println(e.stackTrace.joinToString("\n"))
|
println(e.stackTrace.joinToString("\n"))
|
||||||
@@ -339,25 +354,25 @@ fun Array<String>.runCommand(workingDir: File = File("."),
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun String.splitCommaSeparatedOption(optionName: String) =
|
fun String.splitCommaSeparatedOption(optionName: String) =
|
||||||
split("\\s*,\\s*".toRegex()).map {
|
split("\\s*,\\s*".toRegex()).map {
|
||||||
if (it.isNotEmpty()) listOf(optionName, it) else listOf(null)
|
if (it.isNotEmpty()) listOf(optionName, it) else listOf(null)
|
||||||
}.flatten().filterNotNull()
|
}.flatten().filterNotNull()
|
||||||
|
|
||||||
data class Commit(val revision: String, val developer: String, val webUrlWithDescription: String)
|
data class Commit(val revision: String, val developer: String, val webUrlWithDescription: String)
|
||||||
|
|
||||||
val teamCityUrl = "https://buildserver.labs.intellij.net"
|
val teamCityUrl = "https://buildserver.labs.intellij.net"
|
||||||
|
|
||||||
fun buildsUrl(buildLocator: String) =
|
fun buildsUrl(buildLocator: String) =
|
||||||
"$teamCityUrl/app/rest/builds/?locator=$buildLocator"
|
"$teamCityUrl/app/rest/builds/?locator=$buildLocator"
|
||||||
|
|
||||||
fun getBuild(buildLocator: String, user: String, password: String) =
|
fun getBuild(buildLocator: String, user: String, password: String) =
|
||||||
try {
|
try {
|
||||||
sendGetRequest(buildsUrl(buildLocator), user, password)
|
sendGetRequest(buildsUrl(buildLocator), user, password)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
error("Try to get build! TeamCity is unreachable!")
|
error("Try to get build! TeamCity is unreachable!")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendGetRequest(url: String, username: String? = null, password: String? = null) : String {
|
fun sendGetRequest(url: String, username: String? = null, password: String? = null): String {
|
||||||
val connection = URL(url).openConnection() as HttpURLConnection
|
val connection = URL(url).openConnection() as HttpURLConnection
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
val auth = Base64.getEncoder().encode(("$username:$password").toByteArray()).toString(Charsets.UTF_8)
|
val auth = Base64.getEncoder().encode(("$username:$password").toByteArray()).toString(Charsets.UTF_8)
|
||||||
@@ -370,8 +385,10 @@ fun sendGetRequest(url: String, username: String? = null, password: String? = nu
|
|||||||
|
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun compileSwift(project: Project, target: KonanTarget, sources: List<String>, options: List<String>,
|
fun compileSwift(
|
||||||
output: Path, fullBitcode: Boolean = false) {
|
project: Project, target: KonanTarget, sources: List<String>, options: List<String>,
|
||||||
|
output: Path, fullBitcode: Boolean = false
|
||||||
|
) {
|
||||||
val platform = project.platformManager.platform(target)
|
val platform = project.platformManager.platform(target)
|
||||||
assert(platform.configurables is AppleConfigurables)
|
assert(platform.configurables is AppleConfigurables)
|
||||||
val configs = platform.configurables as AppleConfigurables
|
val configs = platform.configurables as AppleConfigurables
|
||||||
@@ -385,27 +402,29 @@ fun compileSwift(project: Project, target: KonanTarget, sources: List<String>, o
|
|||||||
|
|
||||||
val (stdOut, stdErr, exitCode) = runProcess(executor = localExecutor(project), executable = compiler, args = args)
|
val (stdOut, stdErr, exitCode) = runProcess(executor = localExecutor(project), executable = compiler, args = args)
|
||||||
|
|
||||||
println("""
|
println(
|
||||||
|
"""
|
||||||
|$compiler finished with exit code: $exitCode
|
|$compiler finished with exit code: $exitCode
|
||||||
|options: ${args.joinToString(separator = " ")}
|
|options: ${args.joinToString(separator = " ")}
|
||||||
|stdout: $stdOut
|
|stdout: $stdOut
|
||||||
|stderr: $stdErr
|
|stderr: $stdErr
|
||||||
""".trimMargin())
|
""".trimMargin()
|
||||||
|
)
|
||||||
check(exitCode == 0) { "Compilation failed" }
|
check(exitCode == 0) { "Compilation failed" }
|
||||||
check(output.toFile().exists()) { "Compiler swiftc hasn't produced an output file: $output" }
|
check(output.toFile().exists()) { "Compiler swiftc hasn't produced an output file: $output" }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun targetSupportsMimallocAllocator(targetName: String) =
|
fun targetSupportsMimallocAllocator(targetName: String) =
|
||||||
HostManager().targetByName(targetName).supportsMimallocAllocator()
|
HostManager().targetByName(targetName).supportsMimallocAllocator()
|
||||||
|
|
||||||
fun targetSupportsLibBacktrace(targetName: String) =
|
fun targetSupportsLibBacktrace(targetName: String) =
|
||||||
HostManager().targetByName(targetName).supportsLibBacktrace()
|
HostManager().targetByName(targetName).supportsLibBacktrace()
|
||||||
|
|
||||||
fun targetSupportsCoreSymbolication(targetName: String) =
|
fun targetSupportsCoreSymbolication(targetName: String) =
|
||||||
HostManager().targetByName(targetName).supportsCoreSymbolication()
|
HostManager().targetByName(targetName).supportsCoreSymbolication()
|
||||||
|
|
||||||
fun targetSupportsThreads(targetName: String) =
|
fun targetSupportsThreads(targetName: String) =
|
||||||
HostManager().targetByName(targetName).supportsThreads()
|
HostManager().targetByName(targetName).supportsThreads()
|
||||||
|
|
||||||
fun Project.mergeManifestsByTargets(source: File, destination: File) {
|
fun Project.mergeManifestsByTargets(source: File, destination: File) {
|
||||||
logger.info("Merging manifests: $source -> $destination")
|
logger.info("Merging manifests: $source -> $destination")
|
||||||
@@ -418,29 +437,29 @@ fun Project.mergeManifestsByTargets(source: File, destination: File) {
|
|||||||
|
|
||||||
// check that all properties except for KLIB_PROPERTY_NATIVE_TARGETS are equivalent
|
// check that all properties except for KLIB_PROPERTY_NATIVE_TARGETS are equivalent
|
||||||
val mismatchedProperties = (sourceProperties.keys + destinationProperties.keys)
|
val mismatchedProperties = (sourceProperties.keys + destinationProperties.keys)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { it.toString() }
|
.map { it.toString() }
|
||||||
.filter { it != KLIB_PROPERTY_NATIVE_TARGETS }
|
.filter { it != KLIB_PROPERTY_NATIVE_TARGETS }
|
||||||
.sorted()
|
.sorted()
|
||||||
.mapNotNull { propertyKey: String ->
|
.mapNotNull { propertyKey: String ->
|
||||||
val sourceProperty: String? = sourceProperties.getProperty(propertyKey)
|
val sourceProperty: String? = sourceProperties.getProperty(propertyKey)
|
||||||
val destinationProperty: String? = destinationProperties.getProperty(propertyKey)
|
val destinationProperty: String? = destinationProperties.getProperty(propertyKey)
|
||||||
when {
|
when {
|
||||||
sourceProperty == null -> "\"$propertyKey\" is absent in $sourceFile"
|
sourceProperty == null -> "\"$propertyKey\" is absent in $sourceFile"
|
||||||
destinationProperty == null -> "\"$propertyKey\" is absent in $destinationFile"
|
destinationProperty == null -> "\"$propertyKey\" is absent in $destinationFile"
|
||||||
sourceProperty == destinationProperty -> {
|
sourceProperty == destinationProperty -> {
|
||||||
// properties match, OK
|
// properties match, OK
|
||||||
null
|
null
|
||||||
}
|
|
||||||
sourceProperties.propertyList(propertyKey, escapeInQuotes = true).toSet() ==
|
|
||||||
destinationProperties.propertyList(propertyKey, escapeInQuotes = true).toSet() -> {
|
|
||||||
// properties match, OK
|
|
||||||
null
|
|
||||||
}
|
|
||||||
else -> "\"$propertyKey\" differ: [$sourceProperty] vs [$destinationProperty]"
|
|
||||||
}
|
}
|
||||||
|
sourceProperties.propertyList(propertyKey, escapeInQuotes = true).toSet() ==
|
||||||
|
destinationProperties.propertyList(propertyKey, escapeInQuotes = true).toSet() -> {
|
||||||
|
// properties match, OK
|
||||||
|
null
|
||||||
|
}
|
||||||
|
else -> "\"$propertyKey\" differ: [$sourceProperty] vs [$destinationProperty]"
|
||||||
}
|
}
|
||||||
.toList()
|
}
|
||||||
|
.toList()
|
||||||
|
|
||||||
check(mismatchedProperties.isEmpty()) {
|
check(mismatchedProperties.isEmpty()) {
|
||||||
buildString {
|
buildString {
|
||||||
@@ -478,10 +497,10 @@ fun Project.buildStaticLibrary(cSources: Collection<File>, output: File, objDir:
|
|||||||
output.parentFile.mkdirs()
|
output.parentFile.mkdirs()
|
||||||
exec {
|
exec {
|
||||||
commandLine(
|
commandLine(
|
||||||
"${platform.configurables.absoluteLlvmHome}/bin/llvm-ar",
|
"${platform.configurables.absoluteLlvmHome}/bin/llvm-ar",
|
||||||
"-rc",
|
"-rc",
|
||||||
output,
|
output,
|
||||||
*fileTree(objDir).files.toTypedArray()
|
*fileTree(objDir).files.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-4
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.konan.target.PlatformManager
|
|||||||
import org.jetbrains.kotlin.konan.target.SanitizerKind
|
import org.jetbrains.kotlin.konan.target.SanitizerKind
|
||||||
import org.jetbrains.kotlin.konan.target.supportedSanitizers
|
import org.jetbrains.kotlin.konan.target.supportedSanitizers
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,9 +54,12 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
|||||||
val sanitizers: List<SanitizerKind?> = target.supportedSanitizers() + listOf(null)
|
val sanitizers: List<SanitizerKind?> = target.supportedSanitizers() + listOf(null)
|
||||||
sanitizers.forEach { sanitizer ->
|
sanitizers.forEach { sanitizer ->
|
||||||
project.tasks.register(
|
project.tasks.register(
|
||||||
"${targetName}${name.snakeCaseToCamelCase().capitalize()}${suffixForSanitizer(sanitizer)}",
|
"${targetName}${
|
||||||
CompileToBitcode::class.java,
|
name.snakeCaseToCamelCase()
|
||||||
name, targetName, outputGroup
|
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||||
|
}${suffixForSanitizer(sanitizer)}",
|
||||||
|
CompileToBitcode::class.java,
|
||||||
|
name, targetName, outputGroup
|
||||||
).configure {
|
).configure {
|
||||||
srcDirs = project.files(srcRoot.resolve("cpp"))
|
srcDirs = project.files(srcRoot.resolve("cpp"))
|
||||||
headersDirs = srcDirs + project.files(srcRoot.resolve("headers"))
|
headersDirs = srcDirs + project.files(srcRoot.resolve("headers"))
|
||||||
@@ -78,7 +82,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private fun String.snakeCaseToCamelCase() =
|
private fun String.snakeCaseToCamelCase() =
|
||||||
split('_').joinToString(separator = "") { it.capitalize() }
|
split('_').joinToString(separator = "") { it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }
|
||||||
|
|
||||||
fun suffixForSanitizer(sanitizer: SanitizerKind?) =
|
fun suffixForSanitizer(sanitizer: SanitizerKind?) =
|
||||||
when (sanitizer) {
|
when (sanitizer) {
|
||||||
|
|||||||
+5
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.gradle.plugin.konan
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.ProjectProperty
|
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.ProjectProperty
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin allows an IDE to specify some building parameters. These parameters
|
* The plugin allows an IDE to specify some building parameters. These parameters
|
||||||
@@ -64,10 +65,10 @@ internal class EnvironmentVariablesImpl(val project: Project): EnvironmentVaria
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val debuggingSymbols: Boolean
|
override val debuggingSymbols: Boolean
|
||||||
get() = System.getenv("DEBUGGING_SYMBOLS")?.toUpperCase() == "YES"
|
get() = System.getenv("DEBUGGING_SYMBOLS")?.uppercase(Locale.getDefault()) == "YES"
|
||||||
|
|
||||||
override val enableOptimizations: Boolean
|
override val enableOptimizations: Boolean
|
||||||
get() = System.getenv("KONAN_ENABLE_OPTIMIZATIONS")?.toUpperCase() == "YES"
|
get() = System.getenv("KONAN_ENABLE_OPTIMIZATIONS")?.uppercase(Locale.getDefault()) == "YES"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,12 +83,12 @@ internal class EnvironmentVariablesFromProperties(val project: Project): Environ
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val debuggingSymbols: Boolean
|
override val debuggingSymbols: Boolean
|
||||||
get() = project.findProperty(ProjectProperty.KONAN_DEBUGGING_SYMBOLS)?.toString()?.toUpperCase().let {
|
get() = project.findProperty(ProjectProperty.KONAN_DEBUGGING_SYMBOLS)?.toString()?.uppercase(Locale.getDefault()).let {
|
||||||
it == "YES" || it == "TRUE"
|
it == "YES" || it == "TRUE"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val enableOptimizations: Boolean
|
override val enableOptimizations: Boolean
|
||||||
get() = project.findProperty(ProjectProperty.KONAN_OPTIMIZATIONS_ENABLE)?.toString()?.toUpperCase().let {
|
get() = project.findProperty(ProjectProperty.KONAN_OPTIMIZATIONS_ENABLE)?.toString()?.uppercase(Locale.getDefault()).let {
|
||||||
it == "YES" || it == "TRUE"
|
it == "YES" || it == "TRUE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-3
@@ -29,6 +29,8 @@ import org.gradle.api.tasks.TaskProvider
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanBuildingTask
|
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanBuildingTask
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.NoSuchElementException
|
||||||
|
|
||||||
/** Base class for all Kotlin/Native artifacts. */
|
/** Base class for all Kotlin/Native artifacts. */
|
||||||
abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||||
@@ -79,13 +81,25 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected open fun generateTaskName(target: KonanTarget) =
|
protected open fun generateTaskName(target: KonanTarget) =
|
||||||
"compileKonan${name.capitalize()}${target.visibleName.capitalize()}"
|
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}${
|
||||||
|
target.visibleName.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(
|
||||||
|
Locale.getDefault()
|
||||||
|
) else it.toString()
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
|
||||||
protected open fun generateAggregateTaskName() =
|
protected open fun generateAggregateTaskName() =
|
||||||
"compileKonan${name.capitalize()}"
|
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
|
||||||
|
|
||||||
protected open fun generateTargetAliasTaskName(targetName: String) =
|
protected open fun generateTargetAliasTaskName(targetName: String) =
|
||||||
"compileKonan${name.capitalize()}${targetName.capitalize()}"
|
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}${
|
||||||
|
targetName.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(
|
||||||
|
Locale.getDefault()
|
||||||
|
) else it.toString()
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
|
||||||
protected abstract fun generateTaskDescription(task: T): String
|
protected abstract fun generateTaskDescription(task: T): String
|
||||||
protected abstract fun generateAggregateTaskDescription(task: Task): String
|
protected abstract fun generateAggregateTaskDescription(task: Task): String
|
||||||
|
|||||||
+9
-1
@@ -52,6 +52,7 @@ import org.jetbrains.kotlin.konan.target.customerDistribution
|
|||||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||||
import org.jetbrains.kotlin.*
|
import org.jetbrains.kotlin.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -394,7 +395,14 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
|||||||
.forEach { task ->
|
.forEach { task ->
|
||||||
val isCrossCompile = (task.target != HostManager.host.visibleName)
|
val isCrossCompile = (task.target != HostManager.host.visibleName)
|
||||||
if (!isCrossCompile && !project.hasProperty("konanNoRun"))
|
if (!isCrossCompile && !project.hasProperty("konanNoRun"))
|
||||||
task.runTask = project.tasks.register("run${task.artifactName.capitalize()}", Exec::class.java) {
|
task.runTask = project.tasks.register(
|
||||||
|
"run${
|
||||||
|
task.artifactName.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(
|
||||||
|
Locale.getDefault()
|
||||||
|
) else it.toString()
|
||||||
|
}
|
||||||
|
}", Exec::class.java) {
|
||||||
group= "run"
|
group= "run"
|
||||||
dependsOn(task)
|
dependsOn(task)
|
||||||
val artifactPathClosure = object : Closure<String>(this) {
|
val artifactPathClosure = object : Closure<String>(this) {
|
||||||
|
|||||||
+2
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.gradle.kpm.external.createExternalJvmVariant
|
|||||||
import org.jetbrains.kotlin.gradle.kpm.external.external
|
import org.jetbrains.kotlin.gradle.kpm.external.external
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
||||||
val androidOutgoingArtifacts = FragmentArtifacts<KotlinJvmVariant> {
|
val androidOutgoingArtifacts = FragmentArtifacts<KotlinJvmVariant> {
|
||||||
@@ -44,7 +45,7 @@ fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val kotlinVariant = createExternalJvmVariant(
|
val kotlinVariant = createExternalJvmVariant(
|
||||||
"android${androidVariant.buildType.name.capitalize()}", KotlinJvmVariantConfig(
|
"android${androidVariant.buildType.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}", KotlinJvmVariantConfig(
|
||||||
/* Only swap out configuration that is used. Default setup shall still be applied */
|
/* Only swap out configuration that is used. Default setup shall still be applied */
|
||||||
compileDependencies = (DefaultKotlinCompileDependenciesDefinition +
|
compileDependencies = (DefaultKotlinCompileDependenciesDefinition +
|
||||||
FragmentAttributes<KotlinGradleFragment> {
|
FragmentAttributes<KotlinGradleFragment> {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import org.jetbrains.kotlin.pill.model.PSourceRoot.*
|
|||||||
import org.jetbrains.kotlin.pill.PillExtensionMirror.*
|
import org.jetbrains.kotlin.pill.PillExtensionMirror.*
|
||||||
import org.jetbrains.kotlin.pill.model.*
|
import org.jetbrains.kotlin.pill.model.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.HashMap
|
||||||
|
|
||||||
typealias OutputDir = String
|
typealias OutputDir = String
|
||||||
typealias GradleProjectPath = String
|
typealias GradleProjectPath = String
|
||||||
@@ -104,7 +106,9 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String
|
|||||||
private fun findEmbeddableTask(project: Project, sourceSet: SourceSet): Jar? {
|
private fun findEmbeddableTask(project: Project, sourceSet: SourceSet): Jar? {
|
||||||
val jarName = sourceSet.jarTaskName
|
val jarName = sourceSet.jarTaskName
|
||||||
val embeddable = "embeddable"
|
val embeddable = "embeddable"
|
||||||
val embeddedName = if (jarName == "jar") embeddable else jarName.dropLast("jar".length) + embeddable.capitalize()
|
val embeddedName = if (jarName == "jar") embeddable else jarName.dropLast("jar".length) + embeddable.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
|
||||||
|
}
|
||||||
return project.tasks.findByName(embeddedName) as? Jar
|
return project.tasks.findByName(embeddedName) as? Jar
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +261,9 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String
|
|||||||
val isMainSourceSet = sourceSet.name == SourceSet.MAIN_SOURCE_SET_NAME
|
val isMainSourceSet = sourceSet.name == SourceSet.MAIN_SOURCE_SET_NAME
|
||||||
|
|
||||||
val taskNameBase = "processResources"
|
val taskNameBase = "processResources"
|
||||||
val taskName = if (isMainSourceSet) taskNameBase else sourceSet.name + taskNameBase.capitalize()
|
val taskName = if (isMainSourceSet) taskNameBase else sourceSet.name + taskNameBase.replaceFirstChar {
|
||||||
|
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
|
||||||
|
}
|
||||||
val task = project.tasks.findByName(taskName) as? ProcessResources ?: return emptyList()
|
val task = project.tasks.findByName(taskName) as? ProcessResources ?: return emptyList()
|
||||||
|
|
||||||
val roots = mutableListOf<File>()
|
val roots = mutableListOf<File>()
|
||||||
|
|||||||
Reference in New Issue
Block a user