Better checking of ABI compatibility.
Split ${target}CheckAbiCompatibility into two:
1) check${targetName}PlatformAbiCompatibility -- check platform libs compatibility of the given target
2) checkStdlibAbiCompatibility -- check only stdlib.
This approach allows to avoid repeated check of stdlib for each target.
This commit is contained in:
committed by
Stanislav Erokhin
parent
2057e5c8f1
commit
2d30796483
+38
-24
@@ -12,9 +12,6 @@ import java.io.File
|
|||||||
*/
|
*/
|
||||||
open class CompareDistributionSignatures : DefaultTask() {
|
open class CompareDistributionSignatures : DefaultTask() {
|
||||||
|
|
||||||
@Input
|
|
||||||
lateinit var target: String
|
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
lateinit var oldDistribution: String
|
lateinit var oldDistribution: String
|
||||||
|
|
||||||
@@ -31,22 +28,52 @@ open class CompareDistributionSignatures : DefaultTask() {
|
|||||||
@Input
|
@Input
|
||||||
var onMismatchMode: OnMismatchMode = OnMismatchMode.NOTIFY
|
var onMismatchMode: OnMismatchMode = OnMismatchMode.NOTIFY
|
||||||
|
|
||||||
|
sealed class Libraries {
|
||||||
|
object Standard : Libraries()
|
||||||
|
|
||||||
|
class Platform(val target: String) : Libraries()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Input
|
||||||
|
lateinit var libraries: Libraries
|
||||||
|
|
||||||
|
private fun computeDiff(): KlibDiff = when (val libraries = libraries) {
|
||||||
|
Libraries.Standard -> KlibDiff(
|
||||||
|
emptyList(),
|
||||||
|
emptyList(),
|
||||||
|
listOf(RemainingLibrary(newDistribution.stdlib(), oldDistribution.stdlib()))
|
||||||
|
)
|
||||||
|
is Libraries.Platform -> {
|
||||||
|
val oldPlatformLibs = oldDistribution.platformLibs(libraries.target)
|
||||||
|
val oldPlatformLibsNames = oldPlatformLibs.list().toSet()
|
||||||
|
val newPlatformLibs = newDistribution.platformLibs(libraries.target)
|
||||||
|
val newPlatformLibsNames = newPlatformLibs.list().toSet()
|
||||||
|
KlibDiff(
|
||||||
|
(newPlatformLibsNames - oldPlatformLibsNames).map(newPlatformLibs::resolve),
|
||||||
|
(oldPlatformLibsNames - newPlatformLibsNames).map(oldPlatformLibs::resolve),
|
||||||
|
oldPlatformLibsNames.intersect(newPlatformLibsNames).map {
|
||||||
|
RemainingLibrary(newPlatformLibs.resolve(it), oldPlatformLibs.resolve(it))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun run() {
|
fun run() {
|
||||||
val klibs = getKlibs(oldDistribution, newDistribution)
|
val platformLibsDiff = computeDiff()
|
||||||
if (klibs.missingLibs.isNotEmpty()) {
|
if (platformLibsDiff.missingLibs.isNotEmpty()) {
|
||||||
messageBuilder.apply {
|
messageBuilder.apply {
|
||||||
appendln("Following libraries are missing in the new distro:")
|
appendln("Following platform libraries are missing in the new distro:")
|
||||||
klibs.missingLibs.forEach { appendln(it) }
|
platformLibsDiff.missingLibs.forEach { appendln(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (klibs.newLibs.isNotEmpty()) {
|
if (platformLibsDiff.newLibs.isNotEmpty()) {
|
||||||
messageBuilder.apply {
|
messageBuilder.apply {
|
||||||
appendln("Following libraries were added:")
|
appendln("Following platform libraries were added:")
|
||||||
klibs.newLibs.forEach { appendln(it) }
|
platformLibsDiff.newLibs.forEach { appendln(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ((new, old) in klibs.remainingLibs) {
|
for ((new, old) in platformLibsDiff.remainingLibs) {
|
||||||
val result = compareSignatures(new, old)
|
val result = compareSignatures(new, old)
|
||||||
if (result.run { newKlibOnly.isNotEmpty() || oldKlibOnly.isNotEmpty() }) {
|
if (result.run { newKlibOnly.isNotEmpty() || oldKlibOnly.isNotEmpty() }) {
|
||||||
reportMismatch(result, new.name)
|
reportMismatch(result, new.name)
|
||||||
@@ -92,19 +119,6 @@ open class CompareDistributionSignatures : DefaultTask() {
|
|||||||
private fun String.platformLibs(target: String): File =
|
private fun String.platformLibs(target: String): File =
|
||||||
File("$this/klib/platform/$target")
|
File("$this/klib/platform/$target")
|
||||||
|
|
||||||
private fun getKlibs(oldDistribution: String, newDistribution: String): KlibDiff {
|
|
||||||
val oldPlatformLibs = oldDistribution.platformLibs(target)
|
|
||||||
val oldPlatformLibsNames = oldPlatformLibs.list().toSet()
|
|
||||||
val newPlatformLibs = newDistribution.platformLibs(target)
|
|
||||||
val newPlatformLibsNames = newPlatformLibs.list().toSet()
|
|
||||||
return KlibDiff(
|
|
||||||
(newPlatformLibsNames - oldPlatformLibsNames).map(newPlatformLibs::resolve),
|
|
||||||
(oldPlatformLibsNames - newPlatformLibsNames).map(oldPlatformLibs::resolve),
|
|
||||||
oldPlatformLibsNames.intersect(newPlatformLibsNames).map {
|
|
||||||
RemainingLibrary(newPlatformLibs.resolve(it), oldPlatformLibs.resolve(it))
|
|
||||||
} + RemainingLibrary(newDistribution.stdlib(), oldDistribution.stdlib())
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getKlibSignatures(klib: File): List<String> {
|
private fun getKlibSignatures(klib: File): List<String> {
|
||||||
val tool = if (HostManager.hostIsMingw) "klib.bat" else "klib"
|
val tool = if (HostManager.hostIsMingw) "klib.bat" else "klib"
|
||||||
|
|||||||
@@ -792,12 +792,20 @@ task compdb(type: Copy) {
|
|||||||
|
|
||||||
if (project.hasProperty("anotherDistro")) {
|
if (project.hasProperty("anotherDistro")) {
|
||||||
targetList.each { targetName ->
|
targetList.each { targetName ->
|
||||||
task "${targetName}CheckAbiCompatibility"(type: CompareDistributionSignatures) {
|
task "${targetName}CheckPlatformAbiCompatibility"(type: CompareDistributionSignatures) {
|
||||||
dependsOn "${targetName}PlatformLibs"
|
dependsOn "${targetName}PlatformLibs"
|
||||||
|
|
||||||
target = targetName
|
libraries = new CompareDistributionSignatures.Libraries.Platform(targetName)
|
||||||
oldDistribution = project.findProperty("anotherDistro")
|
oldDistribution = project.findProperty("anotherDistro")
|
||||||
onMismatchMode = CompareDistributionSignatures.OnMismatchMode.FAIL
|
onMismatchMode = CompareDistributionSignatures.OnMismatchMode.FAIL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task "checkStdlibAbiCompatibility"(type: CompareDistributionSignatures) {
|
||||||
|
dependsOn "distRuntime"
|
||||||
|
|
||||||
|
libraries = CompareDistributionSignatures.Libraries.Standard.INSTANCE
|
||||||
|
oldDistribution = project.findProperty("anotherDistro")
|
||||||
|
onMismatchMode = CompareDistributionSignatures.OnMismatchMode.FAIL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user