Skip to content

Commit c761fc1

Browse files
committed
Added command line compile.
Merge branch 'cmd-build' into ide-1.5.x Conflicts: app/src/processing/app/Base.java
2 parents 74dea07 + 7270624 commit c761fc1

File tree

1 file changed

+84
-31
lines changed

1 file changed

+84
-31
lines changed

app/src/processing/app/Base.java

Lines changed: 84 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class Base {
113113
Editor activeEditor;
114114

115115

116-
static public void main(String args[]) {
116+
static public void main(String args[]) throws Exception {
117117
try {
118118
File versionFile = getContentFile("lib/version.txt");
119119
if (versionFile.exists()) {
@@ -244,7 +244,7 @@ static protected void initRequirements() {
244244
}
245245

246246

247-
public Base(String[] args) {
247+
public Base(String[] args) throws Exception {
248248
platform.init(this);
249249

250250
// Get the sketchbook path, and make sure it's set properly
@@ -280,11 +280,28 @@ public Base(String[] args) {
280280
// Setup board-dependent variables.
281281
onBoardOrPortChange();
282282

283-
// Check if there were previously opened sketches to be restored
284-
boolean opened = restoreSketches();
285-
283+
boolean opened = false;
284+
boolean doUpload = false;
285+
String selectBoard = null;
286+
String selectPort = null;
286287
// Check if any files were passed in on the command line
287288
for (int i = 0; i < args.length; i++) {
289+
if (args[i].equals("--upload")) {
290+
doUpload = true;
291+
continue;
292+
}
293+
if (args[i].equals("--board")) {
294+
i++;
295+
if (i < args.length)
296+
selectBoard = args[i];
297+
continue;
298+
}
299+
if (args[i].equals("--port")) {
300+
i++;
301+
if (i < args.length)
302+
selectPort = args[i];
303+
continue;
304+
}
288305
String path = args[i];
289306
// Fix a problem with systems that use a non-ASCII languages. Paths are
290307
// being passed in with 8.3 syntax, which makes the sketch loader code
@@ -303,6 +320,23 @@ public Base(String[] args) {
303320
}
304321
}
305322

323+
if (doUpload) {
324+
if (!opened)
325+
throw new Exception(_("Can't open source sketch!"));
326+
Thread.sleep(2000);
327+
Editor editor = editors.get(0);
328+
if (selectPort != null)
329+
editor.selectSerialPort(selectPort);
330+
if (selectBoard != null)
331+
selectBoard(selectBoard, editor);
332+
editor.exportHandler.run();
333+
System.exit(0);
334+
}
335+
336+
// Check if there were previously opened sketches to be restored
337+
if (restoreSketches())
338+
opened = true;
339+
306340
// Create a new empty window (will be replaced with any files to be opened)
307341
if (!opened) {
308342
handleNew();
@@ -1162,36 +1196,39 @@ public void rebuildBoardsMenu(JMenu toolsMenu, final Editor editor) {
11621196
// For every platform cycle through all boards
11631197
for (final String boardID : targetPlatform.getBoards().keySet()) {
11641198

1165-
PreferencesMap boardAttributes = boards.get(boardID);
1166-
1167-
AbstractAction action = new AbstractAction(boardAttributes.get("name")) {
1168-
1169-
@Override
1170-
public void actionPerformed(ActionEvent e) {
1171-
Preferences.set("target_package", (String) getValue("package"));
1172-
Preferences.set("target_platform", (String) getValue("platform"));
1173-
Preferences.set("board", (String) getValue("board"));
1174-
1175-
filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), 1, e);
1176-
1177-
onBoardOrPortChange();
1178-
Sketch.buildSettingChanged();
1179-
rebuildImportMenu(Editor.importMenu, editor);
1180-
rebuildExamplesMenu(Editor.examplesMenu);
1199+
// PreferencesMap boardAttributes = boards.get(boardID);
1200+
// AbstractAction action = new AbstractAction(boardAttributes.get("name")) {
1201+
//
1202+
// @Override
1203+
// public void actionPerformed(ActionEvent e) {
1204+
// Preferences.set("target_package", (String) getValue("package"));
1205+
// Preferences.set("target_platform", (String) getValue("platform"));
1206+
// Preferences.set("board", (String) getValue("board"));
1207+
//
1208+
// filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), 1);
1209+
//
1210+
// onBoardOrPortChange();
1211+
// Sketch.buildSettingChanged();
1212+
// rebuildImportMenu(Editor.importMenu, editor);
1213+
// rebuildExamplesMenu(Editor.examplesMenu);
1214+
//=======
1215+
// Setup a menu item for the current board
1216+
String boardName = boards.get(boardID).get("name");
1217+
@SuppressWarnings("serial")
1218+
AbstractAction action = new AbstractAction(boardName) {
1219+
public void actionPerformed(ActionEvent actionevent) {
1220+
selectBoard((String) getValue("b"), editor);
11811221
}
11821222

11831223
};
1184-
action.putValue("properties", boardAttributes);
1185-
action.putValue("board", boardID);
1186-
action.putValue("package", packageName);
1187-
action.putValue("platform", platformName);
1224+
action.putValue("b", packageName + ":" + platformName + ":" + boardID);
11881225

11891226
JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
11901227
boardsMenu.add(item);
11911228
boardsButtonGroup.add(item);
11921229

1193-
if (selBoard.equals(action.getValue("board")) && selPackage.equals(action.getValue("package"))
1194-
&& selPlatform.equals(action.getValue("platform"))) {
1230+
if (selBoard.equals(boardID) && selPackage.equals(packageName)
1231+
&& selPlatform.equals(platformName)) {
11951232
menuItemsToClickAfterStartup.add(item);
11961233
}
11971234

@@ -1214,7 +1251,7 @@ public void actionPerformed(ActionEvent e) {
12141251
Preferences.set("board", (String) getValue("board"));
12151252
Preferences.set("custom_" + customMenuID, boardID + "_" + (String) getValue("custom_menu_option"));
12161253

1217-
filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), currentIndex, e);
1254+
filterVisibilityOfSubsequentBoardMenus((String) getValue("board"), currentIndex);
12181255

12191256
onBoardOrPortChange();
12201257
Sketch.buildSettingChanged();
@@ -1258,7 +1295,7 @@ public void actionPerformed(ActionEvent e) {
12581295
}
12591296
}
12601297

1261-
private static void filterVisibilityOfSubsequentBoardMenus(String boardID, int fromIndex, ActionEvent originatingEvent) {
1298+
private static void filterVisibilityOfSubsequentBoardMenus(String boardID, int fromIndex) {
12621299
for (int i = fromIndex; i < Editor.boardsMenus.size(); i++) {
12631300
JMenu menu = Editor.boardsMenus.get(i);
12641301
for (int m = 0; m < menu.getItemCount(); m++) {
@@ -1271,7 +1308,7 @@ private static void filterVisibilityOfSubsequentBoardMenus(String boardID, int f
12711308
JMenuItem visibleSelectedOrFirstMenuItem = selectVisibleSelectedOrFirstMenuItem(menu);
12721309
if (!visibleSelectedOrFirstMenuItem.isSelected()) {
12731310
visibleSelectedOrFirstMenuItem.setSelected(true);
1274-
visibleSelectedOrFirstMenuItem.getAction().actionPerformed(originatingEvent);
1311+
visibleSelectedOrFirstMenuItem.getAction().actionPerformed(null);
12751312
}
12761313
}
12771314
}
@@ -1329,7 +1366,23 @@ private static JMenuItem selectFirstEnabledMenuItem(JMenu menu) {
13291366
}
13301367
throw new IllegalStateException("Menu has no enabled items");
13311368
}
1332-
1369+
1370+
1371+
private void selectBoard(String selectBoard, Editor editor) {
1372+
String[] split = selectBoard.split(":");
1373+
Preferences.set("target_package", split[0]);
1374+
Preferences.set("target_platform", split[1]);
1375+
Preferences.set("board", split[2]);
1376+
1377+
filterVisibilityOfSubsequentBoardMenus(split[2], 1);
1378+
1379+
onBoardOrPortChange();
1380+
Sketch.buildSettingChanged();
1381+
rebuildImportMenu(Editor.importMenu, editor);
1382+
rebuildExamplesMenu(Editor.examplesMenu);
1383+
}
1384+
1385+
13331386
public void rebuildProgrammerMenu(JMenu menu) {
13341387
menu.removeAll();
13351388
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