From 7a2c52b34c2cbe24b02281e4160f1e1dda9967f9 Mon Sep 17 00:00:00 2001 From: Glavo Date: Tue, 7 Sep 2021 20:07:11 +0800 Subject: [PATCH] Download OpenJFX on Linux ARM32 --- .../hmcl/util/SelfDependencyPatcher.java | 28 +++++++++++++++---- .../resources/assets/lang/I18N.properties | 1 + .../resources/assets/lang/I18N_zh.properties | 1 + .../assets/lang/I18N_zh_CN.properties | 1 + .../assets/openjfx-dependencies.json | 7 ++++- build.gradle | 2 +- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/SelfDependencyPatcher.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/SelfDependencyPatcher.java index 01867c155..472b10d1d 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/SelfDependencyPatcher.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/SelfDependencyPatcher.java @@ -87,6 +87,8 @@ public final class SelfDependencyPatcher { switch (Architecture.CURRENT) { case X86_64: return "linux"; + case ARM: + return "linux-arm32-monocle"; case ARM64: return "linux-aarch64"; } @@ -134,6 +136,10 @@ public final class SelfDependencyPatcher { } return DEPENDENCIES_DIR_PATH.resolve(filename()); } + + public boolean isSupported() { + return CURRENT_ARCH_CLASSIFIER != null && sha1.containsKey(CURRENT_ARCH_CLASSIFIER); + } } static final class Repository { @@ -251,7 +257,14 @@ public final class SelfDependencyPatcher { final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - for (String line : i18n("repositories.chooser").split("\n")) { + final String chooserText; + if (OperatingSystem.CURRENT_OS == OperatingSystem.LINUX && Architecture.CURRENT == Architecture.ARM) { + chooserText = i18n("repositories.chooser.linux_arm32"); + } else { + chooserText = i18n("repositories.chooser"); + } + + for (String line : chooserText.split("\n")) { panel.add(new JLabel(line)); } @@ -294,10 +307,12 @@ public final class SelfDependencyPatcher { LOG.info(" - Loading dependencies..."); Set modules = JFX_DEPENDENCIES.stream() + .filter(DependencyDescriptor::isSupported) .map(it -> it.module) .collect(toSet()); Path[] jars = JFX_DEPENDENCIES.stream() + .filter(DependencyDescriptor::isSupported) .map(DependencyDescriptor::localPath) .toArray(Path[]::new); @@ -337,6 +352,9 @@ public final class SelfDependencyPatcher { List missing = new ArrayList<>(); for (DependencyDescriptor dependency : JFX_DEPENDENCIES) { + if (!dependency.isSupported()) { + continue; + } if (!Files.exists(dependency.localPath())) { missing.add(dependency); continue; @@ -390,10 +408,10 @@ public final class SelfDependencyPatcher { setLocationRelativeTo(null); GridBagLayout gridBagLayout = new GridBagLayout(); - gridBagLayout.columnWidths = new int[] { 600, 0 }; - gridBagLayout.rowHeights = new int[] { 0, 0, 0, 200 }; - gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; - gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0 }; + gridBagLayout.columnWidths = new int[]{600, 0}; + gridBagLayout.rowHeights = new int[]{0, 0, 0, 200}; + gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE}; + gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0}; panel.setLayout(gridBagLayout); progressText = new JLabel(""); diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index d3ed040d1..7c8bebf19 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -494,6 +494,7 @@ repositories.custom=Custom Maven Repository (%s) repositories.maven_central=Maven Central (General) repositories.aliyun_mirror=Aliyun Maven Repository (Chinese mainland) repositories.chooser=JavaFX is missing. Do you want to automatically download and load JavaFX runtime components from web?\nSelect 'Yes' to download the JavaFX runtime components from the specified download source and start the HMCL, or select 'No' to exit the program.\nDownload Source: +repositories.chooser.linux_arm32=JavaFX is missing. Do you want to automatically download and load JavaFX runtime components from web?\nSelect 'Yes' to download the JavaFX runtime components from the specified download source and start the HMCL, or select 'No' to exit the program.\nNote: Some components cannot be downloaded temporarily on Linux ARM32 platform, so HMCL may crash at runtime.\nDownload Source: repositories.chooser.title=Do you want to download JavaFX? resourcepack=Resource Pack diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index f4ce2f6d3..276a014b2 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -354,6 +354,7 @@ repositories.custom=自定義 Maven 倉庫(%s) repositories.maven_central=Maven Central(通用) repositories.aliyun_mirror=阿里雲 Maven 倉庫(中國大陸) repositories.chooser=缺少 JavaFX 運行環境。是否需要從網絡下載並加載 JavaFX 運行時組件?\n選擇“是”從指定下載源下載 JavaFX 運行時組件並啟動HMCL,選擇“否”退出程式。\n下載源: +repositories.chooser.linux_arm32=缺少 JavaFX 運行環境。是否需要從網絡下載並加載 JavaFX 運行時組件?\n選擇“是”從指定下載源下載 JavaFX 運行時組件並啟動HMCL,選擇“否”退出程式。\n注意:Linux ARM32 平臺下暫時無法下載部分組件,運行時可能造成HMCL崩潰。\n下載源: repositories.chooser.title=是否下載 JavaFX? selector.choose=選擇 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index a5ff61024..51785a0b4 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -503,6 +503,7 @@ repositories.custom=自定义 Maven 仓库(%s) repositories.maven_central=Maven Central(通用) repositories.aliyun_mirror=阿里云 Maven 仓库(中国大陆) repositories.chooser=缺少 JavaFX 运行环境,是否需要从网络下载并加载 JavaFX 运行时组件?\n选择“是”从指定下载源下载 JavaFX 运行时组件并启动 HMCL,选择“否”退出程序。\n下载源: +repositories.chooser.linux_arm32=缺少 JavaFX 运行环境,是否需要从网络下载并加载 JavaFX 运行时组件?\n选择“是”从指定下载源下载 JavaFX 运行时组件并启动 HMCL,选择“否”退出程序。\n注意:Linux ARM32 平台下暂时无法下载部分组件,运行时可能造成 HMCL 崩溃。\n下载源: repositories.chooser.title=是否下载 JavaFX? resourcepack=资源包 diff --git a/HMCL/src/main/resources/assets/openjfx-dependencies.json b/HMCL/src/main/resources/assets/openjfx-dependencies.json index 5cb6f69e9..e385c19c5 100644 --- a/HMCL/src/main/resources/assets/openjfx-dependencies.json +++ b/HMCL/src/main/resources/assets/openjfx-dependencies.json @@ -6,6 +6,7 @@ "version": "17-ea+17", "sha1": { "linux": "70b3908f548c6031e1dd221124e91ea3891f5f3f", + "linux-arm32-monocle": "256bd3daf1cb8d52f3aed20a8bd400de91f82744", "linux-aarch64": "a55742f01e9e220b8c5143fa018a072e16ad5a8e", "mac": "79d57e0c2984dd2a006bc32a5615e71dac23386c", "mac-aarch64": "a395b2f11af9c4e90fd3297dd529fdaf258c1569", @@ -20,6 +21,7 @@ "version": "17-ea+17", "sha1": { "linux": "3a46f7cdb81c3e8d6f2c8b01bd0f373be30117f5", + "linux-arm32-monocle": "0ae5a384b402b34faaccce3c5a0d37362638ffa1", "linux-aarch64": "fd0a4e2f57ac740c4832f204a9b10093d02dec3b", "mac": "20c2c350a034c8bcf999e97e4e57c782fc3ebea3", "mac-aarch64": "88bafecc908d8e75b1a8496cda8217aa6d9f76fc", @@ -34,6 +36,7 @@ "version": "17-ea+17", "sha1": { "linux": "412ae5755e94fb46dd1c8c0890af570f9dad2985", + "linux-arm32-monocle": "e910781f8518604a144dea01eba168ab252cf46d", "linux-aarch64": "4e2a7938a24f23e86ab22f55c762e10277d52c5c", "mac": "5ff616acca97e7a51e35478f20eb292a4a14fa0f", "mac-aarch64": "4fade5a687f03c17b4d9c2219e7390f2599baf77", @@ -48,6 +51,7 @@ "version": "17-ea+17", "sha1": { "linux": "b11547378c13e2ff404a161460c8f3f68802af44", + "linux-arm32-monocle": "29963f4c3b69fc44a4b63576c655f793d3c87b82", "linux-aarch64": "bff9c9502737b580cd4b40d5e296f4a446c148ba", "mac": "6abbd5c3a87f2d50f63f2c2bbf3e27ff753e06f2", "mac-aarch64": "6d583ff9e01c9e3e0999615aebc4e875db5e368b", @@ -62,6 +66,7 @@ "version": "17-ea+17", "sha1": { "linux": "0d6e841e4c02b566f1f587ddee32ef0cc0ce38e1", + "linux-arm32-monocle": "eca17e33ccb8005ec546f1a44b8a99072b0aefa0", "linux-aarch64": "3c380afd3c1c9c346f8b78826333c56102f4315c", "mac": "ace33a63e65ec7da79ecbce9b6fc439af1815d2d", "mac-aarch64": "72f944f25ce4f8e6b0e31215692a743abc56efef", @@ -83,4 +88,4 @@ "win-x86": "6c894b0cda6e7f2ed825eb66aba9413b88fcc2f2" } } -] +] \ No newline at end of file diff --git a/build.gradle b/build.gradle index 14f0c33ca..812daa0f9 100644 --- a/build.gradle +++ b/build.gradle @@ -56,7 +56,7 @@ subprojects { defaultTasks 'clean', 'build' var jfxModules = ['base', 'controls', 'fxml', 'graphics', 'media', 'web'] -var jfxArches = ['linux', /*'linux-arm32-monocle',*/ 'linux-aarch64', 'mac', 'mac-aarch64', 'win', 'win-x86'] +var jfxArches = ['linux', 'linux-arm32-monocle', 'linux-aarch64', 'mac', 'mac-aarch64', 'win', 'win-x86'] var jfxVersion = "17-ea+17" task 'generateOpenJFXDependencies' {