-
Notifications
You must be signed in to change notification settings - Fork 27
Conversation
Thanks for your interest in palantir/gradle-graal, @frozenice! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
The tests work on Linux, if you install |
I just noticed that the |
getExecutable: add extension on Windows getArchitectureSpecifiedBinaryPath: add Windows (same as Linux)
ignore RC tests on Windows use System.lineSeparator() instead of \n syntax cleanup compare only the path of mock requests
Seeing that #119 got merged, I rebased and added some more changes (I updated the description). Building works on my Windows (also tried with Graal 19.1.1). CircleCI seems happy, too! |
Any chance this can be looked at? Maybe @markelliot? |
I would add following to README.md: Preconditions when using on WindowsGraalVM needs the Microsoft Windows SDK for Windows 7 and .NET Framework 4 as well as the C compilers from KB2519277. You can install it using chocolatey:
|
@frozenice I wonder how "extractGraal()" works on your machine. Here, I get following tar output when trying locally: $ tar -xzf graalvm-ce-19.0.2-amd64.zip
tar: This does not look like a tar archive I included |
@koppor I wondered about that, too. :) I'll take a look at your unzip logic and README changes 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.
Thanks for submitting this!
Would be interested in your thoughts on my comments -- am generally happy to adopt as-is, if you were interested in some refactoring first that'd be helpful, but good either way.
src/main/java/com/palantir/gradle/graal/BaseGraalCompileTask.java
Outdated
Show resolved
Hide resolved
Yep, the standard fix here is to use |
The thing is, I do want to use the default charset for the current platform, because I'm executing a native command which, I assume, also uses the platform's default charset. I'll leave this as-is for now, as it's only a warning. |
I get following output when running
|
Good news everyone! I re(-)searched how to unzip an archive via Gradle APIs (without creating a new As per @markelliot's suggestion, .cmd binary names are now in a I'm not sure what to put into the readme, yet. If we list explicit preconditions for Windows, we should also list them for the other platforms, but they might change (link). If we don't want to list the explicit items, we should include the link to the Graal docs. @koppor's readme changes include some links, though. Also check the review comments btw. |
Cool, happy to take this and a README update later. Good to merge? |
- hide SetEnv.cmd ouput if Gradle is not running verbosely - split long lines, fix style errors - remove unused variable
We replaced my custom registry stuff with @koppor's temporary script file stuff. This is definitely more maintainable. CircleCI tests look good, I also tested with Graal 19.2.0 locally. I created two tracking issues (#141, #142) for the two unresolved items we discussed. @markelliot Ready to merge! |
Hi there,
This PR adds Windows support to the only Gradle GraalVM plugin (this one!) - a much needed feature, I imagine (using Windows myself and experimenting with GraalVM). With this PR
gradle-graal
supports building native images and shared libraries on Windows, if you install the prerequisites GraalVM needs.I haven't opened an issue, because discussing this code directly instead of theoretically seems better.
How to test
Install the required dependencies for GraalVM to work on windows (see substratevm/README.md) and make sure GraalVM can successfully compile something standalone (remember to use the Windows SDK Command Prompt when running
native-image
directly).windows
branchpublishToMavenLocal
printVersion
, this will print something like0.3.0-38-g2b56d74
mavenLocal()
and the locally published plugin to the buildscript dependencies, e.g.:gradle-graal
via aplugins
block or otherwisegraal
extension, e.g.:mainClassName
with a string containing your entry class name if you haven't applied theapplication
plugin)nativeImage
, it will print the output location (thesharedLibrary
task also works)Changes
DownloadGraalTask
Enabling the download of the windows archive required adding a
WINDOWS
case togetOperatingSystem
and a newgetArchiveExtension
method (it's.zip
on Windows).There is a new
[ext]
placeholder, which is used inARTIFACT_PATTERN_RELEASE_VERSION
(RC versions don't have a Windows variant) andFILENAME_PATTERN
. It's replaced inrender
.ExtractGraalTask
The recent version 19 support added
getExecutable
andgetArchitectureSpecifiedBinaryPath
. I added Windows support to those (a bit of complexity arose, because some executables in the GraalVM Windows distribution have .cmd as an extension, others have .exe).BaseGraalCompileTask
I added an abstract method
getArchitectureSpecifiedOutputExtension
so subclasses (NativeImageTask
andSharedLibraryTask
) can specify the platform-dependant file extension for their output.There is also a new
getArchitectureSpecifiedPathSeparator
method, because path separators differ (;
in Windows,:
on Unix).A
WINDOWS
case was added togetArchitectureSpecifiedBinaryPath
, so it finds thenative-image
command.To overcome the need for running inside the Windows SDK Command Prompt (
SetEnv.cmd
) I replicated the environment variables configuration, stripped to a minimum (it sets the following environment variables when launchingnative-image
:CL
,PATH
,LIB
,LIBPATH
,INCLUDE
,APPVER
).To do this, it needs to read some values from the Windows registry. This is done in
readWindowsRegistryString
, which is a very simple (but sufficient) wrapper around reg.exe to query a value from the registry.fileSizeMegabytes
was lifted fromNativeImageTask
so it can be used in all subclasses.NativeImageTask
The overriden method
getArchitectureSpecifiedOutputExtension
returns.exe
on Windows and an empty string on Linux and Mac.configurePlatformSpecifics
is called in the@TaskAction
.SharedLibraryTask
Basically the same as
NativeImageTask
, the extensions ingetArchitectureSpecifiedOutputExtension
are different, though.Oh, and I also added the
LogAction
, like inNativeImageTask
.Tests
I upgraded some GraalVM version that's used in tests to the current
19.1.0
(it must be 19+ so the tests can run on Windows).Some cross-platform enhancements include:
.exe
anddll
for the output file extensions on Windows (could usegetArchitectureSpecifiedOutputExtension
too)\n
s withSystem.lineSeparator()
gradle.properties
fileAllowing bothlocalhost
and127.0.0.1
inrequestUrl
returned by the mock serverThe tests allows specifying different RC graal version, test 1.0.0-rc5 nativeImage and can build shared libraries on 1.0.0-rc5 are now ignored on Windows, because there is no GraalVM RC version for Windows.
The test allows specifying different GA graal version was split into a version for Windows and another version for Linux / Mac. There are some things that are different on Windows. This looks a bit like duplicate code (which it is), but parameterizing all the places looked a bit much.
Notes
There are some baseline warnings.
SwitchStatementDefaultCase
was already present,DefaultCharset
is new, but I'm not sure what to do about it. Of course it needs to use the default platform charset to read the command output! UsingCharset.defaultCharset()
produced another warning.I haven't run tests on Linux or Mac yet.
Cheers 🍺
David