1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +02:00

Improved GCCToolChain.stripCommand()

GCCToolChain.stripCommand() assumed that all resources are at the end
of the command, like in the old version of
GCCToolChain.getResourcesFromCommand() which was fixed in PR  (see
commit a89ce59df2). Now stripCommand() is in line with
getResourcesFromCommand().
This commit is contained in:
Erwin Waterlander 2023-04-21 09:07:45 +01:00 committed by Jonah Graham
parent 82a235fbb9
commit f40f957c6c

View file

@ -721,17 +721,24 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
public List<String> stripCommand(List<String> command, IResource[] resources) { public List<String> stripCommand(List<String> command, IResource[] resources) {
List<String> newCommand = new ArrayList<>(); List<String> newCommand = new ArrayList<>();
for (int i = 0; i < command.size() - resources.length; ++i) { for (int i = 0; i < command.size(); ++i) {
String arg = command.get(i); String arg = command.get(i);
if (arg.startsWith("-o")) { //$NON-NLS-1$ if (arg.equals("-o")) { //$NON-NLS-1$
if (arg.equals("-o")) { //$NON-NLS-1$ // this is an output file, skip.
i++; i++;
}
continue; continue;
} }
newCommand.add(arg); if (arg.startsWith("-")) { //$NON-NLS-1$
// ran into an option, add.
newCommand.add(arg);
continue;
}
String ext = getFileExtension(arg);
if (!resourcesFileExtensions.contains(ext)) {
// not a resource, add.
newCommand.add(arg);
}
} }
return newCommand; return newCommand;
} }