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

Bug 498171 - Fix scanner discovery for some boards.

Seeing issues with the Due board.

Change-Id: I8af6de71f02e620b850dad7e14dcdd040b8f0bba
This commit is contained in:
Doug Schaefer 2016-10-01 12:29:22 -04:00
parent 4a425ec5dd
commit 1383c8d340
2 changed files with 47 additions and 8 deletions

View file

@ -200,7 +200,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
// TODO optimize by dealing with multi arg options like -o // TODO optimize by dealing with multi arg options like -o
Path filePath = buildDirectory.resolve(commandLine.get(i)); Path filePath = buildDirectory.resolve(commandLine.get(i));
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri()); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(filePath.toUri());
if (files.length > 0) { if (files.length > 0 && files[0].exists()) {
// replace it with a temp file // replace it with a temp file
Path parentPath = filePath.getParent(); Path parentPath = filePath.getParent();
String extension = files[0].getFileExtension(); String extension = files[0].getFileExtension();

View file

@ -556,7 +556,8 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
throw Activator.coreException("Upload command not specified", null); throw Activator.coreException("Upload command not specified", null);
} }
if (isWindows) { if (isWindows) {
return splitCommand(command); List<String> args = splitCommand(command);
return args.toArray(new String[args.size()]);
} else { } else {
return new String[] { "sh", "-c", command }; //$NON-NLS-1$ //$NON-NLS-2$ return new String[] { "sh", "-c", command }; //$NON-NLS-1$ //$NON-NLS-2$
} }
@ -659,9 +660,9 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
} }
ExtendedScannerInfo baseInfo = new ExtendedScannerInfo(null, includes); ExtendedScannerInfo baseInfo = new ExtendedScannerInfo(null, includes);
String[] command = splitCommand(commandString); List<String> command = splitCommand(commandString);
IScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(), Paths.get(command[0]), IScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(), command,
Arrays.copyOfRange(command, 1, command.length), baseInfo, resource, getBuildDirectoryURI()); baseInfo, resource, getBuildDirectoryURI());
// cache the results // cache the results
cachedScannerInfo = info; cachedScannerInfo = info;
@ -683,9 +684,47 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
return str; return str;
} }
private String[] splitCommand(String command) { private List<String> splitCommand(String command) {
// TODO deal with quotes properly, for now just strip boolean inQuotes = false;
return command.replaceAll("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ boolean inDouble = false;
List<String> args = new ArrayList<>();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < command.length(); i++) {
char c = command.charAt(i);
switch (c) {
case ' ':
if (inQuotes || inDouble) {
builder.append(c);
} else if (builder.length() > 0) {
args.add(builder.toString());
builder = new StringBuilder();
}
break;
case '\'':
if (inDouble) {
builder.append(c);
} else {
inQuotes = !inQuotes;
}
break;
case '"':
if (inQuotes) {
builder.append(c);
} else {
inDouble = !inDouble;
}
break;
default:
builder.append(c);
}
}
if (builder.length() > 0) {
args.add(builder.toString());
}
return args;
} }
@Override @Override