@@ -16,12 +16,20 @@ import scala.util.Properties
16
16
17
17
object ScalaCli {
18
18
19
+ if (Properties .isWin && isGraalvmNativeImage)
20
+ // have to be initialized before running (new Argv0).get because Argv0SubstWindows uses csjniutils library
21
+ // The DLL loaded by LoadWindowsLibrary is statically linke/d in
22
+ // the Scala CLI native image, no need to manually load it.
23
+ coursier.jniutils.LoadWindowsLibrary .assumeInitialized()
24
+
19
25
val progName = (new Argv0 ).get(" scala-cli" )
20
26
21
- private def checkName (name : String ) =
22
- progName == name ||
23
- progName.endsWith(s " / $name" ) ||
24
- progName.endsWith(File .separator + name)
27
+ private def checkName (name : String ) = {
28
+ val baseProgName = if (Properties .isWin) progName.stripSuffix(" .exe" ) else progName
29
+ baseProgName == name ||
30
+ baseProgName.endsWith(s " / $name" ) ||
31
+ baseProgName.endsWith(File .separator + name)
32
+ }
25
33
26
34
private var isSipScala = checkName(" scala" ) || checkName(" scala-cli-sip" )
27
35
@@ -171,11 +179,6 @@ object ScalaCli {
171
179
if (! Properties .isWin && isGraalvmNativeImage)
172
180
ignoreSigpipe()
173
181
174
- if (Properties .isWin && isGraalvmNativeImage)
175
- // The DLL loaded by LoadWindowsLibrary is statically linked in
176
- // the Scala CLI native image, no need to manually load it.
177
- coursier.jniutils.LoadWindowsLibrary .assumeInitialized()
178
-
179
182
if (Properties .isWin && System .console() != null && coursier.paths.Util .useJni())
180
183
// Enable ANSI output in Windows terminal
181
184
coursier.jniutils.WindowsAnsiTerminal .enableAnsiOutput()
0 commit comments