Skip to content

Commit c51bfdf

Browse files
committed
more work on command line mode for Java version
1 parent d5f603f commit c51bfdf

3 files changed

Lines changed: 53 additions & 50 deletions

File tree

app/src/processing/mode/java/Commander.java

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ static public void main(String[] args) {
7171
// System.out.println(System.getProperty("user.dir"));
7272
args = new String[] {
7373
"--export",
74+
// "--build",
75+
// "--run",
76+
// "--present",
77+
// "--force",
7478
// "--platform=windows",
7579
"--platform=macosx",
7680
"--bits=64",
@@ -188,8 +192,13 @@ public Commander(String[] args) {
188192
}
189193

190194
outputFolder = new File(outputPath);
191-
if (outputFolder.exists() && !force) {
192-
complainAndQuit("The output folder already exists. Use --force to overwrite it.", false);
195+
if (outputFolder.exists()) {
196+
if (force) {
197+
Base.removeDir(outputFolder);
198+
} else {
199+
complainAndQuit("The output folder already exists. " +
200+
"Use --force to remove it.", false);
201+
}
193202
}
194203

195204
if (!outputFolder.mkdirs()) {
@@ -215,44 +224,27 @@ public Commander(String[] args) {
215224
// complainAndQuit("Sketch path must point to the main .pde file.", false);
216225

217226
} else {
218-
//Sketch sketch = null;
219227
boolean success = false;
220228

221229
JavaMode javaMode =
222230
new JavaMode(null, Base.getContentFile("modes/java"));
223231
try {
224232
sketch = new Sketch(pdePath, javaMode);
225-
/*
226-
if (task == PREPROCESS) {
233+
if (task == BUILD || task == RUN || task == PRESENT) {
227234
JavaBuild build = new JavaBuild(sketch);
228-
build.preprocess(new File(sketchFolder), true);
229-
success = sketch.preprocess(new File(outputPath)) != null;
230-
231-
} else*/ if (task == BUILD) {
232-
JavaBuild build = new JavaBuild(sketch);
233-
String mainClassName =
234-
build.build(new File(sketchPath), outputFolder, true);
235-
success = mainClassName != null;
236-
237-
} else if (task == RUN || task == PRESENT) {
238-
JavaBuild build = new JavaBuild(sketch);
239-
String className = build.build(sketchFolder, outputFolder, true);
235+
File srcFolder = new File(outputFolder, "source");
236+
String className = build.build(srcFolder, outputFolder, true);
237+
// String className = build.build(sketchFolder, outputFolder, true);
240238
if (className != null) {
241239
success = true;
242-
Runner runner = new Runner(build, this);
243-
runner.launch(task == PRESENT);
244-
240+
if (task == RUN || task == PRESENT) {
241+
Runner runner = new Runner(build, this);
242+
runner.launch(task == PRESENT);
243+
}
245244
} else {
246245
success = false;
247246
}
248247

249-
// } else if (task == EXPORT_APPLET) {
250-
// if (outputPath != null) {
251-
// success = sketch.exportApplet(outputPath);
252-
// } else {
253-
// String target = sketchFolder + File.separatorChar + "applet";
254-
// success = sketch.exportApplet(target);
255-
// }
256248
} else if (task == EXPORT) {
257249
if (outputPath == null) {
258250
javaMode.handleExportApplication(sketch);
@@ -271,7 +263,11 @@ public Commander(String[] args) {
271263
}
272264
}
273265
}
274-
System.exit(success ? 0 : 1);
266+
if (!success) { // error already printed
267+
System.exit(1);
268+
}
269+
System.out.println("Finished.");
270+
System.exit(0);
275271

276272
} catch (SketchException re) {
277273
statusError(re);
@@ -334,7 +330,8 @@ static void printCommandLine(PrintStream out) {
334330
out.println();
335331
out.println("--force The sketch will not build if the output");
336332
out.println(" folder already exists, because the contents");
337-
out.println(" will be replaced. This option overrides.");
333+
out.println(" will be replaced. This option erases the");
334+
out.println(" folder first. Use with extreme caution!");
338335
out.println();
339336
out.println("--build Preprocess and compile a sketch into .class files.");
340337
out.println("--run Preprocess, compile, and run a sketch.");

core/src/processing/core/PApplet.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ public class PApplet extends Applet
237237
*/
238238
static public boolean useNativeSelect = (platform != LINUX);
239239

240-
/**
241-
* Modifier flags for the shortcut key used to trigger menus.
242-
* (Cmd on Mac OS X, Ctrl on Linux and Windows)
243-
*/
244-
static public final int MENU_SHORTCUT =
245-
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
240+
// /**
241+
// * Modifier flags for the shortcut key used to trigger menus.
242+
// * (Cmd on Mac OS X, Ctrl on Linux and Windows)
243+
// */
244+
// static public final int MENU_SHORTCUT =
245+
// Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
246246

247247
/** The PGraphics renderer associated with this PApplet */
248248
public PGraphics g;
@@ -2773,7 +2773,8 @@ protected void handleKeyEvent(KeyEvent event) {
27732773
// when running independently, because this sketch may be one component
27742774
// embedded inside an application that has its own close behavior.
27752775
if (external &&
2776-
((java.awt.event.KeyEvent) event.getNative()).getModifiers() == MENU_SHORTCUT &&
2776+
((java.awt.event.KeyEvent) event.getNative()).getModifiers() ==
2777+
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() &&
27772778
event.getKeyCode() == 'W') {
27782779
exit();
27792780
}
@@ -10382,7 +10383,7 @@ public void textureMode(int mode) {
1038210383
* Description to come...
1038310384
*
1038410385
* ( end auto-generated from textureWrap.xml )
10385-
*
10386+
*
1038610387
* @webref image:textures
1038710388
* @param wrap Either CLAMP (default) or REPEAT
1038810389
*/
@@ -10551,7 +10552,7 @@ public void noClip() {
1055110552
* This is a new reference entry for Processing 2.0. It will be updated shortly.
1055210553
*
1055310554
* ( end auto-generated )
10554-
*
10555+
*
1055510556
* @webref Rendering
1055610557
* @param mode the blending mode to use
1055710558
*/
@@ -10595,7 +10596,7 @@ public PShape createShape(int kind, float... p) {
1059510596
* This is a new reference entry for Processing 2.0. It will be updated shortly.
1059610597
*
1059710598
* ( end auto-generated )
10598-
*
10599+
*
1059910600
* @webref rendering:shaders
1060010601
* @param fragFilename name of fragment shader file
1060110602
*/
@@ -10618,7 +10619,7 @@ public PShader loadShader(String fragFilename, String vertFilename) {
1061810619
* This is a new reference entry for Processing 2.0. It will be updated shortly.
1061910620
*
1062010621
* ( end auto-generated )
10621-
*
10622+
*
1062210623
* @webref rendering:shaders
1062310624
* @param shader name of shader file
1062410625
*/
@@ -10643,7 +10644,7 @@ public void shader(PShader shader, int kind) {
1064310644
* This is a new reference entry for Processing 2.0. It will be updated shortly.
1064410645
*
1064510646
* ( end auto-generated )
10646-
*
10647+
*
1064710648
* @webref rendering:shaders
1064810649
*/
1064910650
public void resetShader() {
@@ -11524,9 +11525,9 @@ public void smooth() {
1152411525

1152511526

1152611527
/**
11527-
*
11528+
*
1152811529
* @param level either 2, 4, or 8
11529-
*/
11530+
*/
1153011531
public void smooth(int level) {
1153111532
if (recorder != null) recorder.smooth(level);
1153211533
g.smooth(level);

todo.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,23 @@ X with this specific (more esoteric) low-level case w/ a workaround
3131

3232

3333
2.0 FINAL / command line
34+
_ implement command line installer for Mac OS X
35+
_ add processing-java.bat (or exe?) for Windows
36+
_ add processing-java script for Linux
37+
_
3438
_ kill external editor (for all its quirks) in favor of command line
3539
_ use external editor needs to enable/disable across all windows
3640
_ http://code.google.com/p/processing/issues/detail?id=515
3741
C Casey says yes kill ext editor and finish command line
38-
_ processing.app.Commander headless still requiring X11
39-
_ problem is static calls to PApplet
40-
_ http://code.google.com/p/processing/issues/detail?id=220
41-
_ set java.awt.headless=true
42-
_ use as a way to remove the non-GUI-specifc code from PApplet
43-
_ so that the builds can run headless
42+
_ make note for docs to remove mentions of external editor
43+
X processing.app.Commander headless still requiring X11
44+
X problem is static calls to PApplet
45+
X http://code.google.com/p/processing/issues/detail?id=220
46+
X set -Djava.awt.headless=true
47+
X use as a way to remove the non-GUI-specifc code from PApplet
48+
X so that the builds can run headless
4449
X could move to java6 and better internal javac support (drop ecj)
45-
_ decided to use Java 6, so check on Javac usefulness
50+
o decided to use Java 6, so check on Javac usefulness
4651
_ change command line to just be part of regular (separate) distros
4752
_ there's so much platform code in there, it's not worth the extra work
4853
_ also include update check for logging

0 commit comments

Comments
 (0)