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

Commit 6977559

Browse files
Use more specific patterns for matching included resources
Avoids including hundreds of MBs of javadoc in the native image binaries
1 parent e3d5862 commit 6977559

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ jobs:
4343
with:
4444
submodules: recursive
4545
ref: ${{ inputs.release-tag || '' }}
46-
- name: Fetch submodule tags
47-
working-directory: compiler
48-
run: git fetch --tags https://github.com/google/closure-compiler.git
4946
- name: Get yarn cache directory path
5047
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
5148
- name: Yarn and maven cache
@@ -109,12 +106,6 @@ jobs:
109106
distribution: 'graalvm-community'
110107
github-token: ${{ secrets.GITHUB_TOKEN }}
111108
native-image-job-reports: 'true'
112-
- name: Setup upx
113-
run: |
114-
UPX_VERSION=5.0.0
115-
curl --fail --show-error --location --remote-name "https://github.com/upx/upx/releases/download/v$UPX_VERSION/upx-$UPX_VERSION-amd64_linux.tar.xz"
116-
tar -xf upx-$UPX_VERSION-amd64_linux.tar.xz
117-
mv ./upx-$UPX_VERSION-amd64_linux/upx /usr/local/bin/upx
118109
- name: Download compiler jar
119110
uses: actions/download-artifact@v4
120111
with:
@@ -147,7 +138,6 @@ jobs:
147138
run: |
148139
cp ../google-closure-compiler-java/compiler.jar compiler.jar
149140
yarn run build
150-
upx compiler
151141
- name: Tests
152142
run: yarn workspaces run test --color
153143
- name: Upload artifacts
@@ -187,12 +177,6 @@ jobs:
187177
distribution: 'graalvm-community'
188178
github-token: ${{ secrets.GITHUB_TOKEN }}
189179
native-image-job-reports: 'true'
190-
- name: Setup upx
191-
run: |
192-
UPX_VERSION=5.0.0
193-
curl --fail --show-error --location --remote-name "https://github.com/upx/upx/releases/download/v$UPX_VERSION/upx-$UPX_VERSION-arm64_linux.tar.xz"
194-
tar -xf upx-$UPX_VERSION-arm64_linux.tar.xz
195-
mv ./upx-$UPX_VERSION-arm64_linux/upx /usr/local/bin/upx
196180
- name: Download compiler jar
197181
uses: actions/download-artifact@v4
198182
with:
@@ -225,7 +209,6 @@ jobs:
225209
run: |
226210
cp ../google-closure-compiler-java/compiler.jar compiler.jar
227211
yarn run build
228-
upx compiler
229212
- name: Tests
230213
run: yarn workspaces run test --color
231214
- name: Upload artifacts
@@ -263,9 +246,6 @@ jobs:
263246
distribution: 'graalvm-community'
264247
github-token: ${{ secrets.GITHUB_TOKEN }}
265248
native-image-job-reports: 'true'
266-
# # See https://github.com/google/closure-compiler-npm/issues/265
267-
# - name: Install upx
268-
# run: brew install upx
269249
- name: Download compiler jar
270250
uses: actions/download-artifact@v4
271251
with:
@@ -298,7 +278,6 @@ jobs:
298278
run: |
299279
cp ../google-closure-compiler-java/compiler.jar compiler.jar
300280
yarn run build
301-
# upx compiler
302281
- name: Tests
303282
run: yarn workspaces run test --color
304283
- name: Upload artifacts

build-scripts/graal.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,29 @@ process.on('unhandledRejection', error => {
3434
process.exit(1);
3535
});
3636

37+
const windowsPathReplacer = (match) => {
38+
if (process.platform === 'win32') {
39+
// Escape the '|' character in a windows batch command
40+
// See https://stackoverflow.com/a/16018942/1211524
41+
if (match === '|') {
42+
return '^^^|';
43+
}
44+
return `^${match}`;
45+
}
46+
return '|';
47+
};
48+
3749
const NATIVE_IMAGE_BUILD_ARGS = [
3850
'-H:+ReportUnsupportedElementsAtRuntime',
3951
'-H:IncludeResourceBundles=org.kohsuke.args4j.Messages',
4052
'-H:IncludeResourceBundles=org.kohsuke.args4j.spi.Messages',
4153
'-H:IncludeResourceBundles=com.google.javascript.jscomp.parsing.ParserConfig',
4254
'-H:+AllowIncompleteClasspath',
4355
`-H:ReflectionConfigurationFiles=${path.resolve(__dirname, 'reflection-config.json')}`,
44-
'-H:IncludeResources=(externs.zip)|(.*(js|txt|typedast))'.replace(/[\|\(\)]/g, (match) => {
45-
if (process.platform === 'win32') {
46-
// Escape the '|' character in a windows batch command
47-
// See https://stackoverflow.com/a/16018942/1211524
48-
if (match === '|') {
49-
return '^^^|';
50-
}
51-
return `^${match}`;
52-
}
53-
return '|';
54-
}),
56+
'-H:IncludeResources=externs\.zip'.replace(/[\|\(\)]/g, windowsPathReplacer),
57+
'-H:IncludeResources=com\/google\/javascript\/.*\.js'.replace(/[\|\(\)]/g, windowsPathReplacer),
58+
'-H:IncludeResources=com\/google\/javascript\/.*\.txt'.replace(/[\|\(\)]/g, windowsPathReplacer),
59+
'-H:IncludeResources=com\/google\/javascript\/.*\.typedast'.replace(/[\|\(\)]/g, windowsPathReplacer),
5560
'-H:+ReportExceptionStackTraces',
5661
'--initialize-at-build-time',
5762
'--color=always',

0 commit comments

Comments
 (0)