Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2016-10-01 16:29:22 +0000
committerDoug Schaefer2016-10-01 16:29:22 +0000
commit1383c8d3403653056727ab3f5c6b7c4e577ac3c8 (patch)
tree4aee846287fc7fb9313f61ba5a9601a3569a2c79
parent4a425ec5dd00f23c722a5694009808c389c8e467 (diff)
downloadorg.eclipse.cdt-1383c8d3403653056727ab3f5c6b7c4e577ac3c8.tar.gz
org.eclipse.cdt-1383c8d3403653056727ab3f5c6b7c4e577ac3c8.tar.xz
org.eclipse.cdt-1383c8d3403653056727ab3f5c6b7c4e577ac3c8.zip
Bug 498171 - Fix scanner discovery for some boards.
Seeing issues with the Due board. Change-Id: I8af6de71f02e620b850dad7e14dcdd040b8f0bba
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java2
-rw-r--r--toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java53
2 files changed, 47 insertions, 8 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
index 8be04d5d92d..b5bbbcef948 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
@@ -200,7 +200,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
// TODO optimize by dealing with multi arg options like -o
Path filePath = buildDirectory.resolve(commandLine.get(i));
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
Path parentPath = filePath.getParent();
String extension = files[0].getFileExtension();
diff --git a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
index cd057f489fa..9b27c6c5913 100644
--- a/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
+++ b/toolchains/arduino/org.eclipse.cdt.arduino.core/src/org/eclipse/cdt/arduino/core/internal/build/ArduinoBuildConfiguration.java
@@ -556,7 +556,8 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
throw Activator.coreException("Upload command not specified", null);
}
if (isWindows) {
- return splitCommand(command);
+ List<String> args = splitCommand(command);
+ return args.toArray(new String[args.size()]);
} else {
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);
- String[] command = splitCommand(commandString);
- IScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(), Paths.get(command[0]),
- Arrays.copyOfRange(command, 1, command.length), baseInfo, resource, getBuildDirectoryURI());
+ List<String> command = splitCommand(commandString);
+ IScannerInfo info = getToolChain().getScannerInfo(getBuildConfiguration(), command,
+ baseInfo, resource, getBuildDirectoryURI());
// cache the results
cachedScannerInfo = info;
@@ -683,9 +684,47 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration
return str;
}
- private String[] splitCommand(String command) {
- // TODO deal with quotes properly, for now just strip
- return command.replaceAll("\"", "").split("\\s+"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private List<String> splitCommand(String command) {
+ boolean inQuotes = false;
+ 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

Back to the top