[build] joint (step 1)
(cherry picked from commit 7d0775f7e69ab900200bcf1fa78b94d68e6bd4f6)
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ open class KonanArtifactContainer(val project: ProjectInternal)
|
||||
|
||||
var targets: Iterable<String> = emptyList()
|
||||
|
||||
override fun create(name: String?): T =
|
||||
override fun create(name: String): T =
|
||||
instantiator.newInstance(configClass.java, name, project, targets)
|
||||
}
|
||||
|
||||
|
||||
+23
-23
@@ -117,20 +117,20 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||
private fun createTask(target: KonanTarget): TaskProvider<T> =
|
||||
project.tasks.register(generateTaskName(target), type) {
|
||||
val outputDescription = determineOutputPlacement(target)
|
||||
it.init(this, outputDescription.destinationDir, outputDescription.artifactName, target)
|
||||
it.group = BasePlugin.BUILD_GROUP
|
||||
it.description = generateTaskDescription(it)
|
||||
init(this@KonanBuildingConfig, outputDescription.destinationDir, outputDescription.artifactName, target)
|
||||
group = BasePlugin.BUILD_GROUP
|
||||
description = generateTaskDescription(this)
|
||||
} ?: throw Exception("Cannot create task for target: ${target.visibleName}")
|
||||
|
||||
private fun createAggregateTask(): TaskProvider<Task> =
|
||||
project.tasks.register(generateAggregateTaskName()) { task ->
|
||||
task.group = BasePlugin.BUILD_GROUP
|
||||
task.description = generateAggregateTaskDescription(task)
|
||||
project.tasks.register(generateAggregateTaskName()) {
|
||||
group = BasePlugin.BUILD_GROUP
|
||||
description = generateAggregateTaskDescription(this)
|
||||
|
||||
targetToTask.filter {
|
||||
project.targetIsRequested(it.key)
|
||||
}.forEach {
|
||||
task.dependsOn(it.value)
|
||||
dependsOn(it.value)
|
||||
}
|
||||
}.also {
|
||||
project.compileAllTask.dependsOn(it)
|
||||
@@ -141,9 +141,9 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||
|
||||
return this[canonicalTarget]?.let { canonicalBuild ->
|
||||
project.tasks.register(generateTargetAliasTaskName(targetName)) {
|
||||
it.group = BasePlugin.BUILD_GROUP
|
||||
it.description = generateTargetAliasTaskDescription(it, targetName)
|
||||
it.dependsOn(canonicalBuild)
|
||||
group = BasePlugin.BUILD_GROUP
|
||||
description = generateTargetAliasTaskDescription(this, targetName)
|
||||
dependsOn(canonicalBuild)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,43 +160,43 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||
|
||||
// Common building DSL.
|
||||
|
||||
override fun artifactName(name: String) = tasks().forEach { it.configure { t -> t.artifactName(name) } }
|
||||
override fun artifactName(name: String) = tasks().forEach { it.configure { artifactName(name) } }
|
||||
|
||||
fun baseDir(dir: Any) =
|
||||
tasks().forEach {
|
||||
it.configure { t ->
|
||||
t.destinationDir(
|
||||
project.file(dir).targetSubdir(t.konanTarget)
|
||||
it.configure {
|
||||
destinationDir(
|
||||
project.file(dir).targetSubdir(konanTarget)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun libraries(closure: Closure<Unit>) =
|
||||
tasks().forEach { it.configure { t -> t.libraries(closure) } }
|
||||
tasks().forEach { it.configure { libraries(closure) } }
|
||||
|
||||
override fun libraries(action: Action<KonanLibrariesSpec>) =
|
||||
tasks().forEach { it.configure { t -> t.libraries(action) } }
|
||||
tasks().forEach { it.configure { libraries(action) } }
|
||||
|
||||
override fun libraries(configure: KonanLibrariesSpec.() -> Unit) =
|
||||
tasks().forEach { it.configure { t -> t.libraries(configure) } }
|
||||
tasks().forEach { it.configure { libraries(configure) } }
|
||||
|
||||
override fun noDefaultLibs(flag: Boolean) =
|
||||
tasks().forEach { it.configure { t -> t.noDefaultLibs(flag) } }
|
||||
tasks().forEach { it.configure { noDefaultLibs(flag) } }
|
||||
|
||||
override fun noEndorsedLibs(flag: Boolean) =
|
||||
tasks().forEach { it.configure { t -> t.noEndorsedLibs(flag) } }
|
||||
tasks().forEach { it.configure { noEndorsedLibs(flag) } }
|
||||
|
||||
override fun dumpParameters(flag: Boolean) =
|
||||
tasks().forEach { it.configure { t -> t.dumpParameters(flag) } }
|
||||
tasks().forEach { it.configure { dumpParameters(flag) } }
|
||||
|
||||
override fun extraOpts(vararg values: Any) =
|
||||
tasks().forEach { it.configure { t -> t.extraOpts(*values) } }
|
||||
tasks().forEach { it.configure { extraOpts(*values) } }
|
||||
|
||||
override fun extraOpts(values: List<Any>) =
|
||||
tasks().forEach { it.configure { t -> t.extraOpts(values) } }
|
||||
tasks().forEach { it.configure { extraOpts(values) } }
|
||||
|
||||
fun dependsOn(vararg dependencies: Any?) =
|
||||
tasks().forEach { it.configure { t -> t.dependsOn(*dependencies) } }
|
||||
tasks().forEach { it.configure { dependsOn(*dependencies) } }
|
||||
|
||||
fun target(targetString: String, configureAction: T.() -> Unit) {
|
||||
val target = project.hostManager.targetByName(targetString)
|
||||
|
||||
+19
-19
@@ -43,33 +43,33 @@ abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
|
||||
override fun generateTargetAliasTaskDescription(task: Task, targetName: String) =
|
||||
"Build the Kotlin/Native $typeForDescription '${task.name}' for target '$targetName'"
|
||||
|
||||
override fun srcDir(dir: Any) = tasks().forEach { it.configure { t -> t.srcDir(dir) } }
|
||||
override fun srcFiles(vararg files: Any) = tasks().forEach { it.configure { t -> t.srcFiles(*files) } }
|
||||
override fun srcFiles(files: Collection<Any>) = tasks().forEach { it.configure { t -> t.srcFiles(files) } }
|
||||
override fun srcDir(dir: Any) = tasks().forEach { it.configure { srcDir(dir) } }
|
||||
override fun srcFiles(vararg files: Any) = tasks().forEach { it.configure { srcFiles(*files) } }
|
||||
override fun srcFiles(files: Collection<Any>) = tasks().forEach { it.configure { srcFiles(files) } }
|
||||
|
||||
override fun nativeLibrary(lib: Any) = tasks().forEach { it.configure { t -> t.nativeLibrary(lib) } }
|
||||
override fun nativeLibraries(vararg libs: Any) = tasks().forEach { it.configure { t -> t.nativeLibraries(*libs) } }
|
||||
override fun nativeLibraries(libs: FileCollection) = tasks().forEach { it.configure { t -> t.nativeLibraries(libs) } }
|
||||
override fun nativeLibrary(lib: Any) = tasks().forEach { it.configure { nativeLibrary(lib) } }
|
||||
override fun nativeLibraries(vararg libs: Any) = tasks().forEach { it.configure { nativeLibraries(*libs) } }
|
||||
override fun nativeLibraries(libs: FileCollection) = tasks().forEach { it.configure { nativeLibraries(libs) } }
|
||||
|
||||
@Deprecated("Use commonSourceSets instead", ReplaceWith("commonSourceSets(sourceSetName)"))
|
||||
override fun commonSourceSet(sourceSetName: String) = tasks().forEach { it.configure { t -> t.commonSourceSets(sourceSetName) } }
|
||||
override fun commonSourceSets(vararg sourceSetNames: String) = tasks().forEach { it.configure { t -> t.commonSourceSets(*sourceSetNames) } }
|
||||
override fun enableMultiplatform(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableMultiplatform(flag) } }
|
||||
override fun commonSourceSet(sourceSetName: String) = tasks().forEach { it.configure { commonSourceSets(sourceSetName) } }
|
||||
override fun commonSourceSets(vararg sourceSetNames: String) = tasks().forEach { it.configure { commonSourceSets(*sourceSetNames) } }
|
||||
override fun enableMultiplatform(flag: Boolean) = tasks().forEach { it.configure { enableMultiplatform(flag) } }
|
||||
|
||||
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { t -> t.linkerOpts(values) } }
|
||||
override fun linkerOpts(vararg values: String) = tasks().forEach { it.configure { t -> t.linkerOpts(*values) } }
|
||||
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { linkerOpts(values) } }
|
||||
override fun linkerOpts(vararg values: String) = tasks().forEach { it.configure { linkerOpts(*values) } }
|
||||
|
||||
override fun enableDebug(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableDebug(flag) } }
|
||||
override fun noStdLib(flag: Boolean) = tasks().forEach { it.configure { t -> t.noStdLib(flag) } }
|
||||
override fun noMain(flag: Boolean) = tasks().forEach { it.configure { t -> t.noMain(flag) } }
|
||||
override fun enableOptimizations(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableOptimizations(flag) } }
|
||||
override fun enableAssertions(flag: Boolean) = tasks().forEach { it.configure { t -> t.enableAssertions(flag) } }
|
||||
override fun enableDebug(flag: Boolean) = tasks().forEach { it.configure { enableDebug(flag) } }
|
||||
override fun noStdLib(flag: Boolean) = tasks().forEach { it.configure { noStdLib(flag) } }
|
||||
override fun noMain(flag: Boolean) = tasks().forEach { it.configure { noMain(flag) } }
|
||||
override fun enableOptimizations(flag: Boolean) = tasks().forEach { it.configure { enableOptimizations(flag) } }
|
||||
override fun enableAssertions(flag: Boolean) = tasks().forEach { it.configure { enableAssertions(flag) } }
|
||||
|
||||
override fun entryPoint(entryPoint: String) = tasks().forEach { it.configure { t -> t.entryPoint(entryPoint) } }
|
||||
override fun entryPoint(entryPoint: String) = tasks().forEach { it.configure { entryPoint(entryPoint) } }
|
||||
|
||||
override fun measureTime(flag: Boolean) = tasks().forEach { it.configure { t -> t.measureTime(flag) } }
|
||||
override fun measureTime(flag: Boolean) = tasks().forEach { it.configure { measureTime(flag) } }
|
||||
|
||||
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { t -> t.dependencies(closure) } }
|
||||
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { dependencies(closure) } }
|
||||
}
|
||||
|
||||
open class KonanProgram(name: String,
|
||||
|
||||
+12
-12
@@ -50,36 +50,36 @@ open class KonanInteropLibrary(name: String,
|
||||
inner class IncludeDirectoriesSpecImpl: IncludeDirectoriesSpec {
|
||||
override fun allHeaders(vararg includeDirs: Any) = allHeaders(includeDirs.toList())
|
||||
override fun allHeaders(includeDirs: Collection<Any>) = tasks().forEach {
|
||||
it.configure { t -> t.includeDirs.allHeaders(includeDirs) }
|
||||
it.configure { this@configure.includeDirs.allHeaders(includeDirs) }
|
||||
}
|
||||
|
||||
override fun headerFilterOnly(vararg includeDirs: Any) = headerFilterOnly(includeDirs.toList())
|
||||
override fun headerFilterOnly(includeDirs: Collection<Any>) = tasks().forEach {
|
||||
it.configure { t -> t.includeDirs.headerFilterOnly(includeDirs) }
|
||||
it.configure { this@configure.includeDirs.headerFilterOnly(includeDirs) }
|
||||
}
|
||||
}
|
||||
|
||||
val includeDirs = IncludeDirectoriesSpecImpl()
|
||||
|
||||
override fun defFile(file: Any) = tasks().forEach { it.configure { t -> t.defFile(file) } }
|
||||
override fun defFile(file: Any) = tasks().forEach { it.configure { defFile(file) } }
|
||||
|
||||
override fun packageName(value: String) = tasks().forEach { it.configure { t -> t.packageName(value) } }
|
||||
override fun packageName(value: String) = tasks().forEach { it.configure { packageName(value) } }
|
||||
|
||||
override fun compilerOpts(vararg values: String) = tasks().forEach { it.configure { t -> t.compilerOpts(*values) } }
|
||||
override fun compilerOpts(vararg values: String) = tasks().forEach { it.configure { compilerOpts(*values) } }
|
||||
|
||||
override fun headers(vararg files: Any) = tasks().forEach { it.configure { t -> t.headers(*files) } }
|
||||
override fun headers(vararg files: Any) = tasks().forEach { it.configure { headers(*files) } }
|
||||
|
||||
override fun headers(files: FileCollection) = tasks().forEach { it.configure { t -> t.headers(files) } }
|
||||
override fun headers(files: FileCollection) = tasks().forEach { it.configure { headers(files) } }
|
||||
|
||||
override fun includeDirs(vararg values: Any) = tasks().forEach { it.configure { t -> t.includeDirs(*values) } }
|
||||
override fun includeDirs(vararg values: Any) = tasks().forEach { it.configure { includeDirs(*values) } }
|
||||
override fun includeDirs(closure: Closure<Unit>) = includeDirs(ConfigureUtil.configureUsing(closure))
|
||||
override fun includeDirs(action: Action<IncludeDirectoriesSpec>) = includeDirs { action.execute(this) }
|
||||
override fun includeDirs(configure: IncludeDirectoriesSpec.() -> Unit) = includeDirs.configure()
|
||||
|
||||
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { t -> t.linkerOpts(values) } }
|
||||
override fun linkerOpts(values: List<String>) = tasks().forEach { it.configure { linkerOpts(values) } }
|
||||
override fun linkerOpts(vararg values: String) = linkerOpts(values.toList())
|
||||
|
||||
override fun link(vararg files: Any) = tasks().forEach { it.configure { t -> t.link(*files) } }
|
||||
override fun link(files: FileCollection) = tasks().forEach { it.configure { t -> t.link(files) } }
|
||||
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { t -> t.dependencies(closure) }}
|
||||
override fun link(vararg files: Any) = tasks().forEach { it.configure { link(*files) } }
|
||||
override fun link(files: FileCollection) = tasks().forEach { it.configure { link(files) } }
|
||||
override fun dependencies(closure: Closure<Unit>) = tasks().forEach { it.configure { dependencies(closure) }}
|
||||
}
|
||||
+15
-15
@@ -327,7 +327,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
}
|
||||
|
||||
|
||||
override fun apply(project: ProjectInternal?) {
|
||||
override fun apply(project: ProjectInternal) {
|
||||
if (project == null) {
|
||||
return
|
||||
}
|
||||
@@ -370,16 +370,16 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
val isCrossCompile = (task.target != HostManager.host.visibleName)
|
||||
if (!isCrossCompile && !project.hasProperty("konanNoRun"))
|
||||
task.runTask = project.tasks.register("run${task.artifactName.capitalize()}", Exec::class.java) {
|
||||
it.group= "run"
|
||||
it.dependsOn(task)
|
||||
group= "run"
|
||||
dependsOn(task)
|
||||
val artifactPathClosure = object : Closure<String>(this) {
|
||||
override fun call() = task.artifactPath
|
||||
}
|
||||
// Use GString to evaluate a path to the artifact lazily thus allow changing it at configuration phase.
|
||||
val lazyArtifactPath = GStringImpl(arrayOf(artifactPathClosure), arrayOf(""))
|
||||
it.executable(lazyArtifactPath)
|
||||
executable(lazyArtifactPath)
|
||||
// Add values passed in the runArgs project property as arguments.
|
||||
it.argumentProviders.add(task.RunArgumentProvider())
|
||||
argumentProviders.add(task.RunArgumentProvider())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,7 +390,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
.filterIsInstance(KonanProgram::class.java)
|
||||
.forEach { program ->
|
||||
program.tasks().forEach { compile ->
|
||||
compile.configure { it.runTask?.let { runTask.dependsOn(it) } }
|
||||
compile.configure { runTask?.let { runTask.dependsOn(it) } }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -403,7 +403,7 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
val konanSoftwareComponent = buildingConfig.mainVariant
|
||||
project.extensions.configure(PublishingExtension::class.java) {
|
||||
val builtArtifact = buildingConfig.name
|
||||
val mavenPublication = it.publications.maybeCreate(builtArtifact, MavenPublication::class.java)
|
||||
val mavenPublication = publications.maybeCreate(builtArtifact, MavenPublication::class.java)
|
||||
mavenPublication.apply {
|
||||
artifactId = builtArtifact
|
||||
groupId = project.group.toString()
|
||||
@@ -416,22 +416,22 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
}
|
||||
|
||||
project.extensions.configure(PublishingExtension::class.java) {
|
||||
val publishing = it
|
||||
for (v in konanSoftwareComponent.variants) {
|
||||
publishing.publications.create(v.name, MavenPublication::class.java) { mavenPublication ->
|
||||
this@configure.publications.create(v.name, MavenPublication::class.java) {
|
||||
val coordinates = (v as NativeVariantIdentity).coordinates
|
||||
project.logger.info("variant with coordinates($coordinates) and module: ${coordinates.module}")
|
||||
mavenPublication.artifactId = coordinates.module.name
|
||||
mavenPublication.groupId = coordinates.group
|
||||
mavenPublication.version = coordinates.version
|
||||
mavenPublication.from(v)
|
||||
(mavenPublication as MavenPublicationInternal).publishWithOriginalFileName()
|
||||
artifactId = coordinates.module.name
|
||||
groupId = coordinates.group
|
||||
version = coordinates.version
|
||||
from(v)
|
||||
(this as MavenPublicationInternal).publishWithOriginalFileName()
|
||||
buildingConfig.pomActions.forEach {
|
||||
mavenPublication.pom(it)
|
||||
pom(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -91,20 +91,20 @@ internal abstract class KonanCliRunner(
|
||||
"Please change it to the compiler root directory and rerun the build.")
|
||||
}
|
||||
|
||||
project.javaexec { spec ->
|
||||
spec.main = mainClass
|
||||
spec.classpath = classpath
|
||||
spec.jvmArgs(jvmArgs)
|
||||
spec.systemProperties(
|
||||
project.javaexec {
|
||||
main = this@KonanCliRunner.mainClass
|
||||
classpath = classpath
|
||||
jvmArgs(jvmArgs)
|
||||
systemProperties(
|
||||
System.getProperties().asSequence()
|
||||
.map { (k, v) -> k.toString() to v.toString() }
|
||||
.filter { (k, _) -> k !in blacklistProperties }
|
||||
.escapeQuotesForWindows()
|
||||
.toMap()
|
||||
)
|
||||
spec.args(listOf(toolName) + transformArgs(args))
|
||||
blacklistEnvironment.forEach { spec.environment.remove(it) }
|
||||
spec.environment(environment)
|
||||
args(listOf(toolName) + transformArgs(args))
|
||||
blacklistEnvironment.forEach { environment.remove(it) }
|
||||
environment(environment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -97,11 +97,11 @@ abstract class KonanArtifactTask: KonanTargetableTask(), KonanArtifactSpec {
|
||||
platformConfiguration = project.configurations.create("artifact${artifactName}_${target.name}")
|
||||
platformConfiguration.extendsFrom(configuration)
|
||||
platformConfiguration.attributes{
|
||||
it.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.NATIVE_LINK))
|
||||
it.attribute(CppBinary.LINKAGE_ATTRIBUTE, Linkage.STATIC)
|
||||
it.attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false)
|
||||
it.attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, false)
|
||||
it.attribute(Attribute.of("org.gradle.native.kotlin.platform", String::class.java), target.name)
|
||||
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.NATIVE_LINK))
|
||||
attribute(CppBinary.LINKAGE_ATTRIBUTE, Linkage.STATIC)
|
||||
attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false)
|
||||
attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, false)
|
||||
attribute(Attribute.of("org.gradle.native.kotlin.platform", String::class.java), target.name)
|
||||
}
|
||||
|
||||
val artifactNameWithoutSuffix = artifact.name.removeSuffix("$artifactSuffix")
|
||||
|
||||
+2
-2
@@ -190,8 +190,8 @@ open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: Wo
|
||||
val workQueue = workerExecutor.noIsolation()
|
||||
interchangeBox[this.path] = toolRunner
|
||||
workQueue.submit(RunTool::class.java) {
|
||||
it.taskName = this.path
|
||||
it.args = args
|
||||
taskName = path
|
||||
this.args = args
|
||||
}
|
||||
} else {
|
||||
toolRunner.run(args)
|
||||
|
||||
Reference in New Issue
Block a user