Skip to content

Commit 9c1f811

Browse files
authored
Fix z3 build (#28)
1 parent 4ed4a9e commit 9c1f811

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

ksmt-bitwuzla/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ tasks.withType<ProcessResources> {
3838
}
3939
}
4040

41-
val runBenchmarksBasedTests = project.booleanProperty("bitwuzla.runBenchmarksBasedTests") ?: true
41+
val runBenchmarksBasedTests = project.booleanProperty("bitwuzla.runBenchmarksBasedTests") ?: false
4242

4343
// skip big benchmarks to achieve faster tests build and run time
4444
val skipBigBenchmarks = project.booleanProperty("bitwuzla.skipBigBenchmarks") ?: true

ksmt-z3/build.gradle.kts

+41-16
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,60 @@ repositories {
1010
mavenCentral()
1111
}
1212

13-
val z3native by configurations.creating
14-
1513
val z3Version = "4.11.2"
1614

17-
val z3JavaJar by lazy { z3Release("x64-win", "*.jar") }
15+
val z3JavaJar by lazy { mkZ3ReleaseDownloadTask("x64-win", "*.jar") }
16+
17+
val z3Binaries = listOf(
18+
mkZ3ReleaseDownloadTask("x64-win", "*.dll"),
19+
mkZ3ReleaseDownloadTask("x64-glibc-2.31", "*.so"),
20+
mkZ3ReleaseDownloadTask("x64-osx-10.16", "*.dylib")
21+
)
1822

1923
dependencies {
2024
implementation(project(":ksmt-core"))
21-
implementation(z3JavaJar)
25+
implementation(fileTree(z3JavaJar.outputDirectory) {
26+
builtBy(z3JavaJar)
27+
})
2228

2329
testImplementation(testFixtures(project(":ksmt-core")))
2430
testFixturesApi(testFixtures(project(":ksmt-core")))
25-
testFixturesImplementation(z3Release("x64-win", "*.jar"))
26-
27-
z3native(z3Release("x64-win", "*.dll"))
28-
z3native(z3Release("x64-glibc-2.31", "*.so"))
29-
z3native(z3Release("x64-osx-10.16", "*.dylib"))
31+
testFixturesImplementation(fileTree(z3JavaJar.outputDirectory) {
32+
builtBy(z3JavaJar)
33+
})
3034
}
3135

3236
tasks.withType<ProcessResources> {
33-
from(z3native.resolvedConfiguration.files) {
34-
into("lib/x64")
37+
dependsOn.addAll(z3Binaries)
38+
z3Binaries.forEach { z3BinaryTask ->
39+
from(z3BinaryTask.outputFiles) {
40+
into("lib/x64")
41+
}
3542
}
3643
}
3744

38-
fun z3Release(arch: String, artifactPattern: String): FileTree {
45+
fun Project.mkZ3ReleaseDownloadTask(arch: String, artifactPattern: String): TaskProvider<Task> {
3946
val z3ReleaseBaseUrl = "https://github.com/Z3Prover/z3/releases/download"
4047
val releaseName = "z3-${z3Version}"
4148
val packageName = "z3-${z3Version}-${arch}.zip"
4249
val packageDownloadTarget = buildDir.resolve("dist").resolve(releaseName).resolve(packageName)
43-
download(listOf(z3ReleaseBaseUrl, releaseName, packageName).joinToString("/"), packageDownloadTarget)
44-
return zipTree(packageDownloadTarget).matching { include("**/$artifactPattern") }
50+
val downloadUrl = listOf(z3ReleaseBaseUrl, releaseName, packageName).joinToString("/")
51+
val downloadTaskName = "z3-release-$releaseName-$arch-${artifactPattern.replace('*', '-')}"
52+
return tasks.register(downloadTaskName) {
53+
val outputDir = buildDir.resolve("dist").resolve(downloadTaskName)
54+
doLast {
55+
download(downloadUrl, packageDownloadTarget)
56+
val files = zipTree(packageDownloadTarget).matching { include("**/$artifactPattern") }
57+
copy {
58+
from(files.files)
59+
into(outputDir)
60+
}
61+
}
62+
outputs.dir(outputDir)
63+
}
4564
}
4665

47-
val runBenchmarksBasedTests = project.booleanProperty("z3.runBenchmarksBasedTests") ?: true
66+
val runBenchmarksBasedTests = project.booleanProperty("z3.runBenchmarksBasedTests") ?: false
4867

4968
// skip big benchmarks to achieve faster tests build and run time
5069
val skipBigBenchmarks = project.booleanProperty("z3.skipBigBenchmarks") ?: true
@@ -108,7 +127,7 @@ tasks.withType<Test> {
108127
tasks.withType<ShadowJar> {
109128
archiveClassifier.set("")
110129
dependencies {
111-
include(dependency(z3JavaJar))
130+
include(dependency(z3JavaJar.outputFiles))
112131
}
113132
val implementation = project.configurations["implementation"].dependencies.toSet()
114133
val runtimeOnly = project.configurations["runtimeOnly"].dependencies.toSet()
@@ -124,3 +143,9 @@ publishing {
124143
}
125144
}
126145
}
146+
147+
val TaskProvider<Task>.outputDirectory: File
148+
get() = get().outputs.files.singleFile
149+
150+
val TaskProvider<Task>.outputFiles: FileTree
151+
get() = fileTree(outputDirectory)

0 commit comments

Comments
 (0)