Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2012-05-30 14:20:29 -0400
committerAndrew Gvozdev2012-05-30 14:20:29 -0400
commit746e244c33465568ba28582a5965e84069962d65 (patch)
tree97ba6e488ea2d322e450bcefa6fd2a819dcd3f5d /build/org.eclipse.cdt.managedbuilder.core
parent1bcae4bb9b9eec6b98252a64464115c00028f423 (diff)
downloadorg.eclipse.cdt-746e244c33465568ba28582a5965e84069962d65.tar.gz
org.eclipse.cdt-746e244c33465568ba28582a5965e84069962d65.tar.xz
org.eclipse.cdt-746e244c33465568ba28582a5965e84069962d65.zip
[sd90] Handle compiler specs inspection for setups with non-english locale
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
index d4aebe96fb..e90b22987e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java
@@ -16,6 +16,8 @@ import java.io.OutputStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
@@ -84,6 +86,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
+ private static final String ENV_LANGUAGE = "LANGUAGE"; //$NON-NLS-1$
+ private static final String ENV_LC_ALL = "LC_ALL"; //$NON-NLS-1$
+
private static final int MONITOR_SCALE = 100;
private static final int TICKS_REMOVE_MARKERS = 1 * MONITOR_SCALE;
private static final int TICKS_RUN_FOR_ONE_LANGUAGE = 10 * MONITOR_SCALE;
@@ -533,7 +538,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
}
}
- String[] envp = BuildRunnerHelper.getEnvp(currentCfgDescription);
+ String[] envp = getEnvp();
// Using GMAKE_ERROR_PARSER_ID as it can handle generated error messages
ErrorParserManager epm = new ErrorParserManager(currentProject, buildDirURI, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID});
@@ -567,6 +572,30 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
}
}
+ /**
+ * Get array of environment variables in format "var=value".
+ */
+ private String[] getEnvp() {
+ // On POSIX (Linux, UNIX) systems reset language variables to default (English)
+ // with UTF-8 encoding since GNU compilers can handle only UTF-8 characters.
+ // Include paths with locale characters will be handled properly regardless
+ // of the language as long as the encoding is set to UTF-8.
+ // Default language is set for parser because it relies on English messages
+ // in the output of the 'gcc -v' command.
+
+ List<String> envp = new ArrayList<String>(Arrays.asList(BuildRunnerHelper.getEnvp(currentCfgDescription)));
+ for (Iterator<String> iterator = envp.iterator(); iterator.hasNext();) {
+ String var = iterator.next();
+ if (var.startsWith(ENV_LANGUAGE + '=') || var.startsWith(ENV_LC_ALL + '=')) {
+ iterator.remove();
+ }
+ }
+ envp.add(ENV_LANGUAGE + "=C"); // override for GNU gettext //$NON-NLS-1$
+ envp.add(ENV_LC_ALL + "=C.UTF-8"); // for other parts of the system libraries //$NON-NLS-1$
+
+ return envp.toArray(new String[envp.size()]);
+ }
+
protected int runProgramForLanguage(String languageId, String command, String[] envp, URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, IProgressMonitor monitor) throws CoreException, IOException {
return buildRunnerHelper.build(monitor);
}

Back to the top