Skip to content

Commit 67cdd20

Browse files
committed
#151: macOS support
Created macOS binaries with independent libz3.dylib and libz3java.dylib. Changed Z3Initializer to support macOS binaries. Changed utbot-analytics/build.gradle to use correct os name for macOS.
1 parent efad45c commit 67cdd20

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

utbot-analytics/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ configurations {
66
}
77

88

9-
String classifier = System.getProperty('os.name').toLowerCase().split()[0] + "-x86_64"
9+
def osName = System.getProperty('os.name').toLowerCase().split()[0]
10+
if (osName == "mac") osName = "macosx"
11+
String classifier = osName + "-x86_64"
12+
1013
evaluationDependsOn(':utbot-framework')
1114
compileTestJava.dependsOn tasks.getByPath(':utbot-framework:testClasses')
1215
dependencies {

utbot-framework/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dependencies {
5353

5454
z3native group: 'com.microsoft.z3', name: 'z3-native-win64', version: z3_version, ext: 'zip'
5555
z3native group: 'com.microsoft.z3', name: 'z3-native-linux64', version: z3_version, ext: 'zip'
56+
z3native group: 'com.microsoft.z3', name: 'z3-native-osx', version: z3_version, ext: 'zip'
5657
}
5758

5859
processResources {
18 MB
Binary file not shown.

utbot-framework/src/main/kotlin/org/utbot/engine/z3/Z3initializer.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@ abstract class Z3Initializer : AutoCloseable {
2020
companion object {
2121
private val libraries = listOf("libz3", "libz3java")
2222
private val vcWinLibrariesToLoadBefore = listOf("vcruntime140", "vcruntime140_1")
23-
private const val supportedArch = "amd64"
23+
private val supportedArchs = setOf("amd64", "x86_64")
2424
private val initializeCallback by lazy {
2525
System.setProperty("z3.skipLibraryLoad", "true")
2626
val arch = System.getProperty("os.arch")
27-
require(supportedArch == arch) { "Not supported arch: $arch" }
27+
require(arch in supportedArchs) { "Not supported arch: $arch" }
2828

29-
val osProperty = System.getProperty("os.name")
29+
val osProperty = System.getProperty("os.name").toLowerCase()
3030
val (ext, allLibraries) = when {
31-
osProperty.startsWith("Windows") -> ".dll" to vcWinLibrariesToLoadBefore + libraries
32-
osProperty.startsWith("Linux") -> ".so" to libraries
31+
osProperty.startsWith("windows") -> ".dll" to vcWinLibrariesToLoadBefore + libraries
32+
osProperty.startsWith("linux") -> ".so" to libraries
33+
osProperty.startsWith("mac") -> ".dylib" to libraries
3334
else -> error("Unknown OS: $osProperty")
3435
}
3536
val libZ3DllUrl = Z3Initializer::class.java
3637
.classLoader
3738
.getResource("lib/x64/libz3.dll") ?: error("Can't find native library folder")
38-
//can't take resource of parent folder right here because in obfuscated jar parent folder
39+
// can't take resource of parent folder right here because in obfuscated jar parent folder
3940
// can be missed (e.g., in case if obfuscation was applied)
4041

4142
val libFolder: String?

0 commit comments

Comments
 (0)