|
1 | | -import std/os |
2 | | -import std/strutils |
| 1 | +import std/[os, strutils, strformat] |
3 | 2 |
|
4 | 3 | when defined(windows): |
5 | 4 | {.error: "Compilation on windows is not supported.".} |
@@ -32,23 +31,34 @@ when defined(nimjl_cross_compile): |
32 | 31 | JuliaLibPattern = JuliaLibPath / libPrefix & "julia*" & libSuffix |
33 | 32 | prefixLen = len(libPrefix)+len("julia")+1 # length of the string 'libjulia.' |
34 | 33 | suffixLen = len(libSuffix) |
35 | | - JlVersionCmd = fmt"cd {JuliaLibPath} && name=$(echo libjulia.*.*.*.dylib); vers=$\{name:{prefixLen}:-{suffixLen}\}; echo $vers" |
36 | | -else: |
37 | | - const JlVersionCmd = JuliaPath / "bin" / "julia" & " -E VERSION" |
38 | 34 |
|
39 | | -const (cmdOutput, exitCode) = gorgeEx(JlVersionCmd) |
40 | | -static: |
41 | | - echo "Nimjl> ", JuliaPath |
42 | | -when exitCode != 0: |
43 | | - {.error: "Nimjl> Fatal error ! Julia could not be found on your system.".} |
| 35 | + const JlVersionCmd = &"fullname=$(echo {JuliaLibPath}/libjulia.*.*.*.dylib); name=$(basename ${{fullname}}); vers=${{name:{prefixLen}:{suffixLen} }}; echo $vers" |
| 36 | + const (cmdOutput, exitCode) = gorgeEx(JlVersionCmd) |
| 37 | + when exitCode != 0: |
| 38 | + {.error: "Nimjl> Fatal error ! Julia could not be found on your system.".} |
| 39 | + # The bash line is just paramters expansion + string substitution to extract the version from the name |
| 40 | + # This assumes the files is always called : libjulia.so OR libjulia.dylib for osx |
| 41 | + const JuliaArrayVersion* = cmdOutput.split(".") |
| 42 | + const JuliaMajorVersion* = JuliaArrayVersion[0].parseInt() |
| 43 | + const JuliaMinorVersion* = JuliaArrayVersion[1].parseInt() |
| 44 | + const JuliaPatchVersion* = JuliaArrayVersion[2].parseInt() |
44 | 45 |
|
45 | | -const JuliaArrayVersion* = cmdOutput.split("\"")[1].split(".") |
46 | 46 |
|
| 47 | +else: |
| 48 | + const JlVersionCmd = JuliaPath / "bin" / "julia" & " -E VERSION" |
| 49 | + const (cmdOutput, exitCode) = gorgeEx(JlVersionCmd) |
| 50 | + when exitCode != 0: |
| 51 | + {.error: "Nimjl> Fatal error ! Julia could not be found on your system.".} |
| 52 | + const JuliaArrayVersion* = cmdOutput.split("\"")[1].split(".") |
47 | 53 | # For release : result has the form ["v", "1.6.0", ""] -> splitting [1] yields ["1", "6, "0"] |
48 | 54 | # For dev: result has the form ["v", "1.7.0-DEV", "667"] -> splitting [1] yields ["1", "7, "0-DEV", "667"] |
49 | | -const JuliaMajorVersion* = JuliaArrayVersion[0].parseInt() |
50 | | -const JuliaMinorVersion* = JuliaArrayVersion[1].parseInt() |
51 | | -const JuliaPatchVersion* = JuliaArrayVersion[2].parseInt() |
| 55 | + const JuliaMajorVersion* = JuliaArrayVersion[0].parseInt() |
| 56 | + const JuliaMinorVersion* = JuliaArrayVersion[1].parseInt() |
| 57 | + const JuliaPatchVersion* = JuliaArrayVersion[2].parseInt() |
| 58 | + |
| 59 | +static: |
| 60 | + echo "Nimjl> ", JuliaPath, ", version:", JuliaMajorVersion, ".", JuliaMinorVersion, ".", JuliaPatchVersion |
| 61 | + |
52 | 62 |
|
53 | 63 | # TODO: handle more platform |
54 | 64 | {.passC: " -DJulia_ENABLE_THREADING=1".} |
|
0 commit comments