|
51 | 51 | import java.util.TreeMap;
|
52 | 52 | import java.util.TreeSet;
|
53 | 53 | import java.util.function.Consumer;
|
| 54 | +import java.util.regex.Matcher; |
| 55 | +import java.util.regex.Pattern; |
54 | 56 | import java.util.stream.Collectors;
|
55 | 57 | import java.util.stream.Stream;
|
56 | 58 |
|
@@ -1085,37 +1087,24 @@ public OSArchitecture detectArchitecture(
|
1085 | 1087 | }
|
1086 | 1088 |
|
1087 | 1089 | String os = Platform.getOS();
|
1088 |
| - Set<String> launcherLibraries = targetBundleIndex.keySet().stream().filter(name -> name.startsWith("org.eclipse.equinox.launcher") && name.contains(os)).collect(Collectors.toSet()); |
1089 |
| - if (launcherLibraries.size() != 1) { |
| 1090 | + // Find org.eclipse.equinox.launcher.cocoa.macosx.aarch64 |
| 1091 | + // Skip org.eclipse.equinox.launcher.cocoa.macosx |
| 1092 | + Pattern prefix = Pattern.compile(("org.eclipse.equinox.launcher.[\\w\\d]+."+os+".").replace(".", "\\.")); |
| 1093 | + Set<String> launcherArchitectures = targetBundleIndex.keySet().stream().map(name -> removePrefix(name, prefix)).flatMap(Optional::stream).collect(Collectors.toSet()); |
| 1094 | + if (launcherArchitectures.size() != 1) { |
1090 | 1095 | if (detectMsg != null) {
|
1091 |
| - detectMsg.append("Multiple launcher libraries are found in target platform: " + Joiner.on(", ").join(launcherLibraries)); |
| 1096 | + detectMsg.append("Multiple launcher architectures are found in target platform: " + Joiner.on(", ").join(launcherArchitectures)); |
1092 | 1097 | }
|
1093 | 1098 | return OSArchitecture.Unknown;
|
1094 | 1099 | }
|
1095 | 1100 |
|
1096 |
| - String name = launcherLibraries.iterator().next(); |
1097 |
| - if (name.contains("aarch64")) { |
1098 |
| - if (detectMsg != null) { |
1099 |
| - detectMsg.append("aarch64 arch is selected because AUT uses " + name); |
1100 |
| - } |
1101 |
| - return OSArchitecture.aarch64; |
1102 |
| - } else if (name.contains("x86_64")) { |
1103 |
| - if (detectMsg != null) { |
1104 |
| - detectMsg.append("x86_64 arch is selected because AUT uses " + name); |
1105 |
| - } |
1106 |
| - return OSArchitecture.x86_64; |
1107 |
| - } else if (name.contains("x86")) { |
1108 |
| - if (detectMsg != null) { |
1109 |
| - detectMsg.append("x86 arch is selected because AUT uses " + name); |
1110 |
| - } |
1111 |
| - return OSArchitecture.x86; |
1112 |
| - } |
1113 |
| - |
| 1101 | + String name = launcherArchitectures.iterator().next(); |
| 1102 | + OSArchitecture result = OSArchitecture.valueOf(name); |
1114 | 1103 | if (detectMsg != null) {
|
1115 |
| - detectMsg.append("Unrecognized launcher architecture: " + name); |
| 1104 | + detectMsg.append(result).append(" arch detected"); |
1116 | 1105 | }
|
1117 | 1106 |
|
1118 |
| - return OSArchitecture.Unknown; |
| 1107 | + return result; |
1119 | 1108 | }
|
1120 | 1109 |
|
1121 | 1110 | private Map<String, BundleStart> getRunlevelsFromSimpleConfigurator() throws IOException {
|
@@ -1775,4 +1764,14 @@ private Model toModel(IPluginModelBase model) {
|
1775 | 1764 | return new Model(model, BundleStart.fromBundle(bundle.getBundleInfo()));
|
1776 | 1765 | }
|
1777 | 1766 |
|
| 1767 | + private Optional<String> removePrefix(String input, Pattern prefix) { |
| 1768 | + Matcher matcher = prefix.matcher(input); |
| 1769 | + if (matcher.find()) { |
| 1770 | + if (matcher.start() == 0) { |
| 1771 | + return Optional.of(input.substring(matcher.end())); |
| 1772 | + } |
| 1773 | + } |
| 1774 | + return Optional.empty(); |
| 1775 | + } |
| 1776 | + |
1778 | 1777 | }
|
0 commit comments