2222 * Intended to be run with a working directory of the intended package.
2323 */
2424
25- const fs = require ( 'fs' ) ;
2625const path = require ( 'path' ) ;
27- const {
28- GRAAL_OS ,
29- GRAAL_FOLDER ,
30- GRAAL_VERSION ,
31- GRAAL_PACKAGE_SUFFIX ,
32- GRAAL_URL
33- } = require ( './graal-env' ) ;
34- const TEMP_PATH = path . resolve ( __dirname , '../temp' ) ;
3526const runCommand = require ( './run-command' ) ;
3627
3728// This script should catch and handle all rejected promises.
@@ -41,11 +32,6 @@ process.on('unhandledRejection', error => {
4132 process . exit ( 1 ) ;
4233} ) ;
4334
44- // Build graal from source
45- if ( ! fs . existsSync ( TEMP_PATH ) ) {
46- fs . mkdirSync ( TEMP_PATH ) ;
47- }
48-
4935const NATIVE_IMAGE_BUILD_ARGS = [
5036 '-H:+ReportUnsupportedElementsAtRuntime' ,
5137 '-H:IncludeResourceBundles=org.kohsuke.args4j.Messages' ,
@@ -54,7 +40,7 @@ const NATIVE_IMAGE_BUILD_ARGS = [
5440 '-H:+AllowIncompleteClasspath' ,
5541 `-H:ReflectionConfigurationFiles=${ path . resolve ( __dirname , 'reflection-config.json' ) } ` ,
5642 '-H:IncludeResources=(externs.zip)|(.*(js|txt|typedast))' . replace ( / [ \| \( \) ] / g, ( match ) => {
57- if ( GRAAL_OS === 'windows ' ) {
43+ if ( process . platform === 'win32 ' ) {
5844 // Escape the '|' character in a windows batch command
5945 // See https://stackoverflow.com/a/16018942/1211524
6046 if ( match === '|' ) {
@@ -69,45 +55,8 @@ const NATIVE_IMAGE_BUILD_ARGS = [
6955 '-jar' ,
7056 path . resolve ( process . cwd ( ) , 'compiler.jar' )
7157] ;
72- let buildSteps = Promise . resolve ( ) ;
73- // Download Graal
74- const GRAAL_ARCHIVE_FILE = `${ GRAAL_FOLDER } .${ GRAAL_PACKAGE_SUFFIX } ` ;
75- // Build the compiler native image.
76- let pathParts = [ TEMP_PATH , `graalvm-ce-java11-${ GRAAL_VERSION } ` ] ;
77- if ( GRAAL_OS === 'darwin' ) {
78- pathParts . push ( 'Contents' , 'Home' , 'bin' ) ;
79- } else {
80- pathParts . push ( 'bin' ) ;
81- }
82- const GRAAL_BIN_FOLDER = path . resolve . apply ( null , pathParts ) ;
83- if ( ! fs . existsSync ( path . resolve ( TEMP_PATH , GRAAL_FOLDER ) ) ) {
84- const GRAAL_GU_PATH = path . resolve ( GRAAL_BIN_FOLDER , `gu${ GRAAL_OS === 'windows' ? '.cmd' : '' } ` ) ;
85- buildSteps = buildSteps
86- . then ( ( ) => {
87- // Download graal and extract the contents
88- if ( ! fs . existsSync ( path . resolve ( TEMP_PATH , GRAAL_ARCHIVE_FILE ) ) ) {
89- process . stdout . write ( `Downloading graal from ${ GRAAL_URL } \n` ) ;
90- return runCommand (
91- `curl --fail --show-error --location --progress-bar --output ${ GRAAL_ARCHIVE_FILE } ${ GRAAL_URL } ` ,
92- { cwd : TEMP_PATH } ) ;
93- }
94- } )
95- . then ( ( ) => {
96- if ( GRAAL_PACKAGE_SUFFIX === 'tar.gz' ) {
97- return runCommand ( `tar -xzf ${ GRAAL_ARCHIVE_FILE } ` , { cwd : TEMP_PATH } ) ;
98- }
99- return runCommand ( `7z x -y ${ GRAAL_ARCHIVE_FILE } ` , { cwd : TEMP_PATH } ) ;
100- } )
101- . then ( ( ) => runCommand ( `${ GRAAL_GU_PATH } install native-image` ) ) ;
102- }
103-
104- // Build the compiler native image.
105- const GRAAL_NATIVE_IMAGE_PATH = path . resolve (
106- GRAAL_BIN_FOLDER ,
107- `native-image${ GRAAL_OS === 'windows' ? '.cmd' : '' } ` ) ;
10858
109- buildSteps
110- . then ( ( ) => runCommand ( GRAAL_NATIVE_IMAGE_PATH , NATIVE_IMAGE_BUILD_ARGS ) )
59+ runCommand ( `native-image${ process . platform === 'win32' ? '.cmd' : '' } ` , NATIVE_IMAGE_BUILD_ARGS )
11160 . catch ( e => {
11261 console . error ( e ) ;
11362 process . exit ( 1 ) ;
0 commit comments