blob: b978317868909e8223105f4b63dbe315b2503320 [file] [log] [blame]
Tobias Werth218e8f62018-12-13 04:44:35 -08001#!/bin/bash
2
3# Copyright 2018 The Bazel Authors. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# This script creates from the full JDK a minimized version that only contains
18# the specified JDK modules.
19
20set -euo pipefail
21
Tobias Wertha87451a2019-01-29 07:03:58 -080022if [ "$1" == "--allmodules" ]; then
23 shift
24 modules="ALL-MODULE-PATH"
25else
26 modules=$(cat "$2" | paste -sd "," - | tr -d '\r')
27fi
Tobias Werth218e8f62018-12-13 04:44:35 -080028fulljdk=$1
Tobias Werth218e8f62018-12-13 04:44:35 -080029out=$3
30
31UNAME=$(uname -s | tr 'A-Z' 'a-z')
32
33if [[ "$UNAME" =~ msys_nt* ]]; then
34 set -x
35 unzip "$fulljdk"
36 cd zulu*
Tobias Werth218e8f62018-12-13 04:44:35 -080037 ./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
38 --vm=server --strip-debug --no-man-pages \
39 --output reduced
twerth060441f2018-12-20 04:46:27 -080040 cp DISCLAIMER readme.txt legal/java.base/ASSEMBLY_EXCEPTION \
41 reduced/
Tobias Werth290e49b2019-01-16 05:04:40 -080042 # These are necessary for --host_jvm_debug to work.
43 cp bin/dt_socket.dll bin/jdwp.dll reduced/bin
Tobias Werth218e8f62018-12-13 04:44:35 -080044 zip -r -9 ../reduced.zip reduced/
45 cd ..
46 mv reduced.zip "$out"
47else
48 tar xf "$fulljdk"
49 cd zulu*
50 ./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
51 --vm=server --strip-debug --no-man-pages \
52 --output reduced
twerth060441f2018-12-20 04:46:27 -080053 cp DISCLAIMER readme.txt legal/java.base/ASSEMBLY_EXCEPTION \
54 reduced/
Tobias Werth290e49b2019-01-16 05:04:40 -080055 # These are necessary for --host_jvm_debug to work.
56 if [[ "$UNAME" =~ darwin ]]; then
57 cp lib/libdt_socket.dylib lib/libjdwp.dylib reduced/lib
58 else
59 cp lib/libdt_socket.so lib/libjdwp.so reduced/lib
60 fi
Tobias Werth218e8f62018-12-13 04:44:35 -080061 GZIP=-9 tar -zcf ../reduced.tgz reduced
62 cd ..
63 mv reduced.tgz "$out"
64fi