Bug 219 : add command line support
Last modified: 2010-05-31 15:42




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P1
Severity:
enhancement

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-11-22 13:09
would be nice to build from the command line. this could be done reasonably
easily by including some options on the command line:
--compile, --export, --export-application
with the primary arg still being a .pde file for the sketch, since the
whole sketch folder hierarchy has to stay intact (otherwise just use javac
or whatever).

the result won't be a full removal of the need for awt, but rather will
essentially running the pde robotically to do one thing and then exit
again. full awt-free cleanliness could come with a later release.

might also consider a separate application to handle this, i.e.
processingc.exe is the cmd line version or something like that (how to
handle on macosx, for instance, since not a .app file..)
Additional Comment #1 From fjen 2007-01-22 08:44
kyle buza (http://plwclassic.media.mit.edu/people/buza/) posted a writeup on what they did
to serverside compile on opencode (http://opencode.media.mit.edu/), i repost here since
their discussion-board is members-only (i hope that's ok with him):

----- snip, http://opencode.media.mit.edu/tool/discuss/comments/4 -----

buza: Changes we've made to Processing.

Our modifications to the main processing build basically include a mechanism for
transforming Processing .pde files into Java .jar files directly. To do this, we have made the
following modifications:

1. We have created a class to hold the Processing state, that is used by our web server to
dynamically construct pages based on the Processing compilation result. We call these
objects “OpenCodeBundles”


package processing.app;

import java.util.Vector;

public class OpenCodeBundle {

public int file = -1;
public int line = -1;
public int column = -1;
public int width = 10;
public int height = 100;

public String error;
public boolean opengl = false;
public Vector attributes = new Vector();
public String dependencies;
}


2. We use these objects when we invoke the Processing parser directly. To do this, we have
modified the Base class.
Suppose we have a file “test.pde” that we would like to get transformed into a Java .jar
file. We would do the following from Java:

import processing.app.Base;

public static void main(String[] args) {
pdeFile = (String)args[0]
Base b = new Base()
b.getBundle(pdeFile)
}


This returns us the Processing result, after generating the .jar.
We have modified processing.app.Base to obtain this result:

public class Base {

public Base() { }

public OpenCodeBundle getBundle(String fileName) {
editor = null;
try {
Preferences.init();
Sketch s = new Sketch(fileName);
s.exportApplet();
return s.getBundle();
} catch(RunnerException e) {
OpenCodeBundle b = new OpenCodeBundle();
String error = e.toString();
String noException = error.substring(error.indexOf(":") + 1);
b.error = noException;
b.line = e.line;
b.column = e.column;
b.file = e.file;
return b;
} catch(Exception b) {
System.out.println(b.toString());
b.printStackTrace();
return null;
}
}


3. The above modification also requires modifications to the Sketch class as well:

public Sketch(String filename) throws IOException {
this.editor = null;
bundle = new OpenCodeBundle();
File mainFile = new File(filename);
mainFilename = mainFile.getName();
if (mainFilename.endsWith(".pde")) {
name = mainFilename.substring(0, mainFilename.length() - 4);
} else if (mainFilename.endsWith(".java")) {
name = mainFilename.substring(0, mainFilename.length() - 5);
}

tempBuildFolder = Base.getBuildFolder();
folder = new File(new File(path).getParent());
load();
}



public OpenCodeBundle getBundle() {
bundle.error = null;
return bundle;
}


That’s basically it.

----- /snip -----

although it's fairly easy to make these changes on a svn checkout for yourself, i'd love to
see a command-line included inside processing.

F
Additional Comment #2 From phaedon 2008-08-13 14:01
Would like to make another request for command-line compilation of Processing.
I am participating in a coding sprint for Sage ( http://www.sagemath.org/ )
which is an open-source project for symbolic and applied mathematics.
The managers of the Sage project are very interested in the idea of
incorporating Processing to create interesting visualizations of
mathematical functions. The graphics are spectacular. But we need to be
able to run from the command line to create an interface through Sage.

Thoughts on timing / priority?
Additional Comment #3 From fry 2008-08-27 19:38
I've spent the last week writing most of the support for it, but I haven't
finished packaging and debugging it. Should be ready for release 0149 in
the next few days.
Additional Comment #4 From fry 2008-09-20 13:50
Fixed for release 0149.
Additional Comment #5 From fry 2008-09-20 18:01
*** Bug 889 has been marked as a duplicate of this bug. ***
Additional Comment #6 From seyacat 2008-10-21 14:08
I cant use this feature on windows.
i try to run sh script on cygwin, and try with cmd and cant get results

Caused by: java.lang.ClassNotFoundException: processing.app.Commander



(In reply to comment #5)
>
>
>
> Additional Comment #5 From
> fry
> 2008-09-20 18:01
>
> <!--
> addReplyLink(5); //-->[reply]
>
>
>
>
> *** Bug 889 has been marked as a duplicate of this bug. ***
>
>
Additional Comment #7 From fry 2008-10-21 14:10
This issue has been closed, because command line support has been added. If
you've found a new bug, please file a separate report.
Additional Comment #8 From seyacat 2008-10-21 16:24
Can you be polite and say me where is this line?
Additional Comment #9 From marZ 2010-05-31 15:42
(In reply to comment #7)
>
>
>
> Additional Comment #7 From
> fry
> 2008-10-21 14:10
>
> <!--
> addReplyLink(7); //-->[reply]
>
>
>
>
>
>
> This issue has been closed, because command line support has been
added. If
> you've found a new bug, please file a separate report.
>
>

i think we need to reopen this as a lot of people been looking for it and i
doesn't work with recent releases !