From 3736aa0ae4af13b6416b677a45a6cf780d192c32 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 20 Oct 2012 20:15:34 +0000 Subject: [PATCH] more work on command line mode for Java version --- app/src/processing/mode/java/Commander.java | 55 ++++++++++----------- core/src/processing/core/PApplet.java | 29 +++++------ todo.txt | 19 ++++--- 3 files changed, 53 insertions(+), 50 deletions(-) diff --git a/app/src/processing/mode/java/Commander.java b/app/src/processing/mode/java/Commander.java index 4825639fe..12add7389 100644 --- a/app/src/processing/mode/java/Commander.java +++ b/app/src/processing/mode/java/Commander.java @@ -71,6 +71,10 @@ public class Commander implements RunnerListener { // System.out.println(System.getProperty("user.dir")); args = new String[] { "--export", +// "--build", +// "--run", +// "--present", +// "--force", // "--platform=windows", "--platform=macosx", "--bits=64", @@ -188,8 +192,13 @@ public class Commander implements RunnerListener { } outputFolder = new File(outputPath); - if (outputFolder.exists() && !force) { - complainAndQuit("The output folder already exists. Use --force to overwrite it.", false); + if (outputFolder.exists()) { + if (force) { + Base.removeDir(outputFolder); + } else { + complainAndQuit("The output folder already exists. " + + "Use --force to remove it.", false); + } } if (!outputFolder.mkdirs()) { @@ -215,44 +224,27 @@ public class Commander implements RunnerListener { // complainAndQuit("Sketch path must point to the main .pde file.", false); } else { - //Sketch sketch = null; boolean success = false; JavaMode javaMode = new JavaMode(null, Base.getContentFile("modes/java")); try { sketch = new Sketch(pdePath, javaMode); - /* - if (task == PREPROCESS) { + if (task == BUILD || task == RUN || task == PRESENT) { JavaBuild build = new JavaBuild(sketch); - build.preprocess(new File(sketchFolder), true); - success = sketch.preprocess(new File(outputPath)) != null; - - } else*/ if (task == BUILD) { - JavaBuild build = new JavaBuild(sketch); - String mainClassName = - build.build(new File(sketchPath), outputFolder, true); - success = mainClassName != null; - - } else if (task == RUN || task == PRESENT) { - JavaBuild build = new JavaBuild(sketch); - String className = build.build(sketchFolder, outputFolder, true); + File srcFolder = new File(outputFolder, "source"); + String className = build.build(srcFolder, outputFolder, true); +// String className = build.build(sketchFolder, outputFolder, true); if (className != null) { success = true; - Runner runner = new Runner(build, this); - runner.launch(task == PRESENT); - + if (task == RUN || task == PRESENT) { + Runner runner = new Runner(build, this); + runner.launch(task == PRESENT); + } } else { success = false; } -// } else if (task == EXPORT_APPLET) { -// if (outputPath != null) { -// success = sketch.exportApplet(outputPath); -// } else { -// String target = sketchFolder + File.separatorChar + "applet"; -// success = sketch.exportApplet(target); -// } } else if (task == EXPORT) { if (outputPath == null) { javaMode.handleExportApplication(sketch); @@ -271,7 +263,11 @@ public class Commander implements RunnerListener { } } } - System.exit(success ? 0 : 1); + if (!success) { // error already printed + System.exit(1); + } + System.out.println("Finished."); + System.exit(0); } catch (SketchException re) { statusError(re); @@ -334,7 +330,8 @@ public class Commander implements RunnerListener { out.println(); out.println("--force The sketch will not build if the output"); out.println(" folder already exists, because the contents"); - out.println(" will be replaced. This option overrides."); + out.println(" will be replaced. This option erases the"); + out.println(" folder first. Use with extreme caution!"); out.println(); out.println("--build Preprocess and compile a sketch into .class files."); out.println("--run Preprocess, compile, and run a sketch."); diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 67815e44b..74f520a10 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -237,12 +237,12 @@ public class PApplet extends Applet */ static public boolean useNativeSelect = (platform != LINUX); - /** - * Modifier flags for the shortcut key used to trigger menus. - * (Cmd on Mac OS X, Ctrl on Linux and Windows) - */ - static public final int MENU_SHORTCUT = - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); +// /** +// * Modifier flags for the shortcut key used to trigger menus. +// * (Cmd on Mac OS X, Ctrl on Linux and Windows) +// */ +// static public final int MENU_SHORTCUT = +// Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); /** The PGraphics renderer associated with this PApplet */ public PGraphics g; @@ -2773,7 +2773,8 @@ public class PApplet extends Applet // when running independently, because this sketch may be one component // embedded inside an application that has its own close behavior. if (external && - ((java.awt.event.KeyEvent) event.getNative()).getModifiers() == MENU_SHORTCUT && + ((java.awt.event.KeyEvent) event.getNative()).getModifiers() == + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() && event.getKeyCode() == 'W') { exit(); } @@ -10382,7 +10383,7 @@ public class PApplet extends Applet * Description to come... * * ( end auto-generated from textureWrap.xml ) - * + * * @webref image:textures * @param wrap Either CLAMP (default) or REPEAT */ @@ -10551,7 +10552,7 @@ public class PApplet extends Applet * This is a new reference entry for Processing 2.0. It will be updated shortly. * * ( end auto-generated ) - * + * * @webref Rendering * @param mode the blending mode to use */ @@ -10595,7 +10596,7 @@ public class PApplet extends Applet * This is a new reference entry for Processing 2.0. It will be updated shortly. * * ( end auto-generated ) - * + * * @webref rendering:shaders * @param fragFilename name of fragment shader file */ @@ -10618,7 +10619,7 @@ public class PApplet extends Applet * This is a new reference entry for Processing 2.0. It will be updated shortly. * * ( end auto-generated ) - * + * * @webref rendering:shaders * @param shader name of shader file */ @@ -10643,7 +10644,7 @@ public class PApplet extends Applet * This is a new reference entry for Processing 2.0. It will be updated shortly. * * ( end auto-generated ) - * + * * @webref rendering:shaders */ public void resetShader() { @@ -11524,9 +11525,9 @@ public class PApplet extends Applet /** - * + * * @param level either 2, 4, or 8 - */ + */ public void smooth(int level) { if (recorder != null) recorder.smooth(level); g.smooth(level); diff --git a/todo.txt b/todo.txt index 721fcc450..e5c0b1514 100644 --- a/todo.txt +++ b/todo.txt @@ -31,18 +31,23 @@ X with this specific (more esoteric) low-level case w/ a workaround 2.0 FINAL / command line +_ implement command line installer for Mac OS X +_ add processing-java.bat (or exe?) for Windows +_ add processing-java script for Linux +_ _ kill external editor (for all its quirks) in favor of command line _ use external editor needs to enable/disable across all windows _ http://code.google.com/p/processing/issues/detail?id=515 C Casey says yes kill ext editor and finish command line -_ processing.app.Commander headless still requiring X11 -_ problem is static calls to PApplet -_ http://code.google.com/p/processing/issues/detail?id=220 -_ set java.awt.headless=true -_ use as a way to remove the non-GUI-specifc code from PApplet -_ so that the builds can run headless +_ make note for docs to remove mentions of external editor +X processing.app.Commander headless still requiring X11 +X problem is static calls to PApplet +X http://code.google.com/p/processing/issues/detail?id=220 +X set -Djava.awt.headless=true +X use as a way to remove the non-GUI-specifc code from PApplet +X so that the builds can run headless X could move to java6 and better internal javac support (drop ecj) -_ decided to use Java 6, so check on Javac usefulness +o decided to use Java 6, so check on Javac usefulness _ change command line to just be part of regular (separate) distros _ there's so much platform code in there, it's not worth the extra work _ also include update check for logging