Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the .exe suffix to output provided by user for graalvm-native-image #2182

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
lwronski marked this conversation as resolved.
Show resolved Hide resolved
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