Skip to content

Commit 6847c52

Browse files
author
Federico Fissore
committed
arduino-builder arguments must be passed in separate cmd.addArgument calls, otherwise special chars will break it. Fixes #3798
1 parent f18721a commit 6847c52

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

arduino-core/src/cc/arduino/Compiler.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,41 +172,55 @@ private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, Targ
172172
File executable = BaseNoGui.getContentFile("arduino-builder");
173173
CommandLine commandLine = new CommandLine(executable);
174174
commandLine.addArgument(action.value, false);
175-
commandLine.addArgument("-logger=machine", false);
175+
commandLine.addArgument("-logger", false);
176+
commandLine.addArgument("machine", false);
176177

177178
Stream.of(BaseNoGui.getHardwarePath(), new File(BaseNoGui.getSettingsFolder(), "packages").getAbsolutePath(), BaseNoGui.getSketchbookHardwareFolder().getAbsolutePath())
178179
.forEach(p -> {
179180
if (Files.exists(Paths.get(p))) {
180-
commandLine.addArgument("-hardware=\"" + p + "\"", false);
181+
commandLine.addArgument("-hardware", false);
182+
commandLine.addArgument("\"" + p + "\"", false);
181183
}
182184
});
183185

184186
Stream.of(BaseNoGui.getContentFile("tools-builder").getAbsolutePath(), Paths.get(BaseNoGui.getHardwarePath(), "tools", "avr").toAbsolutePath().toString(), new File(BaseNoGui.getSettingsFolder(), "packages").getAbsolutePath())
185187
.forEach(p -> {
186188
if (Files.exists(Paths.get(p))) {
187-
commandLine.addArgument("-tools=\"" + p + "\"", false);
189+
commandLine.addArgument("-tools", false);
190+
commandLine.addArgument("\"" + p + "\"", false);
188191
}
189192
});
190193

191-
commandLine.addArgument("-libraries=\"" + BaseNoGui.getSketchbookLibrariesFolder().getAbsolutePath() + "\"", false);
192-
commandLine.addArgument("-libraries=\"" + BaseNoGui.getContentFile("libraries").getAbsolutePath() + "\"", false);
194+
commandLine.addArgument("-libraries", false);
195+
commandLine.addArgument("\"" + BaseNoGui.getSketchbookLibrariesFolder().getAbsolutePath() + "\"", false);
196+
commandLine.addArgument("-libraries", false);
197+
commandLine.addArgument("\"" + BaseNoGui.getContentFile("libraries").getAbsolutePath() + "\"", false);
193198

194199
String fqbn = Stream.of(aPackage.getId(), platform.getId(), board.getId(), boardOptions(board)).filter(s -> !s.isEmpty()).collect(Collectors.joining(":"));
195-
commandLine.addArgument("-fqbn=" + fqbn, false);
200+
commandLine.addArgument("-fqbn", false);
201+
commandLine.addArgument(fqbn, false);
196202

197-
commandLine.addArgument("-ide-version=" + BaseNoGui.REVISION, false);
198-
commandLine.addArgument("-build-path=\"" + buildPath + "\"", false);
199-
commandLine.addArgument("-warnings=" + PreferencesData.get("compiler.warning_level"), false);
203+
commandLine.addArgument("-ide-version", false);
204+
commandLine.addArgument(Integer.toString(BaseNoGui.REVISION), false);
205+
commandLine.addArgument("-build-path", false);
206+
commandLine.addArgument("\"" + buildPath + "\"", false);
207+
commandLine.addArgument("-warnings", false);
208+
commandLine.addArgument(PreferencesData.get("compiler.warning_level"), false);
200209

201210
PreferencesData.getMap()
202211
.subTree("build_properties_custom")
203212
.entrySet()
204213
.stream()
205-
.forEach(kv -> commandLine.addArgument("-prefs=\"" + kv.getKey() + "=" + kv.getValue() + "\"", false));
214+
.forEach(kv -> {
215+
commandLine.addArgument("-prefs", false);
216+
commandLine.addArgument("\"" + kv.getKey() + "=" + kv.getValue() + "\"", false);
217+
});
206218

207-
commandLine.addArgument("-prefs=build.warn_data_percentage=" + PreferencesData.get("build.warn_data_percentage"));
219+
commandLine.addArgument("-prefs", false);
220+
commandLine.addArgument("build.warn_data_percentage=" + PreferencesData.get("build.warn_data_percentage"), false);
208221

209-
//commandLine.addArgument("-debug-level=10", false);
222+
//commandLine.addArgument("-debug-level", false);
223+
//commandLine.addArgument("10", false);
210224

211225
if (verbose) {
212226
commandLine.addArgument("-verbose", false);

0 commit comments

Comments
 (0)