Repository navigation
Expand file tree
/
Copy pathbuild_java_runtime.py
More file actions
73 lines (64 loc) · 1.79 KB
/
Copy pathbuild_java_runtime.py
File metadata and controls
73 lines (64 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from collections.abc import Collection
from shutil import rmtree
from subprocess import run
from typing import Final, Literal, TypeAlias, get_args
from jdk4py import JAVA_HOME
_ADDED_MODULES: Final = frozenset(
{
"java.se",
"jdk.crypto.ec",
"jdk.httpserver",
"jdk.jcmd",
"jdk.jdwp.agent",
"jdk.jfr",
"jdk.localedata",
"jdk.management.agent",
"jdk.management.jfr",
"jdk.net",
"jdk.security.auth",
"jdk.unsupported",
"jdk.zipfs",
},
)
_RegionSpecificLocale: TypeAlias = Literal[
"bn-IN",
"da-DK",
"de-DE",
"en-GB",
"en-US",
"es-ES",
"es-MX",
"fr-FR",
"it-IT",
"ja-JP",
"pt-BR",
"ru-RU",
"zh-CN",
]
_REGION_SPECIFIC_LOCALES: Final[Collection[str]] = get_args(_RegionSpecificLocale)
_INCLUDED_LOCALES: Final = frozenset(
{
locale
for tag in _REGION_SPECIFIC_LOCALES
# Expand each region-specific locale to also include its language-only locale so that `jlink --include-locales` retains the language-only locale bundles (e.g. `FormatData_fr.class`).
# See https://github.com/openjdk/jdk/blob/jdk-25%2B35/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java.
for locale in (tag, tag.split("-", maxsplit=1)[0])
},
)
def build_java_runtime() -> None:
rmtree(JAVA_HOME, ignore_errors=True)
run( # noqa: S603
[ # noqa: S607
"jlink",
"--no-man-pages",
"--strip-debug",
"--add-modules",
",".join(_ADDED_MODULES),
f"--include-locales={','.join(_INCLUDED_LOCALES)}",
"--output",
JAVA_HOME,
],
check=True,
)
if __name__ == "__main__":
build_java_runtime()