1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

Ability to parse build output running project build from subfolder in

Make Target view
This commit is contained in:
Andrew Gvozdev 2011-11-03 18:49:15 -04:00
parent 7d47f86034
commit 4f2f3a918d
2 changed files with 44 additions and 2 deletions

View file

@ -950,6 +950,46 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
}
}
/**
*/
public void testFileIgnoreWrongBuildDir() throws Exception {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
IFolder folder1=ResourceHelper.createFolder(project, "Folder1");
IFile file=ResourceHelper.createFile(project, "Folder1/Folder2/file.cpp");
ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true);
String languageId = ls.getLanguageId();
// create GCCBuildCommandParser
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT);
ErrorParserManager epm = new ErrorParserManager(project, null);
// Shift build directory, that could happen if Make Target from folder1 was run
IFolder buildDir = folder1;
epm.pushDirectoryURI(buildDir.getLocationURI());
// parse line
parser.startup(cfgDescription);
parser.processLine("gcc "
+ "-I/path0 "
+ "-I. "
+ "Folder1/Folder2/file.cpp",
epm);
parser.shutdown();
// check entries
IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice());
{
List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file, languageId);
assertEquals(new CIncludePathEntry(path0, 0), entries.get(0));
// Information from build output should take precedence over build dir
assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1));
}
}
/**
*/
public void testEndOfLine() throws Exception {

View file

@ -271,6 +271,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
List<String> options = parseForOptions(line);
if (options!=null) {
for (String option : options) {
@SuppressWarnings("unused")
int i =0;
for (AbstractOptionParser optionParser : getOptionParsers()) {
try {
if (optionParser.parseOption(option)) {
@ -647,7 +649,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
return null;
} else {
if (path.endsWith("/" + lastSegment)) { //$NON-NLS-1$
int pos = path.lastIndexOf(lastSegment);
int pos = path.lastIndexOf("/" + lastSegment); //$NON-NLS-1$
path = path.substring(0, pos);
continue;
} else {
@ -660,7 +662,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
try {
cwdURI = new URI(fileURI.getScheme(), fileURI.getUserInfo(), fileURI.getHost(),
fileURI.getPort(), path, fileURI.getQuery(), fileURI.getFragment());
fileURI.getPort(), path + '/', fileURI.getQuery(), fileURI.getFragment());
} catch (URISyntaxException e) {
// It should be valid URI here or something is wrong
MakeCorePlugin.log(e);