@@ -4,7 +4,6 @@ import com.microsoft.z3.Context
4
4
import com.microsoft.z3.Global
5
5
import org.utbot.common.FileUtil
6
6
import java.io.File
7
- import java.nio.file.Files.createTempDirectory
8
7
9
8
abstract class Z3Initializer : AutoCloseable {
10
9
protected val context: Context by lazy {
@@ -27,27 +26,30 @@ abstract class Z3Initializer : AutoCloseable {
27
26
val arch = System .getProperty(" os.arch" )
28
27
require(arch in supportedArchs) { " Not supported arch: $arch " }
29
28
30
- val osProperty = System .getProperty(" os.name" ).toLowerCase ()
29
+ val osProperty = System .getProperty(" os.name" ).lowercase ()
31
30
val (ext, allLibraries) = when {
32
31
osProperty.startsWith(" windows" ) -> " .dll" to vcWinLibrariesToLoadBefore + libraries
33
32
osProperty.startsWith(" linux" ) -> " .so" to libraries
34
33
osProperty.startsWith(" mac" ) -> " .dylib" to libraries
35
34
else -> error(" Unknown OS: $osProperty " )
36
35
}
37
- val libZ3DllUrl = Z3Initializer ::class .java
36
+
37
+ val dist = if (arch == " aarch64" ) " arm" else " x64"
38
+
39
+ val libZ3FilesUrl = Z3Initializer ::class .java
38
40
.classLoader
39
- .getResource(" lib/x64 /libz3.dll " ) ? : error(" Can't find native library folder" )
41
+ .getResource(" lib/$dist /libz3$ext " ) ? : error(" Can't find native library folder" )
40
42
// can't take resource of parent folder right here because in obfuscated jar parent folder
41
43
// can be missed (e.g., in case if obfuscation was applied)
42
44
43
45
val libFolder: String?
44
- if (libZ3DllUrl .toURI().scheme == " jar" ) {
46
+ if (libZ3FilesUrl .toURI().scheme == " jar" ) {
45
47
val tempDir = FileUtil .createTempDirectory(" libs-" ).toFile()
46
48
47
49
allLibraries.forEach { name ->
48
50
Z3Initializer ::class .java
49
51
.classLoader
50
- .getResourceAsStream(" lib/x64 /$name$ext " )
52
+ .getResourceAsStream(" lib/$dist /$name$ext " )
51
53
?.use { input ->
52
54
File (tempDir, " $name$ext " )
53
55
.outputStream()
@@ -57,7 +59,7 @@ abstract class Z3Initializer : AutoCloseable {
57
59
58
60
libFolder = " $tempDir "
59
61
} else {
60
- libFolder = File (libZ3DllUrl .file).parent
62
+ libFolder = File (libZ3FilesUrl .file).parent
61
63
}
62
64
63
65
allLibraries.forEach { System .load(" $libFolder /$it$ext " ) }
0 commit comments