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

Fix for 189909 by Gerhard Schaber, scanner discovery does not handle -iquote

This commit is contained in:
Markus Schorn 2007-05-30 13:33:18 +00:00
parent fa5ff5f046
commit 02cf226a2b
4 changed files with 66 additions and 18 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Martin Oberhuber (Wind River Systems) - bug 155096 * Martin Oberhuber (Wind River Systems) - bug 155096
* Gerhard Schaber (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu; package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
@ -132,6 +133,8 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
* @return CCommandDSC compile command description * @return CCommandDSC compile command description
*/ */
public CCommandDSC getNewCCommandDSC(String[] tokens, boolean cppFileType) { public CCommandDSC getNewCCommandDSC(String[] tokens, boolean cppFileType) {
ArrayList dirafter = new ArrayList();
ArrayList includes = new ArrayList();
CCommandDSC command = new CCommandDSC(cppFileType, getProject()); CCommandDSC command = new CCommandDSC(cppFileType, getProject());
command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[0])); command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[0]));
for (int i = 1; i < tokens.length; ++i) { for (int i = 1; i < tokens.length; ++i) {
@ -163,6 +166,12 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
// ex. -I/dir // ex. -I/dir
} }
else if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDASH)) { else if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDASH)) {
for (Iterator iter=includes.iterator(); iter.hasNext(); ) {
option = (String)iter.next();
KVStringPair pair = new KVStringPair(SCDOptionsEnum.IQUOTE.toString(), option);
command.addSCOption(pair);
}
includes = new ArrayList();
// -I- has no parameter // -I- has no parameter
} }
else { else {
@ -179,15 +188,34 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE_FILE) || SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE_FILE) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IMACROS_FILE) || SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IMACROS_FILE) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDIRAFTER) || SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDIRAFTER) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.ISYSTEM))) { SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.ISYSTEM) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IQUOTE) )) {
option = (getAbsolutePath(option)).toString(); option = (getAbsolutePath(option)).toString();
} }
// add the pair if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDIRAFTER)) {
command.addSCOption(new KVStringPair(SCDOptionsEnum.getSCDOptionsEnum(j).toString(), option)); KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
dirafter.add(pair);
}
else if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE)) {
includes.add(option);
}
else { // add the pair
KVStringPair pair = new KVStringPair(SCDOptionsEnum.getSCDOptionsEnum(j).toString(), option);
command.addSCOption(pair);
}
break; break;
} }
} }
} }
String option;
for (Iterator iter=includes.iterator(); iter.hasNext(); ) {
option = (String)iter.next();
KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
command.addSCOption(pair);
}
for (Iterator iter=dirafter.iterator(); iter.hasNext(); ) {
command.addSCOption((KVStringPair)iter.next());
}
return command; return command;
} }

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Gerhard Schaber (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.util; package org.eclipse.cdt.make.internal.core.scannerconfig.util;
@ -80,7 +81,8 @@ public class CCommandDSC {
(option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()) || (option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()) ||
option.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) || option.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) ||
option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) || option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) ||
option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()))) option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) ||
option.getKey().equals(SCDOptionsEnum.IQUOTE.toString())))
{ {
String value = option.getValue(); String value = option.getValue();
value = (String)CygpathTranslator.translateIncludePaths(project, Collections.singletonList(value)).get(0); value = (String)CygpathTranslator.translateIncludePaths(project, Collections.singletonList(value)).get(0);
@ -142,12 +144,14 @@ public class CCommandDSC {
continue; continue;
String value = optionPair.getValue(); String value = optionPair.getValue();
if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) || if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) ||
optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString())) { optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) ||
optionPair.getKey().equals(SCDOptionsEnum.IQUOTE.toString())) {
value = makeAbsolute(project, value); value = makeAbsolute(project, value);
} }
if (quoteIncludePaths) { if (quoteIncludePaths) {
if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) || if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) ||
optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString())) { optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) ||
optionPair.getKey().equals(SCDOptionsEnum.IQUOTE.toString())) {
commandAsString += optionPair.getKey() + SINGLE_SPACE + commandAsString += optionPair.getKey() + SINGLE_SPACE +
"\"" + value + "\"" + SINGLE_SPACE; //$NON-NLS-1$//$NON-NLS-2$ "\"" + value + "\"" + SINGLE_SPACE; //$NON-NLS-1$//$NON-NLS-2$
} }
@ -367,12 +371,12 @@ public class CCommandDSC {
KVStringPair optionPair = (KVStringPair)options.next(); KVStringPair optionPair = (KVStringPair)options.next();
String key = optionPair.getKey(); String key = optionPair.getKey();
String value = optionPair.getValue(); String value = optionPair.getValue();
if (key.equals(SCDOptionsEnum.INCLUDE.toString())) { if (key.equals(SCDOptionsEnum.INCLUDE.toString()) || key.equals(SCDOptionsEnum.ISYSTEM.toString())) {
quoteincludes.add(value);
}
else if (key.equals(SCDOptionsEnum.ISYSTEM.toString())) {
includes.add(value); includes.add(value);
} }
else if (key.equals(SCDOptionsEnum.IQUOTE.toString())) {
quoteincludes.add(value);
}
else if (key.equals(SCDOptionsEnum.DEFINE.toString())) { else if (key.equals(SCDOptionsEnum.DEFINE.toString())) {
symbols.add(value); symbols.add(value);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Gerhard Schaber (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.util; package org.eclipse.cdt.make.internal.core.scannerconfig.util;
@ -32,7 +33,8 @@ public final class SCDOptionsEnum {
public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix
public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir
public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir
public static final int MAX = 13; public static final SCDOptionsEnum IQUOTE = new SCDOptionsEnum(14); // -iquote dir
public static final int MAX = 14;
private static final String[] SCDOPTION_STRING_VALS = { private static final String[] SCDOPTION_STRING_VALS = {
"cc", //$NON-NLS-1$ "cc", //$NON-NLS-1$
@ -48,7 +50,8 @@ public final class SCDOptionsEnum {
"-isystem", //$NON-NLS-1$ "-isystem", //$NON-NLS-1$
"-iprefix", //$NON-NLS-1$ "-iprefix", //$NON-NLS-1$
"-iwithprefix", //$NON-NLS-1$ "-iwithprefix", //$NON-NLS-1$
"-iwithprefixbefore" //$NON-NLS-1$ "-iwithprefixbefore", //$NON-NLS-1$
"-iquote" //$NON-NLS-1$
}; };
private static final SCDOptionsEnum SCDOPTIONS[] = { private static final SCDOptionsEnum SCDOPTIONS[] = {
COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE, COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE,

View file

@ -13,6 +13,7 @@
package org.eclipse.cdt.make.internal.core.scannerconfig2; package org.eclipse.cdt.make.internal.core.scannerconfig2;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -273,11 +274,11 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC
cmd.setSymbols(siItem); cmd.setSymbols(siItem);
siItem = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS); siItem = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
siItem = CygpathTranslator.translateIncludePaths(project, siItem); siItem = CygpathTranslator.translateIncludePaths(project, siItem);
siItem = CCommandDSC.makeAbsolute(project, siItem); siItem = CCommandDSC.makeRelative(project, siItem);
cmd.setIncludes(siItem); cmd.setIncludes(siItem);
siItem = (List) scannerInfo.get(ScannerInfoTypes.QUOTE_INCLUDE_PATHS); siItem = (List) scannerInfo.get(ScannerInfoTypes.QUOTE_INCLUDE_PATHS);
siItem = CygpathTranslator.translateIncludePaths(project, siItem); siItem = CygpathTranslator.translateIncludePaths(project, siItem);
siItem = CCommandDSC.makeAbsolute(project, siItem); siItem = CCommandDSC.makeRelative(project, siItem);
cmd.setQuoteIncludes(siItem); cmd.setQuoteIncludes(siItem);
cmd.setDiscovered(true); cmd.setDiscovered(true);
@ -603,7 +604,18 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC
*/ */
public IPath[] getIncludePaths() { public IPath[] getIncludePaths() {
// return new IPath[0]; // return new IPath[0];
return getAllIncludePaths(INCLUDE_PATH); IPath[] includepaths = getAllIncludePaths(INCLUDE_PATH);
IPath[] quotepaths = getAllIncludePaths(QUOTE_INCLUDE_PATH);
if (quotepaths == null || quotepaths.length == 0) {
return includepaths;
}
if (includepaths == null || includepaths.length == 0) {
return quotepaths;
}
ArrayList result = new ArrayList(includepaths.length + quotepaths.length);
result.addAll(Arrays.asList(includepaths));
result.addAll(Arrays.asList(quotepaths));
return (IPath[])result.toArray(new IPath[result.size()]);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -841,7 +853,8 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC
String include = (String) j.next(); String include = (String) j.next();
// the following line degrades perfomance // the following line degrades perfomance
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=189127 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=189127
// include = CCommandDSC.makeRelative(project, new Path(include)).toPortableString(); // it is not necessary for renaming projects anyway
// include = CCommandDSC.makeRelative(project, new Path(include)).toPortableString();
if (!allIncludes.contains(include)) { if (!allIncludes.contains(include)) {
allIncludes.add(include); allIncludes.add(include);
} }