We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
command-line? (Read 2850 times)
command-line?
Apr 23rd, 2005, 7:32pm
 
Hey,

I love Processing - I discovered it 3 days ago and now it's making me
re-write all my DOS graphics programs from 10 years ago. Check out
http://gweb.org/computers (click on the pictures).

QUESTION: Can you command-line compile a pde file? I'm using the linux
version on a remote webhost, and I'd like to directly compile things
there.

Thanks!

Geoff
Re: command-line?
Reply #1 - Apr 24th, 2005, 2:08am
 
Well, if you use Java and just include the processing core library in your classpath, you can compile with javac.

This site might help you out.

Marcello
Re: command-line?
Reply #2 - Apr 24th, 2005, 6:19am
 
right, if you wanted to just use the core libraries, you can just include the file from lib/core.jar with your project and compile away.

if you wanted to use a regular .pde file, and run it through the preprocessor, you'd need to hack around with the source code for the environment a bit.
Re: command-line?
Reply #3 - Apr 25th, 2005, 2:43am
 
what happens when you try to compile a sketch that uses opengl?

besides including:
lib/core.jar

I've included:
libraries/jogl.jar
libraries/opengl.jar

but I still get:

Code:

java.lang.RuntimeException: Before using OpenGL, you must first select Import Library > opengl from the Sketch menu.
at processing.core.PApplet.size(PApplet.java:753)


am I missing any library?
I've tried doing:

import processing.opengl.*;
but doesn't seem to like it.

update
since a little bit OT for this thread I moved it here
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1114400513
Re: command-line?
Reply #4 - Apr 25th, 2005, 4:11am
 
Yes, to clarify, I want to command-line compile PDE files. Compiling the generated java files is, of course, easy. But compiling the PDE files requires some trickery, huh? Any hints or leads on directly generating PDE files from the command line?

-G
Re: command-line?
Reply #5 - Apr 25th, 2005, 6:00am
 
as i said, you'd need to hack around in the code. it wasn't really built for it so it'd take a bit of work to make it happen.

the basics are that you'd be removing dependencies on the Runner and Editor classes (inside processing/app) and get Sketch, Compiler, and Preprocessor to essentially work on their own.

there might be a clever way of just breaking out the preprocessor by itself, since it's less closely tied to the other things, but it'd still require a little hacking.
Re: command-line?
Reply #6 - Jul 9th, 2005, 4:50pm
 
I tried to make the processing.app.preproc.PdePreprocessor class work on its own, as it seems that's the one actually generating a proper java source from a PDE file content.

I wrote the following simple piece of code:


import java.io.*;

import processing.app.preproc.PdePreprocessor;

public class Pde2Java
{
   public static void
   main(String args[])                                 throws Exception
   {
       if (args.length != 1) {
           return;
       }

       String  programName          = args[0];
       String  buildPath            = "/tmp/build";
       String  name                 = "name";
       String  codeFolderPackages[] = null;

       BufferedReader reader = new BufferedReader(new FileReader(programName));
       StringWriter   program = new StringWriter();
       BufferedWriter writer  = new BufferedWriter(program);
       String         line;

       while ((line = reader.readLine()) != null) {
           writer.write(line);
           writer.newLine();
       }
       writer.flush();

       PdePreprocessor pp = new PdePreprocessor();

       String  ret;

       ret = pp.write(program.toString(), buildPath, name, codeFolderPackages);
       System.out.println("ret: " + ret);
   }
}



now the problem is, that if I try a simple sample with it, like the Directional sample from among the processing examples:

// Directional
// by REAS <http://reas.com>

// Move the mouse the change the direction of the light.
// Directional light comes from one direction and is stronger
// when hitting a surface squarely and weaker if it hits at a
// a gentle angle. After hitting a surface, a directional lights
// scatters in all directions.

// Created 28 April 2005


void setup()
{
 size(200, 200, P3D);
 noStroke();
 fill(204);
}

void draw()
{
 noStroke();
 background(0);
 float dirY = (mouseY/float(height) - 0.5) * 2.0;
 float dirX = (mouseX/float(width) - 0.5) * 2.0;
 directionalLight(204, 204, 204, -dirX, -dirY, -1);
 translate(20, height/2, 0);
 sphere(60);
 translate(120, 0, 0);
 sphere(60);
}


I get the following error:


Exception in thread "main" line 24:3: unexpected token: float
       at processing.app.preproc.PdeRecognizer.primaryExpression(PdeRecognizer.java:1100)
       at processing.app.preproc.PdeRecognizer.postfixExpression(PdeRecognizer.java:3765)
       at processing.app.preproc.PdeRecognizer.unaryExpressionNotPlusMinus(PdeRecognizer.j
ava:3730)
       at processing.app.preproc.PdeRecognizer.unaryExpression(PdeRecognizer.java:3640)
       at processing.app.preproc.PdeRecognizer.multiplicativeExpression(PdeRecognizer.java
:3548)
       at processing.app.preproc.PdeRecognizer.additiveExpression(PdeRecognizer.java:3505)

       at processing.app.preproc.PdeRecognizer.shiftExpression(PdeRecognizer.java:3456)
       at processing.app.preproc.PdeRecognizer.relationalExpression(PdeRecognizer.java:338
5)
       at processing.app.preproc.PdeRecognizer.equalityExpression(PdeRecognizer.java:3342)

       at processing.app.preproc.PdeRecognizer.andExpression(PdeRecognizer.java:3313)
       at processing.app.preproc.PdeRecognizer.exclusiveOrExpression(PdeRecognizer.java:32
84)
       at processing.app.preproc.PdeRecognizer.inclusiveOrExpression(PdeRecognizer.java:32
55)
       at processing.app.preproc.PdeRecognizer.logicalAndExpression(PdeRecognizer.java:322
6)
       at processing.app.preproc.PdeRecognizer.logicalOrExpression(PdeRecognizer.java:3197
)
       at processing.app.preproc.PdeRecognizer.conditionalExpression(PdeRecognizer.java:31
66)
       at processing.app.preproc.PdeRecognizer.assignmentExpression(PdeRecognizer.java:125
0)
       at processing.app.preproc.PdeRecognizer.expression(PdeRecognizer.java:854)
       at processing.app.preproc.PdeRecognizer.statement(PdeRecognizer.java:571)
       at processing.app.preproc.PdeRecognizer.compoundStatement(PdeRecognizer.java:2683)
       at processing.app.preproc.PdeRecognizer.field(PdeRecognizer.java:1795)
       at processing.app.preproc.PdeRecognizer.possiblyEmptyField(PdeRecognizer.java:175)
       at processing.app.preproc.PdeRecognizer.activeProgram(PdeRecognizer.java:207)
       at processing.app.preproc.PdeRecognizer.pdeProgram(PdeRecognizer.java:132)
       at processing.app.preproc.PdePreprocessor.write(PdePreprocessor.java:254)
       at Pde2Java.main(Unknown Source)


also trying with other PDE inputs, basically it will fail on the first encounter of a primitive type, such as float, int, etc. I wonder why the if() statement at line 1010 in PdeRecognizer.java doesn't recognize the primitive type:

       }
       else if ((LA(1)==NUM_INT||LA(1)==CHAR_LITERAL||LA(1)==STRING_LITERAL||LA(1)==NUM_FLOAT||
LA(1)==NUM_LONG||LA(1)==NUM_DOUBLE||LA(1)==WEBCOLOR_LITERAL)) {



I checked that when running processing 'normally', PdePreprocessor.write() gets the exact same input. so the only different can be is the context it runs in: maybe some global variables are changed when running inside the Editor?


BTW, I looked at the Sketch and some other classes, especially Preferences. It seems that by quite bad design, all rely on the Editor, which is a GUI after all. Like one can't even load Preferences without referring to the Editor class.
Page Index Toggle Pages: 1