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 plugins.configureDefaultPublishing
|
||||
import plugins.configureKotlinPomAttributes
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 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
|
||||
// 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 {
|
||||
moduleName = "${this@createGradleCommonSourceSet.name}_${commonSourceSet.name}"
|
||||
}
|
||||
@@ -357,7 +358,14 @@ fun Project.createGradlePluginVariant(
|
||||
|
||||
if (kotlinBuildProperties.publishGradlePluginsJavadoc) {
|
||||
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"
|
||||
|
||||
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
|
||||
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 {
|
||||
moduleName = this@createGradlePluginVariant.name
|
||||
}
|
||||
@@ -462,7 +470,7 @@ fun Project.publishShadowedJar(
|
||||
val jarTask = tasks.named<Jar>(sourceSet.jarTaskName)
|
||||
|
||||
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(
|
||||
jarTask.flatMap { it.archiveBaseName },
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import java.util.*
|
||||
|
||||
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
|
||||
|
||||
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.Path
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 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")
|
||||
FileWriter(provider.toFile()).use { writer ->
|
||||
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" }
|
||||
|
||||
writer.write("""
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.Base64
|
||||
import java.nio.file.Path
|
||||
import org.jetbrains.kotlin.konan.file.File as KFile
|
||||
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 java.io.ByteArrayOutputStream
|
||||
import java.net.URI
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
//region Project properties.
|
||||
|
||||
@@ -63,7 +64,7 @@ val Project.testTarget
|
||||
get() = findProperty("target") as? KonanTarget ?: HostManager.host
|
||||
|
||||
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
|
||||
get() = hasProperty("test_verbose")
|
||||
@@ -89,15 +90,17 @@ val Project.cacheRedirectorEnabled
|
||||
val Project.compileOnlyTests: Boolean
|
||||
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)
|
||||
"https://cache-redirector.jetbrains.com/${base.host}/${base.path}"
|
||||
} else
|
||||
url
|
||||
|
||||
val validPropertiesNames = listOf("konan.home",
|
||||
"org.jetbrains.kotlin.native.home",
|
||||
"kotlin.native.home")
|
||||
val validPropertiesNames = listOf(
|
||||
"konan.home",
|
||||
"org.jetbrains.kotlin.native.home",
|
||||
"kotlin.native.home"
|
||||
)
|
||||
|
||||
val Project.kotlinNativeDist
|
||||
get() = rootProject.currentKotlinNativeDist
|
||||
@@ -137,10 +140,10 @@ fun Task.dependsOnPlatformLibs() {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private fun Project.groovyPropertyArrayToList(property: String): List<String> =
|
||||
with(findProperty(property)) {
|
||||
if (this is Array<*>) this.toList() as List<String>
|
||||
else this as List<String>
|
||||
}
|
||||
with(findProperty(property)) {
|
||||
if (this is Array<*>) this.toList() as List<String>
|
||||
else this as List<String>
|
||||
}
|
||||
|
||||
val Project.globalBuildArgs: List<String>
|
||||
get() = project.groovyPropertyArrayToList("globalBuildArgs")
|
||||
@@ -166,9 +169,12 @@ fun projectOrFiles(proj: Project, notation: String): Any? {
|
||||
*/
|
||||
fun codesign(project: Project, path: String) {
|
||||
check(HostManager.hostIsMac) { "Apple specific code signing" }
|
||||
val (stdOut, stdErr, exitCode) = runProcess(executor = localExecutor(project), executable = "/usr/bin/codesign",
|
||||
args = listOf("--verbose", "-s", "-", path))
|
||||
check(exitCode == 0) { """
|
||||
val (stdOut, stdErr, exitCode) = runProcess(
|
||||
executor = localExecutor(project), executable = "/usr/bin/codesign",
|
||||
args = listOf("--verbose", "-s", "-", path)
|
||||
)
|
||||
check(exitCode == 0) {
|
||||
"""
|
||||
|Codesign failed with exitCode: $exitCode
|
||||
|stdout: $stdOut
|
||||
|stderr: $stdErr
|
||||
@@ -198,17 +204,24 @@ fun Project.getFilesToCompile(compile: List<String>, exclude: List<String>): Lis
|
||||
// create list of tests to compile
|
||||
return compile.flatMap { f ->
|
||||
project.file(f)
|
||||
.walk()
|
||||
.filter { it.isFile && it.name.endsWith(".kt") && !excludeFiles.contains(it.absolutePath) }
|
||||
.map{ it.absolutePath }
|
||||
.asIterable()
|
||||
.walk()
|
||||
.filter { it.isFile && it.name.endsWith(".kt") && !excludeFiles.contains(it.absolutePath) }
|
||||
.map { it.absolutePath }
|
||||
.asIterable()
|
||||
}
|
||||
}
|
||||
|
||||
//region Task dependency.
|
||||
|
||||
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) {
|
||||
project.tasks.getByName(taskName).dependsOnDist()
|
||||
@@ -234,7 +247,7 @@ private val Project.hasPlatformLibs: Boolean
|
||||
get() {
|
||||
if (!isDefaultNativeHome) {
|
||||
return File(buildDistribution(project.kotlinNativeDist.absolutePath).platformLibs(project.testTarget))
|
||||
.exists()
|
||||
.exists()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -243,7 +256,7 @@ private val Project.isCrossDist: Boolean
|
||||
get() {
|
||||
if (!isDefaultNativeHome) {
|
||||
return File(buildDistribution(project.kotlinNativeDist.absolutePath).runtime(project.testTarget))
|
||||
.exists()
|
||||
.exists()
|
||||
}
|
||||
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)
|
||||
dependsOn.forEach{
|
||||
dependsOn.forEach {
|
||||
val task = (it as? Task) ?: return@forEach
|
||||
if (task.name.startsWith("compileKonan"))
|
||||
task.konanOldPluginTaskDependenciesWalker(index + 1, walker)
|
||||
@@ -320,17 +333,19 @@ fun Task.dependsOnKonanBuildingTask(artifact: String, target: KonanTarget) {
|
||||
|
||||
//endregion
|
||||
// Run command line from string.
|
||||
fun Array<String>.runCommand(workingDir: File = File("."),
|
||||
timeoutAmount: Long = 60,
|
||||
timeoutUnit: TimeUnit = TimeUnit.SECONDS): String {
|
||||
fun Array<String>.runCommand(
|
||||
workingDir: File = File("."),
|
||||
timeoutAmount: Long = 60,
|
||||
timeoutUnit: TimeUnit = TimeUnit.SECONDS
|
||||
): String {
|
||||
return try {
|
||||
ProcessBuilder(*this)
|
||||
.directory(workingDir)
|
||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||
.start().apply {
|
||||
waitFor(timeoutAmount, timeoutUnit)
|
||||
}.inputStream.bufferedReader().readText()
|
||||
.directory(workingDir)
|
||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||
.start().apply {
|
||||
waitFor(timeoutAmount, timeoutUnit)
|
||||
}.inputStream.bufferedReader().readText()
|
||||
} catch (e: Exception) {
|
||||
println("Couldn't run command ${this.joinToString(" ")}")
|
||||
println(e.stackTrace.joinToString("\n"))
|
||||
@@ -339,25 +354,25 @@ fun Array<String>.runCommand(workingDir: File = File("."),
|
||||
}
|
||||
|
||||
fun String.splitCommaSeparatedOption(optionName: String) =
|
||||
split("\\s*,\\s*".toRegex()).map {
|
||||
if (it.isNotEmpty()) listOf(optionName, it) else listOf(null)
|
||||
}.flatten().filterNotNull()
|
||||
split("\\s*,\\s*".toRegex()).map {
|
||||
if (it.isNotEmpty()) listOf(optionName, it) else listOf(null)
|
||||
}.flatten().filterNotNull()
|
||||
|
||||
data class Commit(val revision: String, val developer: String, val webUrlWithDescription: String)
|
||||
|
||||
val teamCityUrl = "https://buildserver.labs.intellij.net"
|
||||
|
||||
fun buildsUrl(buildLocator: String) =
|
||||
"$teamCityUrl/app/rest/builds/?locator=$buildLocator"
|
||||
"$teamCityUrl/app/rest/builds/?locator=$buildLocator"
|
||||
|
||||
fun getBuild(buildLocator: String, user: String, password: String) =
|
||||
try {
|
||||
sendGetRequest(buildsUrl(buildLocator), user, password)
|
||||
} catch (t: Throwable) {
|
||||
error("Try to get build! TeamCity is unreachable!")
|
||||
}
|
||||
try {
|
||||
sendGetRequest(buildsUrl(buildLocator), user, password)
|
||||
} catch (t: Throwable) {
|
||||
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
|
||||
if (username != null && password != null) {
|
||||
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
|
||||
fun compileSwift(project: Project, target: KonanTarget, sources: List<String>, options: List<String>,
|
||||
output: Path, fullBitcode: Boolean = false) {
|
||||
fun compileSwift(
|
||||
project: Project, target: KonanTarget, sources: List<String>, options: List<String>,
|
||||
output: Path, fullBitcode: Boolean = false
|
||||
) {
|
||||
val platform = project.platformManager.platform(target)
|
||||
assert(platform.configurables is 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)
|
||||
|
||||
println("""
|
||||
println(
|
||||
"""
|
||||
|$compiler finished with exit code: $exitCode
|
||||
|options: ${args.joinToString(separator = " ")}
|
||||
|stdout: $stdOut
|
||||
|stderr: $stdErr
|
||||
""".trimMargin())
|
||||
""".trimMargin()
|
||||
)
|
||||
check(exitCode == 0) { "Compilation failed" }
|
||||
check(output.toFile().exists()) { "Compiler swiftc hasn't produced an output file: $output" }
|
||||
}
|
||||
|
||||
fun targetSupportsMimallocAllocator(targetName: String) =
|
||||
HostManager().targetByName(targetName).supportsMimallocAllocator()
|
||||
HostManager().targetByName(targetName).supportsMimallocAllocator()
|
||||
|
||||
fun targetSupportsLibBacktrace(targetName: String) =
|
||||
HostManager().targetByName(targetName).supportsLibBacktrace()
|
||||
HostManager().targetByName(targetName).supportsLibBacktrace()
|
||||
|
||||
fun targetSupportsCoreSymbolication(targetName: String) =
|
||||
HostManager().targetByName(targetName).supportsCoreSymbolication()
|
||||
HostManager().targetByName(targetName).supportsCoreSymbolication()
|
||||
|
||||
fun targetSupportsThreads(targetName: String) =
|
||||
HostManager().targetByName(targetName).supportsThreads()
|
||||
HostManager().targetByName(targetName).supportsThreads()
|
||||
|
||||
fun Project.mergeManifestsByTargets(source: File, destination: File) {
|
||||
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
|
||||
val mismatchedProperties = (sourceProperties.keys + destinationProperties.keys)
|
||||
.asSequence()
|
||||
.map { it.toString() }
|
||||
.filter { it != KLIB_PROPERTY_NATIVE_TARGETS }
|
||||
.sorted()
|
||||
.mapNotNull { propertyKey: String ->
|
||||
val sourceProperty: String? = sourceProperties.getProperty(propertyKey)
|
||||
val destinationProperty: String? = destinationProperties.getProperty(propertyKey)
|
||||
when {
|
||||
sourceProperty == null -> "\"$propertyKey\" is absent in $sourceFile"
|
||||
destinationProperty == null -> "\"$propertyKey\" is absent in $destinationFile"
|
||||
sourceProperty == destinationProperty -> {
|
||||
// properties match, OK
|
||||
null
|
||||
}
|
||||
sourceProperties.propertyList(propertyKey, escapeInQuotes = true).toSet() ==
|
||||
destinationProperties.propertyList(propertyKey, escapeInQuotes = true).toSet() -> {
|
||||
// properties match, OK
|
||||
null
|
||||
}
|
||||
else -> "\"$propertyKey\" differ: [$sourceProperty] vs [$destinationProperty]"
|
||||
.asSequence()
|
||||
.map { it.toString() }
|
||||
.filter { it != KLIB_PROPERTY_NATIVE_TARGETS }
|
||||
.sorted()
|
||||
.mapNotNull { propertyKey: String ->
|
||||
val sourceProperty: String? = sourceProperties.getProperty(propertyKey)
|
||||
val destinationProperty: String? = destinationProperties.getProperty(propertyKey)
|
||||
when {
|
||||
sourceProperty == null -> "\"$propertyKey\" is absent in $sourceFile"
|
||||
destinationProperty == null -> "\"$propertyKey\" is absent in $destinationFile"
|
||||
sourceProperty == destinationProperty -> {
|
||||
// properties match, OK
|
||||
null
|
||||
}
|
||||
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()) {
|
||||
buildString {
|
||||
@@ -478,10 +497,10 @@ fun Project.buildStaticLibrary(cSources: Collection<File>, output: File, objDir:
|
||||
output.parentFile.mkdirs()
|
||||
exec {
|
||||
commandLine(
|
||||
"${platform.configurables.absoluteLlvmHome}/bin/llvm-ar",
|
||||
"-rc",
|
||||
output,
|
||||
*fileTree(objDir).files.toTypedArray()
|
||||
"${platform.configurables.absoluteLlvmHome}/bin/llvm-ar",
|
||||
"-rc",
|
||||
output,
|
||||
*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.supportedSanitizers
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -53,9 +54,12 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
val sanitizers: List<SanitizerKind?> = target.supportedSanitizers() + listOf(null)
|
||||
sanitizers.forEach { sanitizer ->
|
||||
project.tasks.register(
|
||||
"${targetName}${name.snakeCaseToCamelCase().capitalize()}${suffixForSanitizer(sanitizer)}",
|
||||
CompileToBitcode::class.java,
|
||||
name, targetName, outputGroup
|
||||
"${targetName}${
|
||||
name.snakeCaseToCamelCase()
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||
}${suffixForSanitizer(sanitizer)}",
|
||||
CompileToBitcode::class.java,
|
||||
name, targetName, outputGroup
|
||||
).configure {
|
||||
srcDirs = project.files(srcRoot.resolve("cpp"))
|
||||
headersDirs = srcDirs + project.files(srcRoot.resolve("headers"))
|
||||
@@ -78,7 +82,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
companion object {
|
||||
|
||||
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?) =
|
||||
when (sanitizer) {
|
||||
|
||||
+5
-4
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.gradle.plugin.konan
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.ProjectProperty
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 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
|
||||
get() = System.getenv("DEBUGGING_SYMBOLS")?.toUpperCase() == "YES"
|
||||
get() = System.getenv("DEBUGGING_SYMBOLS")?.uppercase(Locale.getDefault()) == "YES"
|
||||
|
||||
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
|
||||
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"
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
+17
-3
@@ -29,6 +29,8 @@ import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.KonanBuildingTask
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.NoSuchElementException
|
||||
|
||||
/** Base class for all Kotlin/Native artifacts. */
|
||||
abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||
@@ -79,13 +81,25 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||
}
|
||||
|
||||
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() =
|
||||
"compileKonan${name.capitalize()}"
|
||||
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
|
||||
|
||||
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 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.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -394,7 +395,14 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
.forEach { task ->
|
||||
val isCrossCompile = (task.target != HostManager.host.visibleName)
|
||||
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"
|
||||
dependsOn(task)
|
||||
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.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||
import java.util.*
|
||||
|
||||
fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
||||
val androidOutgoingArtifacts = FragmentArtifacts<KotlinJvmVariant> {
|
||||
@@ -44,7 +45,7 @@ fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
||||
}
|
||||
|
||||
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 */
|
||||
compileDependencies = (DefaultKotlinCompileDependenciesDefinition +
|
||||
FragmentAttributes<KotlinGradleFragment> {
|
||||
|
||||
@@ -28,6 +28,8 @@ import org.jetbrains.kotlin.pill.model.PSourceRoot.*
|
||||
import org.jetbrains.kotlin.pill.PillExtensionMirror.*
|
||||
import org.jetbrains.kotlin.pill.model.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
typealias OutputDir = 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? {
|
||||
val jarName = sourceSet.jarTaskName
|
||||
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
|
||||
}
|
||||
|
||||
@@ -257,7 +261,9 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String
|
||||
val isMainSourceSet = sourceSet.name == SourceSet.MAIN_SOURCE_SET_NAME
|
||||
|
||||
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 roots = mutableListOf<File>()
|
||||
|
||||
Reference in New Issue
Block a user