22
22
* Intended to be run with a working directory of the intended package.
23
23
*/
24
24
25
- const fs = require ( 'fs' ) ;
26
25
const 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' ) ;
35
26
const runCommand = require ( './run-command' ) ;
36
27
37
28
// This script should catch and handle all rejected promises.
@@ -41,11 +32,6 @@ process.on('unhandledRejection', error => {
41
32
process . exit ( 1 ) ;
42
33
} ) ;
43
34
44
- // Build graal from source
45
- if ( ! fs . existsSync ( TEMP_PATH ) ) {
46
- fs . mkdirSync ( TEMP_PATH ) ;
47
- }
48
-
49
35
const NATIVE_IMAGE_BUILD_ARGS = [
50
36
'-H:+ReportUnsupportedElementsAtRuntime' ,
51
37
'-H:IncludeResourceBundles=org.kohsuke.args4j.Messages' ,
@@ -54,7 +40,7 @@ const NATIVE_IMAGE_BUILD_ARGS = [
54
40
'-H:+AllowIncompleteClasspath' ,
55
41
`-H:ReflectionConfigurationFiles=${ path . resolve ( __dirname , 'reflection-config.json' ) } ` ,
56
42
'-H:IncludeResources=(externs.zip)|(.*(js|txt|typedast))' . replace ( / [ \| \( \) ] / g, ( match ) => {
57
- if ( GRAAL_OS === 'windows ' ) {
43
+ if ( process . platform === 'win32 ' ) {
58
44
// Escape the '|' character in a windows batch command
59
45
// See https://stackoverflow.com/a/16018942/1211524
60
46
if ( match === '|' ) {
@@ -69,45 +55,8 @@ const NATIVE_IMAGE_BUILD_ARGS = [
69
55
'-jar' ,
70
56
path . resolve ( process . cwd ( ) , 'compiler.jar' )
71
57
] ;
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' : '' } ` ) ;
108
58
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 )
111
60
. catch ( e => {
112
61
console . error ( e ) ;
113
62
process . exit ( 1 ) ;
0 commit comments