diff options
author | Andrew Gvozdev | 2011-11-17 22:34:21 +0000 |
---|---|---|
committer | Andrew Gvozdev | 2011-11-17 22:34:21 +0000 |
commit | 2a1cddd71635c39ae336ba43bb89cecbfb09e21f (patch) | |
tree | c7a504d11610c16c23c34e29bba23ba0b280bb81 /build/org.eclipse.cdt.managedbuilder.gnu.ui | |
parent | e47db971decd8fd15ce52984be3de50b6eaa24de (diff) | |
download | org.eclipse.cdt-2a1cddd71635c39ae336ba43bb89cecbfb09e21f.tar.gz org.eclipse.cdt-2a1cddd71635c39ae336ba43bb89cecbfb09e21f.tar.xz org.eclipse.cdt-2a1cddd71635c39ae336ba43bb89cecbfb09e21f.zip |
auto-clean: @Override annotations + organize imports + unnecessary
casts/$NON-NLS + trailing white spaces
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.gnu.ui')
6 files changed, 103 insertions, 89 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java index 4d97d2ac5a0..9599f41fbb4 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/CygwinPathResolver.java @@ -35,7 +35,7 @@ import org.eclipse.core.runtime.IPath; */ public class CygwinPathResolver implements IBuildPathResolver { private static final String DEFAULT_ROOT = "C:\\cygwin"; //$NON-NLS-1$ - private static final String TOOL = "/cygpath -w -p "; //$NON-NLS-1$ + private static final String TOOL = "/cygpath -w -p "; //$NON-NLS-1$ private static final char BS = '\\'; private static final char SLASH = '/'; private static final String PROPERTY_OS_NAME = "os.name"; //$NON-NLS-1$ @@ -57,7 +57,7 @@ public class CygwinPathResolver implements IBuildPathResolver { private static final String GCC_VERSION_CMD = "gcc --version"; //$NON-NLS-1$ private static final String MINGW_SPECIAL = "mingw "; //$NON-NLS-1$ private static final String CYGWIN_SPECIAL = "cygwin "; //$NON-NLS-1$ - + private static boolean checked = false; private static String binCygwin = null; private static String rootCygwin = null; @@ -66,9 +66,10 @@ public class CygwinPathResolver implements IBuildPathResolver { /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IBuildPathResolver#resolveBuildPaths(int, java.lang.String, java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration) */ + @Override public String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration) { - + if(!isWindows()){ return variableValue.split(DELIMITER_UNIX); } else if(isMinGW(configuration)){ @@ -77,19 +78,19 @@ public class CygwinPathResolver implements IBuildPathResolver { String[] result = variableValue.split(DELIMITER_UNIX); String exePath = getBinPath(); - if (exePath == null) { - return result; // no changes - } - File file = new File(exePath); - if (!file.exists() || !file.isDirectory()) { + if (exePath == null) { + return result; // no changes + } + File file = new File(exePath); + if (!file.exists() || !file.isDirectory()) { return result; // no changes } String s = exePath + TOOL + variableValue; String[] lines = exec(s, configuration); if (lines != null && lines.length > 0) { - result = lines[0].replace(BS,SLASH).split(DELIMITER_WIN); + result = lines[0].replace(BS,SLASH).split(DELIMITER_WIN); } - return result; + return result; } /* * returns "/etc" path in Windows format @@ -100,31 +101,31 @@ public class CygwinPathResolver implements IBuildPathResolver { } /* - * returns "/usr/bin" path in Windows format + * returns "/usr/bin" path in Windows format */ public static String getBinPath() { if (!checked) findPaths(); return binCygwin; } /* - * returns Cygwin root ("/") path in Windows format + * returns Cygwin root ("/") path in Windows format */ - + public static String getRootPath() { if (!checked) findPaths(); return rootCygwin; } - + public static boolean isWindows() { return (System.getProperty(PROPERTY_OS_NAME).toLowerCase().startsWith(PROPERTY_OS_VALUE)); } - + /** * Reads required value from registry. Looks in both * HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE - * + * * @param key Registry key - * @param name Registry value to read + * @param name Registry value to read * @return corresponding string value or null if nothing found */ private static String readValueFromRegistry(String key, String name) { @@ -140,9 +141,9 @@ public class CygwinPathResolver implements IBuildPathResolver { return null; } /** - * Returns the absolute path of the pattern by + * Returns the absolute path of the pattern by * simply appending the pattern to the root - * + * * @param pattern The pattern to find * @return The absolute path to the pattern or null if pattern is not found */ @@ -155,18 +156,18 @@ public class CygwinPathResolver implements IBuildPathResolver { else return null; } - + return null; } - + /** * Returns the absolute path to cygwin's root - * + * * @return The absolute path to cygwin's root or null if not found */ private static String findRoot() { String rootValue = null; - + // 1. Look in PATH values. Look for bin\cygwin1.dll IPath location = PathUtil.findProgramLocation("cygwin1.dll"); //$NON-NLS-1$ if (location!=null) { @@ -177,57 +178,57 @@ public class CygwinPathResolver implements IBuildPathResolver { if(rootValue == null) { rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP, "rootdir"); //$NON-NLS-1$ } - + // 3. Try to find the root dir in SOFTWARE\Wow6432Node\Cygwin\setup if(rootValue == null) { rootValue = readValueFromRegistry(REGISTRY_KEY_SETUP_WIN64, "rootdir"); //$NON-NLS-1$ } - + // 4. Try to find the root dir in SOFTWARE\Cygnus Solutions if (rootValue == null) { rootValue = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ROOTPATTERN, PATH_NAME); } - + // 5. Try the default Cygwin install dir if(rootValue == null) { File file = new File(DEFAULT_ROOT); if (file.exists() && file.isDirectory()) rootValue = DEFAULT_ROOT; } - + if(rootValue != null) rootValue = rootValue.replaceAll(BSLASH, SSLASH); - + return rootValue; } - + /** - * Finds Cygwin's paths and sets corresponding properties + * Finds Cygwin's paths and sets corresponding properties */ private static synchronized void findPaths() { if (checked) return; - etcCygwin = null; + etcCygwin = null; binCygwin = null; - rootCygwin = null; + rootCygwin = null; if (!isWindows()) return; - + rootCygwin = findRoot(); - + // 1. Try to find the paths by appending the patterns to the root dir etcCygwin = getValueFromRoot(ETCPATTERN); binCygwin = getValueFromRoot(BINPATTERN); if(binCygwin == null) binCygwin = getValueFromRoot(BINPATTERN_ALTERNATE); - - // 2. Try to find the paths in SOFTWARE\\Cygnus Solutions + + // 2. Try to find the paths in SOFTWARE\\Cygnus Solutions if(etcCygwin == null) etcCygwin = readValueFromRegistry(REGISTRY_KEY_MOUNTS + ETCPATTERN, PATH_NAME); if(binCygwin == null) binCygwin = readValueFromRegistry(REGISTRY_KEY_MOUNTS + BINPATTERN, PATH_NAME); - + checked = true; } - + private static String[] exec(String cmd, IConfiguration cfg) { try { IEnvironmentVariable vars[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true); @@ -236,17 +237,17 @@ public class CygwinPathResolver implements IBuildPathResolver { env[i] = vars[i].getName() + "="; //$NON-NLS-1$ String value = vars[i].getValue(); if(value != null) - env[i] += value; + env[i] += value; } Process proc = ProcessFactory.getFactory().exec(cmd.split(SP), env); if (proc != null) { - + InputStream ein = proc.getInputStream(); BufferedReader d1 = new BufferedReader(new InputStreamReader(ein)); ArrayList<String> ls = new ArrayList<String>(10); String s; while ((s = d1.readLine() ) != null ) { - ls.add(s); + ls.add(s); } ein.close(); return ls.toArray(new String[0]); @@ -254,9 +255,9 @@ public class CygwinPathResolver implements IBuildPathResolver { } catch (IOException e) { GnuUIPlugin.getDefault().log(e); } - return null; + return null; } - + public static boolean isMinGW(IConfiguration cfg){ String versionInfo[] = exec(GCC_VERSION_CMD, cfg); if(versionInfo != null) { diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java index 29752c37cfe..90f9b69d47f 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/GnuCygwinConfigurationEnvironmentSupplier.java @@ -30,30 +30,32 @@ public class GnuCygwinConfigurationEnvironmentSupplier implements /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariable(java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider) */ + @Override public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) { - if (!System.getProperty(PROPERTY_OSNAME).toLowerCase().startsWith("windows ")) //$NON-NLS-1$ + if (!System.getProperty(PROPERTY_OSNAME).toLowerCase().startsWith("windows ")) //$NON-NLS-1$ return null; - + if (variableName == null) return null; if (!VARNAME.equalsIgnoreCase(variableName)) return null; - + String p = CygwinPathResolver.getBinPath(); - if (p != null) + if (p != null) return new BuildEnvVar(VARNAME, p.replace('/','\\'), IBuildEnvironmentVariable.ENVVAR_PREPEND, System.getProperty(PROPERTY_DELIMITER, DELIMITER_UNIX)); - return null; + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariables(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider) */ + @Override public IBuildEnvironmentVariable[] getVariables( IConfiguration configuration, IEnvironmentVariableProvider provider) { - - IBuildEnvironmentVariable[] tmp = new IBuildEnvironmentVariable[1]; + + IBuildEnvironmentVariable[] tmp = new IBuildEnvironmentVariable[1]; tmp[0] = getVariable(VARNAME, configuration, provider); - if (tmp[0] != null) return tmp; + if (tmp[0] != null) return tmp; return null; } } diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/IsGnuCygwinToolChainSupported.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/IsGnuCygwinToolChainSupported.java index 8e6356bbf0b..f3c9541db45 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/IsGnuCygwinToolChainSupported.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/cygwin/IsGnuCygwinToolChainSupported.java @@ -23,22 +23,22 @@ import org.osgi.framework.Version; /** * This class implements the IManagedIsToolChainSupported for the Gnu Cygwin tool-chain * The class is NOT used currently, because currently the gnu cygwin tool-chain - * is intended to be used not only with Cygwin, but with MinGW also, and there is no + * is intended to be used not only with Cygwin, but with MinGW also, and there is no * correct way of determining whether the appropriate packages are installed for MinGW. - * + * * For the future MBS/CDT versions we might create the separate tool-chain/configuration/project-type * for the MinGW and define a set of converters using the tool-chain converter mechanism that MBS will provide, * that would convert the CygWin to the MinGW projects/tool-chains, and vice a versa. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class IsGnuCygwinToolChainSupported implements IManagedIsToolChainSupported { - + static final String[] CHECKED_NAMES = {"gcc", "binutils", "make"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ static boolean suppChecked = false; - static boolean toolchainIsSupported = false; + static boolean toolchainIsSupported = false; /* (non-Javadoc) @@ -47,15 +47,16 @@ public class IsGnuCygwinToolChainSupported implements /** * @since 8.0 */ + @Override public boolean isSupported(IToolChain toolChain, Version version, String instance) { - + if (suppChecked) return toolchainIsSupported; String etcCygwin = CygwinPathResolver.getEtcPath(); if (etcCygwin != null) { toolchainIsSupported = arePackagesInstalled(etcCygwin); } - + suppChecked = true; return toolchainIsSupported; @@ -64,7 +65,7 @@ public class IsGnuCygwinToolChainSupported implements /** * Returns true if all required packages are installed, see CHECKED_NAMES for a list of packages. Cygwin * maintains a list of packages in /etc/setup/installed.db so we look for packages in this file. - * + * * @param etcCygwin the absolute path of /etc containing /setup/installed.db * @return true if the packages specified in CHECKED_NAMES are installed */ @@ -76,20 +77,20 @@ public class IsGnuCygwinToolChainSupported implements // All required package names should be found boolean[] found = new boolean[CHECKED_NAMES.length]; - String s; + String s; while ((s = data.readLine()) != null ) { for (int j = 0; j < CHECKED_NAMES.length; j++) { if (s.startsWith(CHECKED_NAMES[j])) {found[j] = true;} } - } + } arePackagesInstalled = true; for (int j = 0; j < CHECKED_NAMES.length; j++) { - arePackagesInstalled &= found[j]; + arePackagesInstalled &= found[j]; } data.close(); } catch (FileNotFoundException e) { } catch (IOException e) { } return arePackagesInstalled; - } + } } diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java index 43d8de12ccf..940ca95cb59 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java @@ -27,7 +27,7 @@ import org.eclipse.core.runtime.Platform; */ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironmentVariableSupplier { - + private static boolean checked = false; private static IPath binDir = null; @@ -35,32 +35,36 @@ public class MingwEnvironmentVariableSupplier implements private final String name; private final String value; private final int operation; - + public MingwBuildEnvironmentVariable(String name, String value, int operation) { this.name = name; this.value = value; this.operation = operation; } - + + @Override public String getName() { return name; } - + + @Override public String getValue() { return value; } - + + @Override public int getOperation() { return operation; } - + + @Override public String getDelimiter() { return ";"; //$NON-NLS-1$ } } - + private IBuildEnvironmentVariable path; - + public static IPath getBinDir() { if (!checked) { binDir = findBinDir(); @@ -87,38 +91,38 @@ public class MingwEnvironmentVariableSupplier implements // TODO: Since this dir is already in the PATH, why are we adding it here? // This is really only to support isToolchainAvail. Must be a better way. IPath gccLoc = PathUtil.findProgramLocation("mingw32-gcc.exe"); //$NON-NLS-1$ - if (gccLoc != null) + if (gccLoc != null) return gccLoc.removeLastSegments(1); - - // Try the default MinGW install dir + + // Try the default MinGW install dir mingwBinDir = new Path("C:\\MinGW\\bin"); //$NON-NLS-1$ if (mingwBinDir.toFile().isDirectory()) return mingwBinDir; - + return null; } - + public static IPath getMsysBinDir() { // Just look in the install location parent dir IPath installPath = new Path(Platform.getInstallLocation().getURL().getFile()); IPath msysBinPath = installPath.append("msys\\bin"); //$NON-NLS-1$ if (msysBinPath.toFile().isDirectory()) return msysBinPath; - + String mingwHome = System.getenv("MINGW_HOME"); //$NON-NLS-1$ if (mingwHome != null) { msysBinPath = new Path(mingwHome + "\\msys\\1.0\\bin"); //$NON-NLS-1$ if (msysBinPath.toFile().isDirectory()) return msysBinPath; } - + // Try the new MinGW msys bin dir msysBinPath = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$ if (msysBinPath.toFile().isDirectory()) return msysBinPath; return null; } - + public MingwEnvironmentVariableSupplier() { IPath binPath = getBinDir(); if (binPath != null) { @@ -126,11 +130,12 @@ public class MingwEnvironmentVariableSupplier implements IPath msysBinPath = getMsysBinDir(); if (msysBinPath != null) pathStr += ';' + msysBinPath.toOSString(); - + path = new MingwBuildEnvironmentVariable("PATH", pathStr, IBuildEnvironmentVariable.ENVVAR_PREPEND); //$NON-NLS-1$ } } - + + @Override public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) { if (path != null && variableName.equals(path.getName())) @@ -139,6 +144,7 @@ public class MingwEnvironmentVariableSupplier implements return null; } + @Override public IBuildEnvironmentVariable[] getVariables( IConfiguration configuration, IEnvironmentVariableProvider provider) { return path != null diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwIsToolChainSupported.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwIsToolChainSupported.java index da46486a884..a92364c870d 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwIsToolChainSupported.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwIsToolChainSupported.java @@ -4,8 +4,8 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: + * + * Contributors: * QNX Software Systems - Initial API and implementation **********************************************************************/ @@ -23,12 +23,13 @@ import org.osgi.framework.Version; public class MingwIsToolChainSupported implements IManagedIsToolChainSupported { private final boolean supported; - + public MingwIsToolChainSupported() { // Only supported if we can find the mingw bin dir to run the compiler supported = MingwEnvironmentVariableSupplier.getBinDir() != null; } - + + @Override public boolean isSupported(IToolChain toolChain, Version version, String instance) { return supported; } diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/ui/ProfAppCalculator.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/ui/ProfAppCalculator.java index 66d28ca5132..5209c4a264b 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/ui/ProfAppCalculator.java +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/ui/ProfAppCalculator.java @@ -25,24 +25,26 @@ import org.eclipse.cdt.managedbuilder.core.ITool; public class ProfAppCalculator implements IOptionApplicability { protected static final String COMPILER_PATTERN = ".compiler."; //$NON-NLS-1$ - + protected String getOptionIdPattern() { return ".compiler.option.debugging.prof"; //$NON-NLS-1$ } - + + @Override public boolean isOptionEnabled(IBuildObject configuration, IHoldsOptions holder, IOption option) { return true; } + @Override public boolean isOptionUsedInCommandLine(IBuildObject configuration, IHoldsOptions holder, IOption option) { if (! (configuration instanceof IConfiguration)) return false; // not probable. - + IConfiguration cfg = (IConfiguration)configuration; - outer: + outer: for (ITool t : cfg.getFilteredTools()){ if (t.getId().indexOf(COMPILER_PATTERN) < 0) continue; @@ -59,6 +61,7 @@ public class ProfAppCalculator implements IOptionApplicability { return true; } + @Override public boolean isOptionVisible(IBuildObject configuration, IHoldsOptions holder, IOption option) { return false; |