Skip to content

Commit 7270624

Browse files
committed
Command line build. Still requires a display to show GUI.
1 parent 86ae5cd commit 7270624

File tree

1 file changed

+55
-17
lines changed

1 file changed

+55
-17
lines changed

app/src/processing/app/Base.java

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public class Base {
109109
Editor activeEditor;
110110

111111

112-
static public void main(String args[]) {
112+
static public void main(String args[]) throws Exception {
113113
try {
114114
File versionFile = getContentFile("lib/version.txt");
115115
if (versionFile.exists()) {
@@ -240,7 +240,7 @@ static protected void initRequirements() {
240240
}
241241

242242

243-
public Base(String[] args) {
243+
public Base(String[] args) throws Exception {
244244
platform.init(this);
245245

246246
// Get the sketchbook path, and make sure it's set properly
@@ -276,11 +276,28 @@ public Base(String[] args) {
276276
// Setup board-dependent variables.
277277
onBoardOrPortChange();
278278

279-
// Check if there were previously opened sketches to be restored
280-
boolean opened = restoreSketches();
281-
279+
boolean opened = false;
280+
boolean doUpload = false;
281+
String selectBoard = null;
282+
String selectPort = null;
282283
// Check if any files were passed in on the command line
283284
for (int i = 0; i < args.length; i++) {
285+
if (args[i].equals("--upload")) {
286+
doUpload = true;
287+
continue;
288+
}
289+
if (args[i].equals("--board")) {
290+
i++;
291+
if (i < args.length)
292+
selectBoard = args[i];
293+
continue;
294+
}
295+
if (args[i].equals("--port")) {
296+
i++;
297+
if (i < args.length)
298+
selectPort = args[i];
299+
continue;
300+
}
284301
String path = args[i];
285302
// Fix a problem with systems that use a non-ASCII languages. Paths are
286303
// being passed in with 8.3 syntax, which makes the sketch loader code
@@ -299,6 +316,23 @@ public Base(String[] args) {
299316
}
300317
}
301318

319+
if (doUpload) {
320+
if (!opened)
321+
throw new Exception(_("Can't open source sketch!"));
322+
Thread.sleep(2000);
323+
Editor editor = editors.get(0);
324+
if (selectPort != null)
325+
editor.selectSerialPort(selectPort);
326+
if (selectBoard != null)
327+
selectBoard(selectBoard);
328+
editor.exportHandler.run();
329+
System.exit(0);
330+
}
331+
332+
// Check if there were previously opened sketches to be restored
333+
if (restoreSketches())
334+
opened = true;
335+
302336
// Create a new empty window (will be replaced with any files to be opened)
303337
if (!opened) {
304338
handleNew();
@@ -1131,19 +1165,10 @@ public void rebuildBoardsMenu(JMenu menu) {
11311165
@SuppressWarnings("serial")
11321166
AbstractAction action = new AbstractAction(boardName) {
11331167
public void actionPerformed(ActionEvent actionevent) {
1134-
Preferences.set("target_package", (String) getValue("package"));
1135-
Preferences.set("target_platform", (String) getValue("platform"));
1136-
Preferences.set("board", (String) getValue("board"));
1137-
1138-
onBoardOrPortChange();
1139-
Sketch.buildSettingChanged();
1140-
rebuildImportMenu(Editor.importMenu);
1141-
rebuildExamplesMenu(Editor.examplesMenu);
1168+
selectBoard((String) getValue("b"));
11421169
}
11431170
};
1144-
action.putValue("package", packageName);
1145-
action.putValue("platform", platformName);
1146-
action.putValue("board", board);
1171+
action.putValue("b", packageName + ":" + platformName + ":" + board);
11471172
JMenuItem item = new JRadioButtonMenuItem(action);
11481173
if (packageName.equals(selPackage) &&
11491174
platformName.equals(selPlatform) && board.equals(selBoard)) {
@@ -1155,7 +1180,20 @@ public void actionPerformed(ActionEvent actionevent) {
11551180
}
11561181
}
11571182
}
1158-
1183+
1184+
1185+
private void selectBoard(String selectBoard) {
1186+
String[] split = selectBoard.split(":");
1187+
Preferences.set("target_package", split[0]);
1188+
Preferences.set("target_platform", split[1]);
1189+
Preferences.set("board", split[2]);
1190+
onBoardOrPortChange();
1191+
Sketch.buildSettingChanged();
1192+
rebuildImportMenu(Editor.importMenu);
1193+
rebuildExamplesMenu(Editor.examplesMenu);
1194+
}
1195+
1196+
11591197
public void rebuildProgrammerMenu(JMenu menu) {
11601198
menu.removeAll();
11611199
ButtonGroup group = new ButtonGroup();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy