|
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 | +' Path resolution, fast path first: |
| 6 | +' 1. If iview_app.jl sits right next to this script (running in place -- a dev checkout, or |
| 7 | +' inside a live Pkg package folder), use this script's own folder. Zero overhead, exactly |
| 8 | +' one julia.exe launch, same speed as always. |
| 9 | +' 2. Only if this is a DETACHED copy (e.g. sitting on your Desktop, so iview_app.jl is NOT next |
| 10 | +' to it) does it look for a live install, checking BOTH possible locations: |
| 11 | +' a. `] dev`-installed: a FIXED directory (<depot>\dev\InteractiveGMT), no scanning needed. |
| 12 | +' b. `] add`-installed: a content-hashed folder (<depot>\packages\InteractiveGMT\<hash>) |
| 13 | +' that gets a NEW hash on every Pkg.update -- scan for the newest-modified one. |
| 14 | +' This is a plain filesystem check, not a Julia subprocess -- still only one julia.exe |
| 15 | +' launch total, never two. |
| 16 | +' |
| 17 | +' (An earlier version asked Julia itself, via a second julia.exe subprocess, to resolve the path |
| 18 | +' on every launch -- correct, but doubled startup time. Don't reintroduce that.) |
| 19 | +' |
5 | 20 | ' Files dropped ONTO the desktop shortcut arrive here as WScript.Arguments; we forward each path |
6 | 21 | ' to Julia, and iview_app.jl opens it (otherwise, with no args, it opens an empty launcher). |
7 | | -' sh.Run """C:\programs\Julia-1.10\bin\julia.exe"" --project=""C:\Users\j\.julia\dev\InteractiveGMT"" ""C:\Users\j\.julia\dev\InteractiveGMT\iview_app.jl""" & extra, 7, False |
8 | | -Dim sh : Set sh = CreateObject("WScript.Shell") |
| 22 | +Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") |
| 23 | +Dim sh : Set sh = CreateObject("WScript.Shell") |
| 24 | + |
| 25 | +Dim here : here = fso.GetParentFolderName(WScript.ScriptFullName) |
| 26 | + |
| 27 | +Dim devPath, depot, diag, subFoldersScanned |
| 28 | +devPath = "" : depot = "" : diag = "" |
| 29 | +subFoldersScanned = 0 |
| 30 | + |
| 31 | +If Not fso.FileExists(here & "\iview_app.jl") Then |
| 32 | + ' Detached copy -- find the live InteractiveGMT install. |
| 33 | + ' |
| 34 | + ' Depot root: respect JULIA_DEPOT_PATH if set (Julia checks this env var itself; a |
| 35 | + ' customized depot location is real, not hypothetical -- this same machine already turned |
| 36 | + ' out to have Desktop silently redirected by OneDrive). ExpandEnvironmentStrings returns the |
| 37 | + ' literal "%JULIA_DEPOT_PATH%" string unexpanded when the var isn't set, which is how we |
| 38 | + ' detect "not set" here. Windows uses ";" to separate multiple depot paths -- take the first. |
| 39 | + Dim depotRoot : depotRoot = sh.ExpandEnvironmentStrings("%JULIA_DEPOT_PATH%") |
| 40 | + If depotRoot = "%JULIA_DEPOT_PATH%" Then |
| 41 | + depotRoot = sh.ExpandEnvironmentStrings("%USERPROFILE%") & "\.julia" |
| 42 | + ElseIf InStr(depotRoot, ";") > 0 Then |
| 43 | + depotRoot = Left(depotRoot, InStr(depotRoot, ";") - 1) |
| 44 | + End If |
| 45 | + here = "" |
| 46 | + |
| 47 | + ' 1. `] dev` install -- fixed location, check directly first, no scanning. |
| 48 | + devPath = depotRoot & "\dev\InteractiveGMT" |
| 49 | + If fso.FileExists(devPath & "\iview_app.jl") Then |
| 50 | + here = devPath |
| 51 | + Else |
| 52 | + ' 2. `] add` install -- content-hashed depot, scan for the newest match. |
| 53 | + depot = depotRoot & "\packages\InteractiveGMT" |
| 54 | + If fso.FolderExists(depot) Then |
| 55 | + Dim subFolder, best |
| 56 | + best = -1 |
| 57 | + For Each subFolder In fso.GetFolder(depot).SubFolders |
| 58 | + subFoldersScanned = subFoldersScanned + 1 |
| 59 | + If fso.FileExists(subFolder.Path & "\iview_app.jl") Then |
| 60 | + If CDbl(subFolder.DateLastModified) > best Then |
| 61 | + best = CDbl(subFolder.DateLastModified) |
| 62 | + here = subFolder.Path |
| 63 | + End If |
| 64 | + End If |
| 65 | + Next |
| 66 | + End If |
| 67 | + End If |
| 68 | +End If |
| 69 | + |
| 70 | +If here = "" Then |
| 71 | + ' Report exactly what was checked instead of a bare "not found" -- no more guessing/back |
| 72 | + ' and forth needed to diagnose why. |
| 73 | + diag = "Checked dev install: " & devPath & " (not found)" & vbCrLf |
| 74 | + If Not fso.FolderExists(depot) Then |
| 75 | + diag = diag & "Checked add install: depot folder does not exist: " & depot |
| 76 | + Else |
| 77 | + diag = diag & "Checked add install: depot folder exists (" & depot & ")," & vbCrLf & _ |
| 78 | + "scanned " & subFoldersScanned & " subfolder(s), none contained iview_app.jl." |
| 79 | + End If |
| 80 | + MsgBox "Could not locate InteractiveGMT." & vbCrLf & vbCrLf & diag & vbCrLf & vbCrLf & _ |
| 81 | + "Is it added ('] add https://github.com/GenericMappingTools/InteractiveGMT') or dev'd in Julia's default environment?", _ |
| 82 | + vbExclamation, "iGMT" |
| 83 | + WScript.Quit 1 |
| 84 | +End If |
| 85 | + |
| 86 | +' --project=<here> ONLY if <here> has its OWN Manifest.toml (a `] dev`-instantiated checkout -- |
| 87 | +' this dev checkout has one). A plain `Pkg.add`-installed copy in the depot has NO Manifest of |
| 88 | +' its own -- the resolved dependency graph lives only in your DEFAULT environment |
| 89 | +' (~/.julia/environments/v1.10/), where `] add` put it. Pointing --project straight at a bare, |
| 90 | +' Manifest-less package folder forces Julia into an empty/unresolved environment and it tries to |
| 91 | +' re-resolve + precompile the entire dependency tree from scratch, which fails ("Failed to |
| 92 | +' precompile InteractiveGMT..."). Launch bare (no --project) in that case instead, so Julia uses |
| 93 | +' your normal default environment where `Pkg.add` already resolved everything correctly -- same |
| 94 | +' as what a plain interactive `using InteractiveGMT` does. |
| 95 | +Dim projectArg : projectArg = "" |
| 96 | +If fso.FileExists(here & "\Manifest.toml") Then |
| 97 | + projectArg = "--project=" & Chr(34) & here & Chr(34) & " " |
| 98 | +End If |
| 99 | + |
9 | 100 | Dim extra : extra = "" |
10 | 101 | Dim i |
11 | 102 | For i = 0 To WScript.Arguments.Count - 1 |
12 | | - extra = extra & " """ & WScript.Arguments(i) & """" |
| 103 | + extra = extra & " " & Chr(34) & WScript.Arguments(i) & Chr(34) |
13 | 104 | Next |
14 | | -sh.Run """C:\programs\Julia-1.10\bin\julia.exe"" ""C:\Users\j\.julia\dev\InteractiveGMT\iview_app.jl""" & extra, 7, False |
| 105 | +sh.Run "julia " & projectArg & Chr(34) & here & "\iview_app.jl" & Chr(34) & extra, 7, False |
0 commit comments