1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Process some commandline arguments earlier

Previously, the --board and --port arguments were stored in a variable
first and only processed later. Now, the arguments are processed right
away.

This does mean that the arguments are processed when the GUI is not yet
initialized, which caused problems with calling onBoardOrPortChange and
friends from selectBoard. However, since the GUI is not initialized,
there is no real reason to call them either - if we just set the
preferences to the right values, the GUI will be initialized correctly
later. For this reason, selectBoard no longer calls the GUI update
methods. Instead, those are called from the GUI code when the board is
changed through the menu instead (e.g., after calling selectBoard).

This commit slightly changes behaviour. Previously, --board and --port
only worked in combination with --verify and --upload, but were ignored
when just starting the IDE. Now, these are processed regardless of the
other options present.

Additionally, this commit causes all changed preferences to be saved.
Previously, only changes with --pref were saved, --board and --port
options were only active for the current run. This was caused because
the saving of the preferences happened as a side effect of loading the
file in the Editor, but only the --pref option was processed at that
time.

Note that the --verbose options are still only active for the current
run and are only valid combined with --verify or --upload (since they
default to non-verbose instead of the current preference).
This commit is contained in:
Matthijs Kooijman
2014-04-07 10:27:39 +02:00
committed by Cristian Maglie
parent 7301b37c7e
commit d3e2208c01
2 changed files with 20 additions and 18 deletions

View File

@ -361,14 +361,14 @@ public class Base {
i++;
if (i >= args.length)
showError(null, _("Argument required for --board"), 3);
selectBoard = args[i];
processBoardArgument(args[i]);
continue;
}
if (args[i].equals("--port")) {
i++;
if (i >= args.length)
showError(null, _("Argument required for --port"), 3);
selectPort = args[i];
Base.selectSerialPort(args[i]);
continue;
}
if (args[i].equals("--curdir")) {
@ -439,13 +439,8 @@ public class Base {
Editor editor = editors.get(0);
// Do board selection if requested
processBoardArgument(selectBoard);
if (action == ACTION.UPLOAD) {
// Build and upload
if (selectPort != null)
editor.selectSerialPort(selectPort);
editor.exportHandler.run();
} else {
// Build only
@ -1456,6 +1451,11 @@ public class Base {
Action action = new AbstractAction(board.getName()) {
public void actionPerformed(ActionEvent actionevent) {
selectBoard((TargetBoard)getValue("b"));
filterVisibilityOfSubsequentBoardMenus((TargetBoard)getValue("b"), 1);
onBoardOrPortChange();
rebuildImportMenu(Editor.importMenu);
rebuildExamplesMenu(Editor.examplesMenu);
}
};
action.putValue("b", board);
@ -1592,12 +1592,6 @@ public class Base {
File platformFolder = targetPlatform.getFolder();
Preferences.set("runtime.platform.path", platformFolder.getAbsolutePath());
Preferences.set("runtime.hardware.path", platformFolder.getParentFile().getAbsolutePath());
filterVisibilityOfSubsequentBoardMenus(targetBoard, 1);
onBoardOrPortChange();
rebuildImportMenu(Editor.importMenu);
rebuildExamplesMenu(Editor.examplesMenu);
}
public static void selectSerialPort(String port) {