mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 200327: Platform.getOSArch() should return real architecture on x86_64
This commit is contained in:
parent
e31cd6e520
commit
976e9e1204
1 changed files with 32 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation and others.
|
* Copyright (c) 2006, 2007 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - Initial API and implementation (Corey Ashford)
|
* IBM Corporation - Initial API and implementation (Corey Ashford)
|
||||||
*
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.utils;
|
package org.eclipse.cdt.utils;
|
||||||
|
@ -33,8 +33,7 @@ public final class Platform {
|
||||||
|
|
||||||
public static final String OS_LINUX = org.eclipse.core.runtime.Platform.OS_LINUX;
|
public static final String OS_LINUX = org.eclipse.core.runtime.Platform.OS_LINUX;
|
||||||
|
|
||||||
private static boolean ppcArchIsCached = false;
|
private static String cachedArch = null;
|
||||||
private static String cachedPpcArch = null;
|
|
||||||
|
|
||||||
public static Bundle getBundle(String symbolicName) {
|
public static Bundle getBundle(String symbolicName) {
|
||||||
return org.eclipse.core.runtime.Platform.getBundle(symbolicName);
|
return org.eclipse.core.runtime.Platform.getBundle(symbolicName);
|
||||||
|
@ -45,31 +44,43 @@ public final class Platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getOSArch() {
|
public static String getOSArch() {
|
||||||
|
if (cachedArch == null) {
|
||||||
String arch = org.eclipse.core.runtime.Platform.getOSArch();
|
String arch = org.eclipse.core.runtime.Platform.getOSArch();
|
||||||
if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_PPC)) {
|
if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_PPC)) {
|
||||||
// Determine if the platform is actually a ppc64 machine
|
// Determine if the platform is actually a ppc64 machine
|
||||||
if (!ppcArchIsCached) {
|
|
||||||
Process unameProcess;
|
Process unameProcess;
|
||||||
String cmd[] = {"uname", "-p"};
|
String cmd[] = {"uname", "-p"}; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
ppcArchIsCached = true;
|
|
||||||
try {
|
try {
|
||||||
unameProcess = Runtime.getRuntime().exec(cmd);
|
unameProcess = Runtime.getRuntime().exec(cmd);
|
||||||
|
|
||||||
InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream());
|
InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream());
|
||||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||||
cachedPpcArch = bufferedReader.readLine();
|
arch = bufferedReader.readLine();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
cachedPpcArch = null;
|
}
|
||||||
|
} else if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_X86)) {
|
||||||
|
// Determine if the platform is actually a x86_64 machine
|
||||||
|
Process unameProcess;
|
||||||
|
String cmd[] = {"uname", "-p"}; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
|
try {
|
||||||
|
unameProcess = Runtime.getRuntime().exec(cmd);
|
||||||
|
|
||||||
|
InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream());
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
|
||||||
|
String unameOutput = bufferedReader.readLine();
|
||||||
|
if (unameOutput.endsWith("64")) { //$NON-NLS-1$
|
||||||
|
arch= org.eclipse.core.runtime.Platform.ARCH_X86_64;
|
||||||
|
}
|
||||||
|
unameProcess.waitFor();
|
||||||
|
} catch (IOException e) {
|
||||||
|
} catch (InterruptedException exc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cachedPpcArch != null) {
|
cachedArch= arch;
|
||||||
return cachedPpcArch;
|
}
|
||||||
} else {
|
return cachedArch;
|
||||||
return arch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arch;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue