Skip to content

Commit

Permalink
Add the .exe suffix to output provided by user for graalvm-native-image
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski committed Jun 2, 2023
1 parent db0dcd5 commit 9d57e5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,16 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
case _ if Properties.isWin => "app.bat"
case _ => "app"
}
val output = outputOpt.map {
case path
if packageType == PackageType.GraalVMNativeImage
&& Properties.isWin && !path.endsWith(".exe") =>
s"$path.exe" // graalvm-native-image requires .exe extension on Windows
case path => path
}

val packageOutput = build.options.notForBloopOptions.packageOptions.output
val dest = outputOpt.orElse(packageOutput)
val dest = output.orElse(packageOutput)
.orElse {
build.sources.defaultMainClass
.map(n => n.drop(n.lastIndexOf('.') + 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,8 @@ abstract class PackageTestDefinitions(val scalaVersionOpt: Option[String])

test("native image") {
val message = "Hello from native-image"
val dest =
val dest = "hello"
val actualDest =
if (Properties.isWin) "hello.exe"
else "hello"
val inputs = TestInputs(
Expand Down Expand Up @@ -837,11 +838,11 @@ abstract class PackageTestDefinitions(val scalaVersionOpt: Option[String])
stdout = os.Inherit
)

expect(os.isFile(root / dest))
expect(os.isFile(root / actualDest))

// FIXME Check that dest is indeed a binary?

val res = os.proc(root / dest).call(cwd = root)
val res = os.proc(root / actualDest).call(cwd = root)
val output = res.out.trim()
expect(output == message)
}
Expand Down

0 comments on commit 9d57e5e

Please sign in to comment.