|
2 | 2 | ' STARTUPINFO SW_HIDE, which the Qt GUI window would inherit and stay invisible. iview_app.jl |
3 | 3 | ' hides its own console on startup, so only the viewer window remains. |
4 | 4 | ' |
5 | | -' Self-locating (same trick as deps/installer/iview_launch.vbs): finds its own folder at runtime |
6 | | -' instead of hardcoding a julia.exe path + dev checkout path, so this works on any machine/checkout |
7 | | -' without editing. Calls `julia` bare (from PATH) with --project pointed at this same folder. |
| 5 | +' Resolves InteractiveGMT's install path by ASKING JULIA at every launch (Base.find_package — |
| 6 | +' just reads the active project's Manifest, does not load/precompile the package) instead of |
| 7 | +' hardcoding a location. This matters because a git-based Pkg install lives in a content-hashed |
| 8 | +' folder (~/.julia/packages/InteractiveGMT/<hash>/) that gets a NEW <hash> on every |
| 9 | +' `Pkg.update("InteractiveGMT")` — a script that instead finds its OWN folder (fso.GetParentFolderName) |
| 10 | +' would go stale the moment you copy it to a Desktop shortcut and then update. Asking Julia fresh |
| 11 | +' every time means the SAME copy of this file — wherever you put it, including a Desktop shortcut |
| 12 | +' — keeps working across every future update, no re-copying, ever. |
| 13 | +' |
| 14 | +' Also works unmodified for a plain dev checkout (this file run in place): Base.find_package |
| 15 | +' resolves `dev`ed packages from the Manifest too, same as `add`ed ones. |
| 16 | +' |
| 17 | +' The lookup expression is written to a temp .jl file rather than passed inline on the command |
| 18 | +' line, to sidestep Windows/VBScript quote-escaping entirely. |
8 | 19 | ' |
9 | 20 | ' Files dropped ONTO the desktop shortcut arrive here as WScript.Arguments; we forward each path |
10 | 21 | ' to Julia, and iview_app.jl opens it (otherwise, with no args, it opens an empty launcher). |
11 | 22 | Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") |
12 | | -Dim here : here = fso.GetParentFolderName(WScript.ScriptFullName) |
13 | | -Dim sh : Set sh = CreateObject("WScript.Shell") |
| 23 | +Dim sh : Set sh = CreateObject("WScript.Shell") |
| 24 | + |
| 25 | +Dim tmp : tmp = sh.ExpandEnvironmentStrings("%TEMP%") & "\igmt_locate_" & CStr(Timer) & ".jl" |
| 26 | +Dim f : Set f = fso.CreateTextFile(tmp, True) |
| 27 | +f.WriteLine "p = Base.find_package(" & Chr(34) & "InteractiveGMT" & Chr(34) & ")" |
| 28 | +f.WriteLine "print(p === nothing ? " & Chr(34) & Chr(34) & " : dirname(dirname(p)))" |
| 29 | +f.Close |
| 30 | + |
| 31 | +Dim ex : Set ex = sh.Exec("julia --startup-file=no " & Chr(34) & tmp & Chr(34)) |
| 32 | +Dim here : here = Trim(ex.StdOut.ReadAll()) |
| 33 | +fso.DeleteFile tmp, True |
| 34 | + |
| 35 | +If here = "" Then |
| 36 | + MsgBox "Could not locate InteractiveGMT." & vbCrLf & _ |
| 37 | + "Is it added ('] add https://github.com/GenericMappingTools/InteractiveGMT') or dev'd in Julia's default environment?", _ |
| 38 | + vbExclamation, "iGMT" |
| 39 | + WScript.Quit 1 |
| 40 | +End If |
| 41 | + |
14 | 42 | Dim extra : extra = "" |
15 | 43 | Dim i |
16 | 44 | For i = 0 To WScript.Arguments.Count - 1 |
17 | | - extra = extra & " """ & WScript.Arguments(i) & """" |
| 45 | + extra = extra & " " & Chr(34) & WScript.Arguments(i) & Chr(34) |
18 | 46 | Next |
19 | | -sh.Run "julia --project=""" & here & """ """ & here & "\iview_app.jl""" & extra, 7, False |
| 47 | +sh.Run "julia --project=" & Chr(34) & here & Chr(34) & " " & Chr(34) & here & "\iview_app.jl" & Chr(34) & extra, 7, False |
0 commit comments