Skip to content

Commit

Permalink
Fix z3 build (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saloed authored Sep 26, 2022
1 parent 4ed4a9e commit 9c1f811
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ksmt-bitwuzla/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tasks.withType<ProcessResources> {
}
}

val runBenchmarksBasedTests = project.booleanProperty("bitwuzla.runBenchmarksBasedTests") ?: true
val runBenchmarksBasedTests = project.booleanProperty("bitwuzla.runBenchmarksBasedTests") ?: false

// skip big benchmarks to achieve faster tests build and run time
val skipBigBenchmarks = project.booleanProperty("bitwuzla.skipBigBenchmarks") ?: true
Expand Down
57 changes: 41 additions & 16 deletions ksmt-z3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,60 @@ repositories {
mavenCentral()
}

val z3native by configurations.creating

val z3Version = "4.11.2"

val z3JavaJar by lazy { z3Release("x64-win", "*.jar") }
val z3JavaJar by lazy { mkZ3ReleaseDownloadTask("x64-win", "*.jar") }

val z3Binaries = listOf(
mkZ3ReleaseDownloadTask("x64-win", "*.dll"),
mkZ3ReleaseDownloadTask("x64-glibc-2.31", "*.so"),
mkZ3ReleaseDownloadTask("x64-osx-10.16", "*.dylib")
)

dependencies {
implementation(project(":ksmt-core"))
implementation(z3JavaJar)
implementation(fileTree(z3JavaJar.outputDirectory) {
builtBy(z3JavaJar)
})

testImplementation(testFixtures(project(":ksmt-core")))
testFixturesApi(testFixtures(project(":ksmt-core")))
testFixturesImplementation(z3Release("x64-win", "*.jar"))

z3native(z3Release("x64-win", "*.dll"))
z3native(z3Release("x64-glibc-2.31", "*.so"))
z3native(z3Release("x64-osx-10.16", "*.dylib"))
testFixturesImplementation(fileTree(z3JavaJar.outputDirectory) {
builtBy(z3JavaJar)
})
}

tasks.withType<ProcessResources> {
from(z3native.resolvedConfiguration.files) {
into("lib/x64")
dependsOn.addAll(z3Binaries)
z3Binaries.forEach { z3BinaryTask ->
from(z3BinaryTask.outputFiles) {
into("lib/x64")
}
}
}

fun z3Release(arch: String, artifactPattern: String): FileTree {
fun Project.mkZ3ReleaseDownloadTask(arch: String, artifactPattern: String): TaskProvider<Task> {
val z3ReleaseBaseUrl = "https://github.com/Z3Prover/z3/releases/download"
val releaseName = "z3-${z3Version}"
val packageName = "z3-${z3Version}-${arch}.zip"
val packageDownloadTarget = buildDir.resolve("dist").resolve(releaseName).resolve(packageName)
download(listOf(z3ReleaseBaseUrl, releaseName, packageName).joinToString("/"), packageDownloadTarget)
return zipTree(packageDownloadTarget).matching { include("**/$artifactPattern") }
val downloadUrl = listOf(z3ReleaseBaseUrl, releaseName, packageName).joinToString("/")
val downloadTaskName = "z3-release-$releaseName-$arch-${artifactPattern.replace('*', '-')}"
return tasks.register(downloadTaskName) {
val outputDir = buildDir.resolve("dist").resolve(downloadTaskName)
doLast {
download(downloadUrl, packageDownloadTarget)
val files = zipTree(packageDownloadTarget).matching { include("**/$artifactPattern") }
copy {
from(files.files)
into(outputDir)
}
}
outputs.dir(outputDir)
}
}

val runBenchmarksBasedTests = project.booleanProperty("z3.runBenchmarksBasedTests") ?: true
val runBenchmarksBasedTests = project.booleanProperty("z3.runBenchmarksBasedTests") ?: false

// skip big benchmarks to achieve faster tests build and run time
val skipBigBenchmarks = project.booleanProperty("z3.skipBigBenchmarks") ?: true
Expand Down Expand Up @@ -108,7 +127,7 @@ tasks.withType<Test> {
tasks.withType<ShadowJar> {
archiveClassifier.set("")
dependencies {
include(dependency(z3JavaJar))
include(dependency(z3JavaJar.outputFiles))
}
val implementation = project.configurations["implementation"].dependencies.toSet()
val runtimeOnly = project.configurations["runtimeOnly"].dependencies.toSet()
Expand All @@ -124,3 +143,9 @@ publishing {
}
}
}

val TaskProvider<Task>.outputDirectory: File
get() = get().outputs.files.singleFile

val TaskProvider<Task>.outputFiles: FileTree
get() = fileTree(outputDirectory)

0 comments on commit 9c1f811

Please sign in to comment.