mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
ContributionInstaller OS check: MacOSX now uses real arch rather than JVM one
This commit is contained in:
@ -28,6 +28,8 @@
|
||||
*/
|
||||
package cc.arduino.contributions.packages;
|
||||
|
||||
import processing.app.BaseNoGui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ContributedTool {
|
||||
@ -40,7 +42,7 @@ public abstract class ContributedTool {
|
||||
|
||||
public DownloadableContribution getDownloadableContribution() {
|
||||
for (HostDependentDownloadableContribution c : getSystems()) {
|
||||
if (c.isCompatible())
|
||||
if (c.isCompatible(BaseNoGui.getPlatform()))
|
||||
return c;
|
||||
}
|
||||
return null;
|
||||
@ -52,7 +54,7 @@ public abstract class ContributedTool {
|
||||
res = "Tool name : " + getName() + " " + getVersion() + "\n";
|
||||
for (HostDependentDownloadableContribution sys : getSystems()) {
|
||||
res += " sys";
|
||||
res += sys.isCompatible() ? "*" : " ";
|
||||
res += sys.isCompatible(BaseNoGui.getPlatform()) ? "*" : " ";
|
||||
res += " : " + sys + "\n";
|
||||
}
|
||||
return res;
|
||||
|
@ -172,7 +172,7 @@ public class ContributionInstaller {
|
||||
|
||||
if (postInstallScripts.isEmpty()) {
|
||||
String[] subfolders = folder.list(new OnlyDirs());
|
||||
if (subfolders.length > 1) {
|
||||
if (subfolders.length != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,8 @@
|
||||
*/
|
||||
package cc.arduino.contributions.packages;
|
||||
|
||||
import java.util.Properties;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.Platform;
|
||||
|
||||
public abstract class HostDependentDownloadableContribution extends DownloadableContribution {
|
||||
|
||||
@ -39,12 +40,9 @@ public abstract class HostDependentDownloadableContribution extends Downloadable
|
||||
return getHost() + " " + super.toString();
|
||||
}
|
||||
|
||||
public boolean isCompatible() {
|
||||
// TODO: add missing host detections
|
||||
|
||||
Properties prop = System.getProperties();
|
||||
String osName = prop.getProperty("os.name");
|
||||
String osArch = prop.getProperty("os.arch");
|
||||
public boolean isCompatible(Platform platform) {
|
||||
String osName = platform.getOsName();
|
||||
String osArch = platform.getOsArch();
|
||||
|
||||
String host = getHost();
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class Platform {
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
public void init() throws IOException {
|
||||
}
|
||||
|
||||
|
||||
@ -236,4 +236,12 @@ public class Platform {
|
||||
scripts.add(new File(folder, "post_install.sh"));
|
||||
return scripts;
|
||||
}
|
||||
|
||||
public String getOsName() {
|
||||
return System.getProperty("os.name");
|
||||
}
|
||||
|
||||
public String getOsArch() {
|
||||
return System.getProperty("os.arch");
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import cc.arduino.packages.BoardPort;
|
||||
import com.apple.eio.FileManager;
|
||||
import org.apache.commons.exec.CommandLine;
|
||||
import org.apache.commons.exec.Executor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import processing.app.debug.TargetPackage;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.legacy.PConstants;
|
||||
@ -45,6 +46,8 @@ import java.util.List;
|
||||
*/
|
||||
public class Platform extends processing.app.Platform {
|
||||
|
||||
private String osArch;
|
||||
|
||||
public void setLookAndFeel() throws Exception {
|
||||
}
|
||||
|
||||
@ -54,35 +57,18 @@ public class Platform extends processing.app.Platform {
|
||||
Toolkit.getDefaultToolkit();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
public void init() throws IOException {
|
||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||
/*
|
||||
try {
|
||||
String name = "processing.app.macosx.ThinkDifferent";
|
||||
Class osxAdapter = ClassLoader.getSystemClassLoader().loadClass(name);
|
||||
|
||||
Class[] defArgs = { Base.class };
|
||||
Method registerMethod = osxAdapter.getDeclaredMethod("register", defArgs);
|
||||
if (registerMethod != null) {
|
||||
Object[] args = { this };
|
||||
registerMethod.invoke(osxAdapter, args);
|
||||
}
|
||||
} catch (NoClassDefFoundError e) {
|
||||
// This will be thrown first if the OSXAdapter is loaded on a system without the EAWT
|
||||
// because OSXAdapter extends ApplicationAdapter in its def
|
||||
System.err.println("This version of Mac OS X does not support the Apple EAWT." +
|
||||
"Application Menu handling has been disabled (" + e + ")");
|
||||
discoverRealOsArch();
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
// This shouldn't be reached; if there's a problem with the OSXAdapter
|
||||
// we should get the above NoClassDefFoundError first.
|
||||
System.err.println("This version of Mac OS X does not support the Apple EAWT. " +
|
||||
"Application Menu handling has been disabled (" + e + ")");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Exception while loading BaseOSX:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
private void discoverRealOsArch() throws IOException {
|
||||
CommandLine uname = CommandLine.parse("uname -m");
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
CollectStdOutExecutor executor = new CollectStdOutExecutor(baos);
|
||||
executor.execute(uname);
|
||||
osArch = StringUtils.trim(new String(baos.toByteArray()));
|
||||
}
|
||||
|
||||
|
||||
@ -252,4 +238,9 @@ public class Platform extends processing.app.Platform {
|
||||
|
||||
return filteredPorts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOsArch() {
|
||||
return osArch;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class Platform extends processing.app.Platform {
|
||||
"\\arduino.exe \"%1\"";
|
||||
static final String DOC = "Arduino.Document";
|
||||
|
||||
public void init() {
|
||||
public void init() throws IOException {
|
||||
super.init();
|
||||
|
||||
checkAssociations();
|
||||
|
Reference in New Issue
Block a user