Fix CompileToBitcodePlugin onlyIf to make it CC compatible
Required for KTI-1553
This commit is contained in:
committed by
Space Team
parent
c382b0e2b3
commit
e83d2e31d4
+67
-61
@@ -10,10 +10,7 @@ import org.gradle.api.*
|
|||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.artifacts.ConfigurationVariant
|
import org.gradle.api.artifacts.ConfigurationVariant
|
||||||
import org.gradle.api.attributes.Usage
|
import org.gradle.api.attributes.Usage
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
import org.gradle.api.file.*
|
||||||
import org.gradle.api.file.ConfigurableFileTree
|
|
||||||
import org.gradle.api.file.DirectoryProperty
|
|
||||||
import org.gradle.api.file.RegularFileProperty
|
|
||||||
import org.gradle.api.provider.ListProperty
|
import org.gradle.api.provider.ListProperty
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
@@ -104,28 +101,28 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
this.factory = { target ->
|
this.factory = { target ->
|
||||||
project.objects.newInstance<Target>(this, target)
|
project.objects.newInstance<Target>(this, target)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outgoing configuration with `main` parts of all modules.
|
* Outgoing configuration with `main` parts of all modules.
|
||||||
*/
|
*/
|
||||||
val compileBitcodeMainElements = project.compileBitcodeElements(MAIN_SOURCE_SET_NAME)
|
project.compileBitcodeElements(MAIN_SOURCE_SET_NAME)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outgoing configuration with `testFixtures` parts of all modules.
|
* Outgoing configuration with `testFixtures` parts of all modules.
|
||||||
*/
|
*/
|
||||||
val compileBitcodeTestFixturesElements = project.compileBitcodeElements(TEST_FIXTURES_SOURCE_SET_NAME) {
|
project.compileBitcodeElements(TEST_FIXTURES_SOURCE_SET_NAME) {
|
||||||
outgoing {
|
outgoing {
|
||||||
capability(CppConsumerPlugin.testFixturesCapability(project))
|
capability(CppConsumerPlugin.testFixturesCapability(project))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outgoing configuration with `test` parts of all modules.
|
* Outgoing configuration with `test` parts of all modules.
|
||||||
*/
|
*/
|
||||||
val compileBitcodeTestElements = project.compileBitcodeElements(TEST_SOURCE_SET_NAME) {
|
project.compileBitcodeElements(TEST_SOURCE_SET_NAME) {
|
||||||
outgoing {
|
outgoing {
|
||||||
capability(CppConsumerPlugin.testCapability(project))
|
capability(CppConsumerPlugin.testCapability(project))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,12 +195,12 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
*/
|
*/
|
||||||
abstract val dependencies: ListProperty<TaskProvider<*>>
|
abstract val dependencies: ListProperty<TaskProvider<*>>
|
||||||
|
|
||||||
protected abstract val onlyIf: ListProperty<Spec<in SourceSet>>
|
protected abstract val onlyIf: ListProperty<Spec<in KonanTarget>>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds this source set only if [spec] is satisfied.
|
* Builds this source set only if [spec] is satisfied.
|
||||||
*/
|
*/
|
||||||
fun onlyIf(spec: Spec<in SourceSet>) {
|
fun onlyIf(spec: Spec<in KonanTarget>) {
|
||||||
this.onlyIf.add(spec)
|
this.onlyIf.add(spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,8 +231,10 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
dependsOn(nativeDependencies.llvmDependency)
|
dependsOn(nativeDependencies.llvmDependency)
|
||||||
dependsOn(nativeDependencies.targetDependency(_target))
|
dependsOn(nativeDependencies.targetDependency(_target))
|
||||||
dependsOn(this@SourceSet.dependencies)
|
dependsOn(this@SourceSet.dependencies)
|
||||||
|
val specs = this@SourceSet.onlyIf
|
||||||
|
val target = target
|
||||||
onlyIf {
|
onlyIf {
|
||||||
this@SourceSet.onlyIf.get().all { it.isSatisfiedBy(this@SourceSet) }
|
specs.get().all { it.isSatisfiedBy(target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compilationDatabase.target(_target) {
|
compilationDatabase.target(_target) {
|
||||||
@@ -268,8 +267,10 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
this.inputFiles.from(compileTask)
|
this.inputFiles.from(compileTask)
|
||||||
this.outputFile.set(this@SourceSet.outputFile)
|
this.outputFile.set(this@SourceSet.outputFile)
|
||||||
this.arguments.set(module.linkerArgs)
|
this.arguments.set(module.linkerArgs)
|
||||||
|
val specs = this@SourceSet.onlyIf
|
||||||
|
val target = target
|
||||||
onlyIf {
|
onlyIf {
|
||||||
this@SourceSet.onlyIf.get().all { it.isSatisfiedBy(this@SourceSet) }
|
specs.get().all { it.isSatisfiedBy(target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
project.compileBitcodeElements(this@SourceSet.name).targetVariant(_target).artifact(this)
|
project.compileBitcodeElements(this@SourceSet.name).targetVariant(_target).artifact(this)
|
||||||
@@ -363,40 +364,43 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val project by owner::project
|
||||||
|
|
||||||
|
init {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outgoing configuration with `main` part of this module.
|
||||||
|
*/
|
||||||
|
project.moduleCompileBitcodeElements(name, MAIN_SOURCE_SET_NAME) {
|
||||||
|
outgoing {
|
||||||
|
capability(CppConsumerPlugin.moduleCapability(project, this@Module.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outgoing configuration with `testFixtures` part of this module.
|
||||||
|
*/
|
||||||
|
project.moduleCompileBitcodeElements(name, TEST_FIXTURES_SOURCE_SET_NAME) {
|
||||||
|
outgoing {
|
||||||
|
capability(CppConsumerPlugin.moduleTestFixturesCapability(project, this@Module.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outgoing configuration with `test` part of this module.
|
||||||
|
*/
|
||||||
|
project.moduleCompileBitcodeElements(name, TEST_SOURCE_SET_NAME) {
|
||||||
|
outgoing {
|
||||||
|
capability(CppConsumerPlugin.moduleTestCapability(project, this@Module.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val target by _target::target
|
val target by _target::target
|
||||||
val sanitizer by _target::sanitizer
|
val sanitizer by _target::sanitizer
|
||||||
|
|
||||||
override fun getName() = name
|
override fun getName() = name
|
||||||
|
|
||||||
private val project by owner::project
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Outgoing configuration with `main` part of this module.
|
|
||||||
*/
|
|
||||||
val compileBitcodeMainElements = project.moduleCompileBitcodeElements(name, MAIN_SOURCE_SET_NAME) {
|
|
||||||
outgoing {
|
|
||||||
capability(CppConsumerPlugin.moduleCapability(project, this@Module.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Outgoing configuration with `testFixtures` part of this module.
|
|
||||||
*/
|
|
||||||
val compileBitcodeTestFixturesElements = project.moduleCompileBitcodeElements(name, TEST_FIXTURES_SOURCE_SET_NAME) {
|
|
||||||
outgoing {
|
|
||||||
capability(CppConsumerPlugin.moduleTestFixturesCapability(project, this@Module.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Outgoing configuration with `test` part of this module.
|
|
||||||
*/
|
|
||||||
val compileBitcodeTestElements = project.moduleCompileBitcodeElements(name, TEST_SOURCE_SET_NAME) {
|
|
||||||
outgoing {
|
|
||||||
capability(CppConsumerPlugin.moduleTestCapability(project, this@Module.name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory where module sources are located. By default `src/<module name>`.
|
* Directory where module sources are located. By default `src/<module name>`.
|
||||||
*/
|
*/
|
||||||
@@ -432,12 +436,12 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
* Extra tqsk dependencies to be used for all [SourceSet]s.
|
* Extra tqsk dependencies to be used for all [SourceSet]s.
|
||||||
*/
|
*/
|
||||||
abstract val dependencies: ListProperty<TaskProvider<*>>
|
abstract val dependencies: ListProperty<TaskProvider<*>>
|
||||||
protected abstract val onlyIf: ListProperty<Spec<in Module>>
|
protected abstract val onlyIf: ListProperty<Spec<in KonanTarget>>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds this module only if [spec] is satisfied.
|
* Builds this module only if [spec] is satisfied.
|
||||||
*/
|
*/
|
||||||
fun onlyIf(spec: Spec<in Module>) {
|
fun onlyIf(spec: Spec<in KonanTarget>) {
|
||||||
this.onlyIf.add(spec)
|
this.onlyIf.add(spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,8 +457,10 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
this.inputFiles.from(this@Module.srcRoot.dir("cpp"))
|
this.inputFiles.from(this@Module.srcRoot.dir("cpp"))
|
||||||
this.headersDirs.setFrom(this@Module.headersDirs)
|
this.headersDirs.setFrom(this@Module.headersDirs)
|
||||||
dependencies.set(this@Module.dependencies)
|
dependencies.set(this@Module.dependencies)
|
||||||
|
val specs = this@Module.onlyIf
|
||||||
|
val target = target
|
||||||
onlyIf {
|
onlyIf {
|
||||||
this@Module.onlyIf.get().all { it.isSatisfiedBy(this@Module) }
|
specs.get().all { it.isSatisfiedBy(target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -612,9 +618,9 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) :
|
|||||||
tsanSuppressionsFile.set(project.layout.projectDirectory.file("tsan_suppressions.txt"))
|
tsanSuppressionsFile.set(project.layout.projectDirectory.file("tsan_suppressions.txt"))
|
||||||
this.target.set(target)
|
this.target.set(target)
|
||||||
this.executionTimeout.set(
|
this.executionTimeout.set(
|
||||||
(project.findProperty("gtest_timeout") as? String)?.let {
|
(project.findProperty("gtest_timeout") as? String)?.let {
|
||||||
Duration.parse("PT${it}")
|
Duration.parse("PT${it}")
|
||||||
} ?: Duration.ofMinutes(5))
|
} ?: Duration.ofMinutes(5))
|
||||||
|
|
||||||
usesService(runGTestSemaphore)
|
usesService(runGTestSemaphore)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ bitcode {
|
|||||||
"-DMI_TSAN=1".takeIf { sanitizer == SanitizerKind.THREAD },
|
"-DMI_TSAN=1".takeIf { sanitizer == SanitizerKind.THREAD },
|
||||||
))
|
))
|
||||||
|
|
||||||
onlyIf { target.supportsMimallocAllocator() }
|
onlyIf { it.supportsMimallocAllocator() }
|
||||||
}
|
}
|
||||||
|
|
||||||
module("libbacktrace") {
|
module("libbacktrace") {
|
||||||
@@ -142,7 +142,7 @@ bitcode {
|
|||||||
"-Wno-atomic-alignment"
|
"-Wno-atomic-alignment"
|
||||||
))
|
))
|
||||||
|
|
||||||
onlyIf { target.supportsLibBacktrace() }
|
onlyIf { it.supportsLibBacktrace() }
|
||||||
}
|
}
|
||||||
|
|
||||||
module("compiler_interface") {
|
module("compiler_interface") {
|
||||||
@@ -251,7 +251,7 @@ bitcode {
|
|||||||
main {}
|
main {}
|
||||||
}
|
}
|
||||||
|
|
||||||
onlyIf { target.supportsCoreSymbolication() }
|
onlyIf { it.supportsCoreSymbolication() }
|
||||||
}
|
}
|
||||||
|
|
||||||
module("source_info_libbacktrace") {
|
module("source_info_libbacktrace") {
|
||||||
@@ -261,7 +261,7 @@ bitcode {
|
|||||||
main {}
|
main {}
|
||||||
}
|
}
|
||||||
|
|
||||||
onlyIf { target.supportsLibBacktrace() }
|
onlyIf { it.supportsLibBacktrace() }
|
||||||
}
|
}
|
||||||
|
|
||||||
module("objc") {
|
module("objc") {
|
||||||
@@ -488,7 +488,7 @@ bitcode {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
main {}
|
main {}
|
||||||
}
|
}
|
||||||
onlyIf { target.family.isAppleFamily }
|
onlyIf { it.family.isAppleFamily }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user