mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-12 11:35:21 +02:00
Ability to parse build output running project build from subfolder in
Make Target view
This commit is contained in:
parent
7d47f86034
commit
4f2f3a918d
2 changed files with 44 additions and 2 deletions
|
@ -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 {
|
public void testEndOfLine() throws Exception {
|
||||||
|
|
|
@ -271,6 +271,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
|
||||||
List<String> options = parseForOptions(line);
|
List<String> options = parseForOptions(line);
|
||||||
if (options!=null) {
|
if (options!=null) {
|
||||||
for (String option : options) {
|
for (String option : options) {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int i =0;
|
||||||
for (AbstractOptionParser optionParser : getOptionParsers()) {
|
for (AbstractOptionParser optionParser : getOptionParsers()) {
|
||||||
try {
|
try {
|
||||||
if (optionParser.parseOption(option)) {
|
if (optionParser.parseOption(option)) {
|
||||||
|
@ -647,7 +649,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (path.endsWith("/" + lastSegment)) { //$NON-NLS-1$
|
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);
|
path = path.substring(0, pos);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -660,7 +662,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cwdURI = new URI(fileURI.getScheme(), fileURI.getUserInfo(), fileURI.getHost(),
|
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) {
|
} catch (URISyntaxException e) {
|
||||||
// It should be valid URI here or something is wrong
|
// It should be valid URI here or something is wrong
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue