Skip to content

Commit c740f25

Browse files
author
Federico Fissore
committed
SAM boards stop compiling due to way of handling params with spaces on different OSs. Fixed
1 parent 4c9e5fc commit c740f25

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

arduino-core/src/processing/app/debug/Compiler.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import processing.app.legacy.PApplet;
5555
import processing.app.packages.LegacyUserLibrary;
5656
import processing.app.packages.UserLibrary;
57+
import processing.app.tools.ArgumentsWithSpaceAwareCommandLine;
5758

5859
public class Compiler implements MessageConsumer {
5960

@@ -319,10 +320,10 @@ protected void size(PreferencesMap prefs) throws RunnerException {
319320
if (maxDataSize > 0) {
320321
System.out
321322
.println(I18n
322-
.format(
323-
_("Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes."),
324-
dataSize, maxDataSize, dataSize * 100 / maxDataSize,
325-
maxDataSize - dataSize));
323+
.format(
324+
_("Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes."),
325+
dataSize, maxDataSize, dataSize * 100 / maxDataSize,
326+
maxDataSize - dataSize));
326327
} else {
327328
System.out.println(I18n
328329
.format(_("Global variables use {0} bytes of dynamic memory."), dataSize));
@@ -736,9 +737,9 @@ public void stop() {
736737
}
737738
});
738739

739-
CommandLine commandLine = new CommandLine(command[0]);
740+
CommandLine commandLine = new ArgumentsWithSpaceAwareCommandLine(command[0]);
740741
for (int i = 1; i < command.length; i++) {
741-
commandLine.addArgument(command[i]);
742+
commandLine.addArgument(command[i], false);
742743
}
743744

744745
int result;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package processing.app.tools;
2+
3+
import org.apache.commons.exec.CommandLine;
4+
import processing.app.BaseNoGui;
5+
import processing.app.Platform;
6+
import processing.app.helpers.OSUtils;
7+
8+
import java.io.File;
9+
10+
public class ArgumentsWithSpaceAwareCommandLine extends CommandLine {
11+
12+
public ArgumentsWithSpaceAwareCommandLine(String executable) {
13+
super(executable);
14+
}
15+
16+
public ArgumentsWithSpaceAwareCommandLine(File executable) {
17+
super(executable);
18+
}
19+
20+
public ArgumentsWithSpaceAwareCommandLine(CommandLine other) {
21+
super(other);
22+
}
23+
24+
@Override
25+
public CommandLine addArgument(String argument, boolean handleQuoting) {
26+
if (argument.contains(" ") && OSUtils.isWindows()) {
27+
argument = argument.replaceAll("\"", "").replaceAll("'", "");
28+
}
29+
30+
return super.addArgument(argument, handleQuoting);
31+
}
32+
}

0 commit comments

Comments
 (0)