Skip to content

Commit 7205cd5

Browse files
authored
Add the .exe suffix to output provided by user for graalvm-native-image (#2182)
1 parent dcc8dc1 commit 7205cd5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

modules/cli/src/main/scala/scala/cli/commands/package0/Package.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,16 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
268268
case _ if Properties.isWin => "app.bat"
269269
case _ => "app"
270270
}
271+
val output = outputOpt.map {
272+
case path
273+
if packageType == PackageType.GraalVMNativeImage
274+
&& Properties.isWin && !path.endsWith(".exe") =>
275+
s"$path.exe" // graalvm-native-image requires .exe extension on Windows
276+
case path => path
277+
}
271278

272279
val packageOutput = build.options.notForBloopOptions.packageOptions.output
273-
val dest = outputOpt.orElse(packageOutput)
280+
val dest = output.orElse(packageOutput)
274281
.orElse {
275282
build.sources.defaultMainClass
276283
.map(n => n.drop(n.lastIndexOf('.') + 1))

modules/integration/src/test/scala/scala/cli/integration/PackageTestDefinitions.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ abstract class PackageTestDefinitions(val scalaVersionOpt: Option[String])
808808

809809
test("native image") {
810810
val message = "Hello from native-image"
811-
val dest =
811+
val dest = "hello"
812+
val actualDest =
812813
if (Properties.isWin) "hello.exe"
813814
else "hello"
814815
val inputs = TestInputs(
@@ -837,11 +838,11 @@ abstract class PackageTestDefinitions(val scalaVersionOpt: Option[String])
837838
stdout = os.Inherit
838839
)
839840

840-
expect(os.isFile(root / dest))
841+
expect(os.isFile(root / actualDest))
841842

842843
// FIXME Check that dest is indeed a binary?
843844

844-
val res = os.proc(root / dest).call(cwd = root)
845+
val res = os.proc(root / actualDest).call(cwd = root)
845846
val output = res.out.trim()
846847
expect(output == message)
847848
}

0 commit comments

Comments
 (0)