-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix: use native api to enable windows ansi support #4103
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleAPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.quarkus.runtime.logging; | ||
|
||
import org.graalvm.nativeimage.Platform; | ||
import org.graalvm.nativeimage.Platforms; | ||
import org.graalvm.nativeimage.c.CContext; | ||
import org.graalvm.nativeimage.c.function.CFunction; | ||
import org.graalvm.nativeimage.c.type.CIntPointer; | ||
import org.graalvm.word.Pointer; | ||
|
||
@CContext(WindowsConsoleDirectives.class) | ||
@Platforms(Platform.WINDOWS.class) | ||
public class ConsoleAPI { | ||
|
||
static final int STD_INPUT_HANDLE = -10; | ||
static final int STD_OUTPUT_HANDLE = -11; | ||
static final int STD_ERROR_HANDLE = -12; | ||
|
||
static final int ENABLE_PROCESSED_INPUT = 0x0001; | ||
static final int ENABLE_LINE_INPUT = 0x0002; | ||
static final int ENABLE_ECHO_INPUT = 0x0004; | ||
static final int ENABLE_WINDOW_INPUT = 0x0008; | ||
static final int ENABLE_MOUSE_INPUT = 0x0010; | ||
static final int ENABLE_INSERT_MODE = 0x0020; | ||
static final int ENABLE_QUICK_EDIT_MODE = 0x0040; | ||
static final int ENABLE_EXTENDED_FLAGS = 0x0080; | ||
|
||
// HANDLE WINAPI GetStdHandle( | ||
// __in DWORD nStdHandle | ||
// ); | ||
@CFunction | ||
public static native Pointer GetStdHandle(int nStdHandle); | ||
|
||
// BOOL WINAPI SetConsoleMode( | ||
// _In_ HANDLE hConsoleHandle, | ||
// _In_ DWORD dwMode); | ||
@CFunction | ||
public static native int SetConsoleMode(Pointer hConsoleHandle, int dwMode); | ||
|
||
// BOOL WINAPI GetConsoleMode( | ||
// _In_ HANDLE hConsoleHandle, | ||
// _Out_ LPDWORD lpMode); | ||
@CFunction | ||
public static native void GetConsoleMode(Pointer hConsoleHandle, CIntPointer dwMode); | ||
|
||
/** | ||
* kernel32 = ctypes.windll.kernel32 | ||
* kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) | ||
**/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/runtime/src/main/java/io/quarkus/runtime/logging/WindowsConsoleDirectives.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.quarkus.runtime.logging; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.graalvm.nativeimage.Platform; | ||
import org.graalvm.nativeimage.Platforms; | ||
import org.graalvm.nativeimage.c.CContext; | ||
|
||
import com.oracle.svm.core.util.VMError; | ||
|
||
@Platforms(Platform.WINDOWS.class) | ||
public class WindowsConsoleDirectives implements CContext.Directives { | ||
|
||
private static final String[] windowsLibs = new String[] { "<windows.h>" }; | ||
|
||
@Override | ||
public boolean isInConfiguration() { | ||
return Platform.includedIn(Platform.WINDOWS.class); | ||
} | ||
|
||
@Override | ||
public List<String> getHeaderFiles() { | ||
if (Platform.includedIn(Platform.WINDOWS.class)) { | ||
List<String> result = new ArrayList<>(Arrays.asList(windowsLibs)); | ||
return result; | ||
} else { | ||
throw VMError.shouldNotReachHere("Unsupported OS"); | ||
} | ||
} | ||
|
||
@Override | ||
public List<String> getMacroDefinitions() { | ||
return Arrays.asList("_WIN64"); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently I'm getting an error I highly assumes is missing header files but not sure.
Error is:
waiting for oracle/graal#1675 to be fixed or someone magically figuring out what is wrong ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show the content of
C:\Users\max\AppData\Local\Temp\SVM-3772467201033451472\NativeInfoDirectives.cpp
?