Skip to content

Commit f906d45

Browse files
author
Federico Fissore
committed
Better to separate arguments only when specifying paths, otherwise we can't specify empty args like "-warnings="
1 parent 6847c52 commit f906d45

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

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

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ enum BuilderAction {
107107
private final String pathToSketch;
108108
private final SketchData sketch;
109109
private final String buildPath;
110-
private boolean verbose;
110+
private final boolean verbose;
111111
private RunnerException exception;
112112

113113
public Compiler(SketchData data, String buildPath) {
@@ -172,8 +172,7 @@ 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", false);
176-
commandLine.addArgument("machine", false);
175+
commandLine.addArgument("-logger=machine", false);
177176

178177
Stream.of(BaseNoGui.getHardwarePath(), new File(BaseNoGui.getSettingsFolder(), "packages").getAbsolutePath(), BaseNoGui.getSketchbookHardwareFolder().getAbsolutePath())
179178
.forEach(p -> {
@@ -197,30 +196,22 @@ private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, Targ
197196
commandLine.addArgument("\"" + BaseNoGui.getContentFile("libraries").getAbsolutePath() + "\"", false);
198197

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

203-
commandLine.addArgument("-ide-version", false);
204-
commandLine.addArgument(Integer.toString(BaseNoGui.REVISION), false);
201+
commandLine.addArgument("-ide-version=" + BaseNoGui.REVISION, false);
205202
commandLine.addArgument("-build-path", false);
206203
commandLine.addArgument("\"" + buildPath + "\"", false);
207-
commandLine.addArgument("-warnings", false);
208-
commandLine.addArgument(PreferencesData.get("compiler.warning_level"), false);
204+
commandLine.addArgument("-warnings=" + PreferencesData.get("compiler.warning_level"), false);
209205

210206
PreferencesData.getMap()
211207
.subTree("build_properties_custom")
212208
.entrySet()
213209
.stream()
214-
.forEach(kv -> {
215-
commandLine.addArgument("-prefs", false);
216-
commandLine.addArgument("\"" + kv.getKey() + "=" + kv.getValue() + "\"", false);
217-
});
210+
.forEach(kv -> commandLine.addArgument("-prefs=\"" + kv.getKey() + "=" + kv.getValue() + "\"", false));
218211

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

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

225216
if (verbose) {
226217
commandLine.addArgument("-verbose", false);
@@ -260,7 +251,7 @@ private void callArduinoBuilder(TargetBoard board, TargetPlatform platform, Targ
260251
}
261252
}
262253

263-
protected void size(PreferencesMap prefs) throws RunnerException {
254+
private void size(PreferencesMap prefs) throws RunnerException {
264255
String maxTextSizeString = prefs.get("upload.maximum_size");
265256
String maxDataSizeString = prefs.get("upload.maximum_data_size");
266257

@@ -310,7 +301,7 @@ protected void size(PreferencesMap prefs) throws RunnerException {
310301
}
311302
}
312303

313-
void saveHex(PreferencesMap prefs) throws RunnerException {
304+
private void saveHex(PreferencesMap prefs) throws RunnerException {
314305
List<String> compiledSketches = new ArrayList<>(prefs.subTree("recipe.output.tmp_file", 1).values());
315306
List<String> copyOfCompiledSketches = new ArrayList<>(prefs.subTree("recipe.output.save_file", 1).values());
316307

@@ -365,19 +356,15 @@ private boolean isExportCompiledSketchSupported(List<String> compiledSketches, L
365356
return (compiledSketches.isEmpty() || copyOfCompiledSketches.isEmpty() || copyOfCompiledSketches.size() < compiledSketches.size()) && (!prefs.containsKey("recipe.output.tmp_file") || !prefs.containsKey("recipe.output.save_file"));
366357
}
367358

368-
void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
369-
List<String> patterns = new ArrayList<>();
370-
for (String key : prefs.keySet()) {
371-
if (key.startsWith("recipe." + recipeClass) && key.endsWith(".pattern"))
372-
patterns.add(key);
373-
}
359+
private void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
360+
List<String> patterns = prefs.keySet().stream().filter(key -> key.startsWith("recipe." + recipeClass) && key.endsWith(".pattern")).collect(Collectors.toList());
374361
Collections.sort(patterns);
375362
for (String recipe : patterns) {
376363
runRecipe(recipe, prefs);
377364
}
378365
}
379366

380-
void runRecipe(String recipe, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
367+
private void runRecipe(String recipe, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
381368
PreferencesMap dict = new PreferencesMap(prefs);
382369
dict.put("ide_version", "" + BaseNoGui.REVISION);
383370
dict.put("sketch_path", sketch.getFolder().getAbsolutePath());
@@ -394,7 +381,7 @@ void runRecipe(String recipe, PreferencesMap prefs) throws RunnerException, Pref
394381

395382
private void exec(String[] command) throws RunnerException {
396383
// eliminate any empty array entries
397-
List<String> stringList = new ArrayList<String>();
384+
List<String> stringList = new ArrayList<>();
398385
for (String string : command) {
399386
string = string.trim();
400387
if (string.length() != 0)
@@ -582,9 +569,9 @@ public void message(String s) {
582569
System.err.println(s);
583570
}
584571

585-
public RunnerException placeException(String message,
586-
String dotJavaFilename,
587-
int dotJavaLine) {
572+
private RunnerException placeException(String message,
573+
String dotJavaFilename,
574+
int dotJavaLine) {
588575
// Placing errors is simple, because we inserted #line directives
589576
// into the preprocessed source. The compiler gives us correct
590577
// the file name and line number. :-)

0 commit comments

Comments
 (0)