Skip to content

Commit

Permalink
Add build-time configuration for nativeimage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Aug 15, 2024
1 parent 4fdc96b commit 22d90ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.github.ajalt.mordant.terminal.terminalinterface
import com.github.ajalt.mordant.rendering.Size
import java.lang.foreign.*

internal object WinLayouts {
private object WinLayouts {
val HANDLE: AddressLayout = Layouts.POINTER
val WORD: ValueLayout.OfShort = ValueLayout.JAVA_SHORT
val DWORD: ValueLayout.OfInt = Layouts.INT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Args = -H:+UnlockExperimentalVMOptions \
-H:ResourceConfigurationResources=${.}/resource-config.json \
-H:ReflectionConfigurationResources=${.}/reflection-config.json
-H:ReflectionConfigurationResources=${.}/reflection-config.json \
--initialize-at-build-time=com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfacePosix$Companion \
--initialize-at-build-time=com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfacePosix$TermiosConstants \
--initialize-at-build-time=com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceProviderNativeImage \
--initialize-at-build-time=com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceNativeImageLinux \
--initialize-at-build-time=com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceNativeImageMacos \
--initialize-at-build-time=com.github.ajalt.mordant.terminal.terminalinterface.TerminalInterfaceNativeImageWindows \
--initialize-at-build-time=com.github.ajalt.mordant.internal.MppInternal_jvmKt \
--initialize-at-build-time=com.github.ajalt.mordant.internal.MppInternalKt
9 changes: 4 additions & 5 deletions test/graalvm/src/test/kotlin/GraalSmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ import kotlin.test.fail
* They just make sure nothing crashes; the actual output is verified in the normal test suite.
*/
class GraalSmokeTest {
// It would be nice to have more graal-specific assertions, but the nativeTest task actually
// runs all the tests twice, the first time on regular JVM to detect tests, then a second time
// on native. So any assertions about environment would have to handle that.
@Test
fun `terminal detection test`() {
val name = Terminal().terminalInterface::class.simpleName
val assertion = name!!.startsWith("TerminalInterfaceNativeImage")
if (!assertion) {
fail("Incorrect terminal interface: $name")
}
Terminal()
}

@Test
Expand Down

0 comments on commit 22d90ce

Please sign in to comment.