Skip to content

Commit a9c8a54

Browse files
author
jantje
committed
#892 tool platform matching linke in arduino code
1 parent 70da094 commit a9c8a54

File tree

1 file changed

+54
-26
lines changed

1 file changed

+54
-26
lines changed

io.sloeber.core/src/io/sloeber/core/managers/ToolSystem.java

+54-26
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import org.eclipse.core.runtime.IProgressMonitor;
1111
import org.eclipse.core.runtime.IStatus;
12-
import org.eclipse.core.runtime.Platform;
1312

1413
public class ToolSystem {
1514

@@ -45,32 +44,61 @@ public String getSize() {
4544
return this.size;
4645
}
4746

47+
48+
49+
/**
50+
* Is the tool compatible with the system sloeber is running on
51+
*
52+
* code as taken from arduino HostDependentDownloadableContribution
53+
* https://github.com/arduino/Arduino/blob/master/arduino-core/src/cc/arduino/contributions/packages/HostDependentDownloadableContribution.java
54+
*
55+
* @return true if ok; false if not
56+
*/
57+
@SuppressWarnings("nls")
4858
public boolean isApplicable() {
49-
switch (Platform.getOS()) {
50-
case Platform.OS_WIN32:
51-
return "i686-mingw32".equals(this.host); //$NON-NLS-1$
52-
case Platform.OS_MACOSX:
53-
switch (this.host) {
54-
case "i386-apple-darwin11": //$NON-NLS-1$
55-
case "x86_64-apple-darwin": //$NON-NLS-1$
56-
case "x86_64-apple-darwin12": //$NON-NLS-1$
57-
case "x86_64-apple-darwin14": //$NON-NLS-1$
58-
return true;
59-
default:
60-
return false;
61-
}
62-
case Platform.OS_LINUX:
63-
switch (Platform.getOSArch()) {
64-
case Platform.ARCH_X86_64:
65-
return "x86_64-linux-gnu".equals(this.host) || "x86_64-pc-linux-gnu".equals(this.host); //$NON-NLS-1$ //$NON-NLS-2$
66-
case Platform.ARCH_X86:
67-
return "i686-linux-gnu".equals(this.host) || "i686-pc-linux-gnu".equals(this.host); //$NON-NLS-1$ //$NON-NLS-2$
68-
default:
69-
return false;
70-
}
71-
default:
72-
return false;
73-
}
59+
60+
String osName =System.getProperty("os.name");
61+
String osArch =System.getProperty("os.arch");
62+
63+
if (osName.contains("Linux")) {
64+
if (osArch.equals("arm")) {
65+
// Raspberry PI, BBB or other ARM based host
66+
67+
// PI: "arm-linux-gnueabihf"
68+
// Arch-linux on PI2: "armv7l-unknown-linux-gnueabihf"
69+
// Raspbian on PI2: "arm-linux-gnueabihf"
70+
// Ubuntu Mate on PI2: "arm-linux-gnueabihf"
71+
// Debian 7.9 on BBB: "arm-linux-gnueabihf"
72+
// Raspbian on PI Zero: "arm-linux-gnueabihf"
73+
return host.matches("arm.*-linux-gnueabihf");
74+
} else if (osArch.contains("aarch64")) {
75+
return host.matches("aarch64.*-linux-gnu*");
76+
} else if (osArch.contains("amd64")) {
77+
return host.matches("x86_64-.*linux-gnu");
78+
} else {
79+
return host.matches("i[3456]86-.*linux-gnu");
80+
}
81+
}
82+
83+
if (osName.contains("Windows")) {
84+
return host.matches("i[3456]86-.*mingw32") || host.matches("i[3456]86-.*cygwin");
85+
}
86+
87+
if (osName.contains("Mac")) {
88+
if (osArch.contains("x86_64")) {
89+
return host.matches("x86_64-apple-darwin.*") || host.matches("i[3456]86-apple-darwin.*");
90+
}
91+
return host.matches("i[3456]86-apple-darwin.*");
92+
}
93+
94+
if (osName.contains("FreeBSD")) {
95+
if (osArch.contains("arm")) {
96+
return host.matches("arm.*-freebsd[0-9]*");
97+
}
98+
return host.matches(osArch + "-freebsd[0-9]*");
99+
}
100+
101+
return false;
74102
}
75103

76104
public IStatus install(IProgressMonitor monitor) {

0 commit comments

Comments
 (0)