Skip to content

Commit 3b0727d

Browse files
committed
increase graalvm-native-image exception logging; native-image.cmd instead of .exe
1 parent c14164b commit 3b0727d

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

modules/core/src/main/scala/scala/build/internals/NativeWrapper.scala

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,12 @@ object MsvcEnvironment {
6767
logger.message(s"$entry;")
6868
}
6969

70-
// Replace native-image.cmd with native-image.exe, if applicable
71-
val updatedCommand: Seq[String] =
72-
command.headOption match {
73-
case Some(cmd) if cmd.toLowerCase.endsWith("native-image.cmd") =>
74-
val cmdPath = os.Path(cmd, os.pwd)
75-
val graalHome = cmdPath / os.up / os.up
76-
resolveNativeImage(graalHome) match {
77-
case Some(exe) =>
78-
exe.toString +: command.tail
79-
case None =>
80-
command // fall back to the .cmd wrapper
81-
}
82-
case _ =>
83-
command
84-
}
85-
86-
logger.message(s"native-image w/args: $updatedCommand")
87-
88-
val result =
89-
os.proc(updatedCommand)
70+
logger.message(s"native-image w/args: $command")
71+
72+
// request extra info in case of exceptions
73+
val altCommand = insertAfterCp(command, "-H:+ReportExceptionStackTraces")
74+
val result =
75+
os.proc(altCommand)
9076
.call(
9177
cwd = workingDir,
9278
env = finalEnv,
@@ -99,6 +85,16 @@ object MsvcEnvironment {
9985
}
10086
}
10187

88+
def insertAfterCp(cmd: Seq[String], flag: String): Seq[String] =
89+
cmd match {
90+
case exe +: "-cp" +: cp +: rest =>
91+
exe +: "-cp" +: cp +: flag +: rest
92+
case exe +: rest =>
93+
exe +: flag +: rest
94+
case Seq() =>
95+
Seq()
96+
}
97+
10298
def aliasedDriveLetters: Map[Char, String] =
10399
try
104100
val (exitCode, output) = execWindowsCmd(cmdExe, "/c", "subst")
@@ -215,15 +211,6 @@ object MsvcEnvironment {
215211
.toMap
216212
}
217213

218-
private def resolveNativeImage(graalHome: os.Path): Option[os.Path] = {
219-
val candidates = Seq(
220-
graalHome / "lib" / "svm" / "bin" / "native-image.exe",
221-
graalHome / "bin" / "native-image.exe",
222-
graalHome / "native-image.exe"
223-
)
224-
candidates.find(os.exists)
225-
}
226-
227214
private def vcvarsOpt: Option[os.Path] = {
228215
val candidates =
229216
vcVarsCandidates

0 commit comments

Comments
 (0)