Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 927d259

Browse files
Merge pull request #247 from google/graal-action
Switch to using the Graal github action
2 parents 3cc8222 + 7399ab4 commit 927d259

File tree

3 files changed

+20
-101
lines changed

3 files changed

+20
-101
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ jobs:
7575
env:
7676
NODE_VERSION: '14.x'
7777
FORCE_COLOR: '1'
78-
GRAAL_VERSION: '22.0.0.2'
79-
GRAAL_URL: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz'
8078
steps:
8179
- name: Setup Java
8280
uses: actions/setup-java@v2
@@ -90,6 +88,12 @@ jobs:
9088
uses: actions/setup-node@v3
9189
with:
9290
node-version: ${{ env.NODE_VERSION }}
91+
- uses: graalvm/setup-graalvm@v1
92+
with:
93+
version: '22.2.0'
94+
java-version: '17'
95+
components: 'native-image'
96+
github-token: ${{ secrets.GITHUB_TOKEN }}
9397
- name: Setup upx
9498
run: |
9599
UPX_VERSION=3.96
@@ -141,8 +145,6 @@ jobs:
141145
env:
142146
NODE_VERSION: '16.x'
143147
FORCE_COLOR: '1'
144-
GRAAL_VERSION: '22.0.0.2'
145-
GRAAL_URL: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz'
146148
steps:
147149
- name: Setup Java
148150
uses: actions/setup-java@v2
@@ -156,6 +158,12 @@ jobs:
156158
uses: actions/setup-node@v3
157159
with:
158160
node-version: ${{ env.NODE_VERSION }}
161+
- uses: graalvm/setup-graalvm@v1
162+
with:
163+
version: '22.2.0'
164+
java-version: '17'
165+
components: 'native-image'
166+
github-token: ${{ secrets.GITHUB_TOKEN }}
159167
- name: Install upx
160168
run: brew install upx
161169
- name: Download compiler jar
@@ -203,8 +211,6 @@ jobs:
203211
env:
204212
NODE_VERSION: '18.x'
205213
FORCE_COLOR: '1'
206-
GRAAL_VERSION: '22.0.0.2'
207-
GRAAL_URL: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-windows-amd64-22.0.0.2.zip'
208214
steps:
209215
- name: Setup Java
210216
uses: actions/setup-java@v2
@@ -218,6 +224,12 @@ jobs:
218224
uses: actions/setup-node@v3
219225
with:
220226
node-version: ${{ env.NODE_VERSION }}
227+
- uses: graalvm/setup-graalvm@v1
228+
with:
229+
version: '22.2.0'
230+
java-version: '17'
231+
components: 'native-image'
232+
github-token: ${{ secrets.GITHUB_TOKEN }}
221233
- name: Download compiler jar
222234
uses: actions/download-artifact@v2
223235
with:
@@ -243,18 +255,7 @@ jobs:
243255
run: yarn install --colors=always
244256
- name: Build image
245257
working-directory: packages/google-closure-compiler-windows
246-
# Enable Visual Studio Build Environment in Powershell
247-
# See https://stackoverflow.com/a/2124759/1211524
248258
run: |
249-
pushd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools"
250-
cmd /c "VsDevCmd.bat -arch=amd64 & set" |
251-
foreach {
252-
if ($_ -match "=") {
253-
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
254-
}
255-
}
256-
popd
257-
Write-Host "`nVisual Studio 2022 Command Prompt variables set." -ForegroundColor Yellow
258259
cp ../google-closure-compiler-java/compiler.jar compiler.jar
259260
yarn run build
260261
- name: Tests

build-scripts/graal-env.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

build-scripts/graal.js

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222
* Intended to be run with a working directory of the intended package.
2323
*/
2424

25-
const fs = require('fs');
2625
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');
3526
const 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-
4935
const 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

Comments
 (0)