Skip to content

Commit f40f957

Browse files
ewaterlanderjonahgraham
authored andcommitted
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 #311 (see commit a89ce59). Now stripCommand() is in line with getResourcesFromCommand().
1 parent 82a235f commit f40f957

File tree

1 file changed

+14
-7
lines changed
  • build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core

1 file changed

+14
-7
lines changed

build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,17 +721,24 @@ public IResource[] getResourcesFromCommand(List<String> cmd, URI buildDirectoryU
721721
public List<String> stripCommand(List<String> command, IResource[] resources) {
722722
List<String> newCommand = new ArrayList<>();
723723

724-
for (int i = 0; i < command.size() - resources.length; ++i) {
724+
for (int i = 0; i < command.size(); ++i) {
725725
String arg = command.get(i);
726-
if (arg.startsWith("-o")) { //$NON-NLS-1$
727-
if (arg.equals("-o")) { //$NON-NLS-1$
728-
i++;
729-
}
726+
if (arg.equals("-o")) { //$NON-NLS-1$
727+
// this is an output file, skip.
728+
i++;
729+
continue;
730+
}
731+
if (arg.startsWith("-")) { //$NON-NLS-1$
732+
// ran into an option, add.
733+
newCommand.add(arg);
730734
continue;
731735
}
732-
newCommand.add(arg);
736+
String ext = getFileExtension(arg);
737+
if (!resourcesFileExtensions.contains(ext)) {
738+
// not a resource, add.
739+
newCommand.add(arg);
740+
}
733741
}
734-
735742
return newCommand;
736743
}
737744

0 commit comments

Comments
 (0)