1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-05-30 18:43:46 -04:00
commit c409e16cab
6 changed files with 93 additions and 22 deletions

View file

@ -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;
@ -85,6 +87,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;
@ -549,7 +554,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});
@ -583,6 +588,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);
}

View file

@ -1205,6 +1205,36 @@ public class ErrorParserFileMatchingTest extends TestCase {
assertEquals("error",problemMarkerInfo.description);
}
/**
* Checks if output of '-n'/'--just-print' or '-w'/'--print-directory' options of make can be recognized.
*
* @throws Exception...
*/
public void testPushPop_WithNoLevel() throws Exception {
String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFolder(fProject, "Folder/SubFolder");
ResourceHelper.createFile(fProject, fileName);
ResourceHelper.createFile(fProject, "Folder/"+fileName);
ResourceHelper.createFile(fProject, "Folder/SubFolder/"+fileName);
String lines = "make: Entering directory `Folder'\n"
+ "make: Entering directory `SubFolder'\n"
+ "make: Leaving directory `SubFolder'\n"
+ fileName+":1:error\n";
String[] errorParsers = {CWD_LOCATOR_ID, mockErrorParserId };
parseOutput(fProject, fProject.getLocation(), errorParsers, lines);
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/Folder/"+fileName,problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
/**
* Checks if a file from error output can be found.
*

View file

@ -501,8 +501,8 @@ public class BuildRunnerHelper implements Closeable {
* Get environment variables from configuration as array of "var=value" suitable
* for using as "envp" with Runtime.exec(String[] cmdarray, String[] envp, File dir)
*
* @param cfgDescription - configuration description
* @return String array of environment variables in format "var=value"
* @param cfgDescription - configuration description.
* @return String array of environment variables in format "var=value". Does not return {@code null}.
*/
public static String[] getEnvp(ICConfigurationDescription cfgDescription) {
IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();

View file

@ -24,14 +24,14 @@ import org.eclipse.core.runtime.Path;
*/
public class CWDLocator extends AbstractErrorParser {
private static boolean enabled = true;
@Override
public boolean processLine(String line, ErrorParserManager manager) {
int lineNumber = manager.getLineCounter();
// enable on first line (can be previously disabled if processed parallel build)
if (lineNumber==1)
enabled = true;
if (enabled)
return super.processLine(line, manager);
return false;
@ -53,7 +53,8 @@ public class CWDLocator extends AbstractErrorParser {
}
return false;
}
}, new ErrorPattern("make\\[(.*)\\]: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1$
},
new ErrorPattern("make\\[(.*)\\]: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1$
@Override
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
int level;
@ -74,7 +75,17 @@ public class CWDLocator extends AbstractErrorParser {
eoParser.pushDirectory(new Path(dir));
return true;
}
}, new ErrorPattern("make\\[.*\\]: Leaving directory", 0, 0) { //$NON-NLS-1$
},
// This is emitted by GNU make using options -n, --just-print or -w, --print-directory.
new ErrorPattern("make: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1$
@Override
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
String dir = matcher.group(1);
eoParser.pushDirectory(new Path(dir));
return true;
}
},
new ErrorPattern("make(\\[.*\\])?: Leaving directory", 0, 0) { //$NON-NLS-1$
@Override
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
eoParser.popDirectoryURI();

View file

@ -31,6 +31,8 @@ import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
@ -592,6 +594,15 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
compositeOptionsPage = new Composite(comp, SWT.NONE);
compositeOptionsPage.setLayout(new TabFolderLayout());
compositeOptionsPage.addControlListener(new ControlListener() {
@Override
public void controlResized(ControlEvent e) {
compositeOptionsPage.setBounds(compositeOptionsPage.getParent().getClientArea());
}
@Override
public void controlMoved(ControlEvent e) {
}
});
}
/**
@ -969,7 +980,6 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
optionsPage.setContainer(page);
optionsPage.createControl(compositeOptionsPage);
optionsPage.setVisible(false);
compositeOptionsPage.setBounds(compositeOptionsPage.getParent().getClientArea());
compositeOptionsPage.layout(true);
}
}
@ -1015,7 +1025,6 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
boolean isEditable = isEditableForProject || isEditableForPrefs;
currentOptionsPage.getControl().setEnabled(isEditable);
compositeOptionsPage.setEnabled(isEditable);
compositeOptionsPage.setBounds(compositeOptionsPage.getParent().getClientArea());
compositeOptionsPage.layout(true);
}
}

View file

@ -297,21 +297,13 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
{
if (! m_actionsInitialized) return;
// TODO: do we need any special enabling code here?
// Seems like we can rely on the enabling done by the DebugView itself,
// since we've associated these actions with it.
boolean enabled = hasSelection();
m_selectAllAction.setEnabled(enabled);
m_refreshAction.setEnabled(enabled);
m_resumeAction.setEnabled(enabled);
m_suspendAction.setEnabled(enabled);
m_terminateAction.setEnabled(enabled);
m_stepReturnAction.setEnabled(enabled);
m_stepOverAction.setEnabled(enabled);
m_stepIntoAction.setEnabled(enabled);
m_dropToFrameAction.setEnabled(enabled);
// We should not change the enablement of the debug view
// actions, as they are automatically enabled/disabled
// by the platform.
}
/** Updates actions specific to context menu. */