[K/N] Remove more ext properties
This commit is contained in:
committed by
Space Team
parent
23710ac133
commit
adf5331ff0
@@ -130,5 +130,9 @@ gradlePlugin {
|
||||
id = "native-dependencies"
|
||||
implementationClass = "org.jetbrains.kotlin.dependencies.NativeDependenciesPlugin"
|
||||
}
|
||||
create("platformManager") {
|
||||
id = "platform-manager"
|
||||
implementationClass = "org.jetbrains.kotlin.PlatformManagerPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -170,7 +170,7 @@ class NamedNativeInteropConfig implements Named {
|
||||
this.project = project
|
||||
this.flavor = flavor
|
||||
|
||||
def platformManager = project.project(":kotlin-native").ext.platformManager
|
||||
def platformManager = project.extensions.platformManager
|
||||
def targetManager = platformManager.targetManager(target)
|
||||
this.target = targetManager.targetName
|
||||
|
||||
@@ -304,6 +304,7 @@ class NativeInteropPlugin implements Plugin<Project> {
|
||||
|
||||
@Override
|
||||
void apply(Project prj) {
|
||||
prj.plugins.apply("platform-manager")
|
||||
prj.plugins.apply("native-dependencies")
|
||||
|
||||
prj.extensions.add("kotlinNativeInterop", new NativeInteropExtension(prj))
|
||||
|
||||
@@ -161,12 +161,6 @@ abstract class ExecClang @Inject constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(project: Project): ExecClang = create(
|
||||
project.objects,
|
||||
project.project(":kotlin-native").findProperty("platformManager") as PlatformManager,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun create(objects: ObjectFactory, platformManager: PlatformManager) =
|
||||
objects.newInstance(ExecClang::class.java, platformManager)
|
||||
|
||||
@@ -32,7 +32,7 @@ object PlatformInfo {
|
||||
|
||||
@JvmStatic
|
||||
fun getTarget(project: Project): KonanTarget {
|
||||
val platformManager = project.project(":kotlin-native").platformManager
|
||||
val platformManager = project.platformManager
|
||||
val targetName = project.project.testTarget.name
|
||||
return platformManager.targetManager(targetName).target
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import kotlinBuildProperties
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
open class PlatformManagerPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
val konanDataDir = project.kotlinBuildProperties.getOrNull("konan.data.dir") as String?
|
||||
val platformManager = PlatformManager(buildDistribution(project.project(":kotlin-native").projectDir.absolutePath, konanDataDir), false)
|
||||
project.extensions.add("platformManager", platformManager)
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.plugins.ExtraPropertiesExtension
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
@@ -25,7 +26,7 @@ private const val KLIB_PROPERTY_COMPILER_VERSION = "compiler_version"
|
||||
//region Project properties.
|
||||
|
||||
val Project.platformManager
|
||||
get() = findProperty("platformManager") as PlatformManager
|
||||
get() = extensions.getByType<PlatformManager>()
|
||||
|
||||
val Project.testTarget
|
||||
get() = findProperty("target") as? KonanTarget ?: HostManager.host
|
||||
@@ -331,7 +332,7 @@ fun Project.buildStaticLibrary(cSources: Collection<File>, output: File, objDir:
|
||||
val platform = platformManager.platform(testTarget)
|
||||
|
||||
objDir.mkdirs()
|
||||
ExecClang.create(project).execClangForCompilerTests(testTarget) {
|
||||
ExecClang.create(project.objects, project.platformManager).execClangForCompilerTests(testTarget) {
|
||||
args = listOf("-c", *cSources.map { it.absolutePath }.toTypedArray())
|
||||
workingDir(objDir)
|
||||
}
|
||||
|
||||
+5
-5
@@ -21,6 +21,7 @@ import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.jetbrains.kotlin.ExecClang
|
||||
import org.jetbrains.kotlin.PlatformManagerPlugin
|
||||
import org.jetbrains.kotlin.cpp.*
|
||||
import org.jetbrains.kotlin.dependencies.NativeDependenciesExtension
|
||||
import org.jetbrains.kotlin.dependencies.NativeDependenciesPlugin
|
||||
@@ -29,6 +30,7 @@ import org.jetbrains.kotlin.konan.target.PlatformManager
|
||||
import org.jetbrains.kotlin.konan.target.SanitizerKind
|
||||
import org.jetbrains.kotlin.konan.target.TargetDomainObjectContainer
|
||||
import org.jetbrains.kotlin.konan.target.TargetWithSanitizer
|
||||
import org.jetbrains.kotlin.konan.target.enabledTargets
|
||||
import org.jetbrains.kotlin.testing.native.GoogleTestExtension
|
||||
import org.jetbrains.kotlin.utils.capitalized
|
||||
import java.time.Duration
|
||||
@@ -139,13 +141,10 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
||||
"-Wno-unused-parameter", // False positives with polymorphic functions.
|
||||
)
|
||||
|
||||
private val targetList = with(project) {
|
||||
provider { (rootProject.project(":kotlin-native").property("targetList") as? List<*>)?.filterIsInstance<String>() ?: emptyList() } // TODO: Can we make it better?
|
||||
}
|
||||
|
||||
private val allTestsTasks by lazy {
|
||||
val name = project.name.capitalized
|
||||
targetList.get().associateBy(keySelector = { it }, valueTransform = {
|
||||
val platformManager = project.extensions.getByType<PlatformManager>()
|
||||
enabledTargets(platformManager).associateBy(keySelector = { it.visibleName }, valueTransform = {
|
||||
project.tasks.register("${it}${name}Tests") {
|
||||
description = "Runs all $name tests for $it"
|
||||
group = VERIFICATION_TASK_GROUP
|
||||
@@ -670,6 +669,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
||||
*/
|
||||
open class CompileToBitcodePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.apply<PlatformManagerPlugin>()
|
||||
project.apply<CppConsumerPlugin>()
|
||||
project.apply<CompilationDatabasePlugin>()
|
||||
project.apply<GitClangFormatPlugin>()
|
||||
|
||||
+3
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.cpp
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.PlatformManagerPlugin
|
||||
import org.jetbrains.kotlin.dependencies.NativeDependenciesExtension
|
||||
import org.jetbrains.kotlin.dependencies.NativeDependenciesPlugin
|
||||
|
||||
@@ -16,6 +17,7 @@ import org.jetbrains.kotlin.dependencies.NativeDependenciesPlugin
|
||||
*/
|
||||
open class GitClangFormatPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
target.apply<PlatformManagerPlugin>()
|
||||
target.apply<NativeDependenciesPlugin>()
|
||||
val nativeDependencies = target.extensions.getByType<NativeDependenciesExtension>()
|
||||
|
||||
@@ -35,4 +37,4 @@ open class GitClangFormatPlugin : Plugin<Project> {
|
||||
@JvmStatic
|
||||
val TASK_GROUP = "development support"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,4 +61,4 @@ abstract class NativeDependenciesDownloader : DefaultTask() {
|
||||
dependencyProcessor.showInfo = logger.isEnabled(LogLevel.INFO)
|
||||
dependencyProcessor.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -13,6 +13,7 @@ import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.PlatformManagerPlugin
|
||||
import org.jetbrains.kotlin.konan.properties.KonanPropertiesLoader
|
||||
import org.jetbrains.kotlin.konan.target.PlatformManager
|
||||
import org.jetbrains.kotlin.konan.target.TargetDomainObjectContainer
|
||||
@@ -166,7 +167,8 @@ abstract class NativeDependenciesDownloaderExtension @Inject constructor(private
|
||||
*/
|
||||
open class NativeDependenciesDownloaderPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.apply<PlatformManagerPlugin>()
|
||||
project.apply<NativeDependenciesBasePlugin>()
|
||||
project.extensions.create<NativeDependenciesDownloaderExtension>("nativeDependenciesDownloader", project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -12,6 +12,7 @@ import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.PlatformManagerPlugin
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
@@ -137,7 +138,8 @@ abstract class NativeDependenciesExtension @Inject constructor(private val proje
|
||||
*/
|
||||
class NativeDependenciesPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.apply<PlatformManagerPlugin>()
|
||||
project.apply<NativeDependenciesBasePlugin>()
|
||||
project.extensions.create<NativeDependenciesExtension>("nativeDependencies", project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user