In order to avoid starting JVM every time you run lzc, I developed a command line interface and a Swing version to keep the JVM alive and wait for input of new LZX file, inspired by Apache Maven console mode. The result is quite exciting:
c:\Java\OpenLaszloServer3.0.2
\Server\lps-3.0.2\test>lzc
>LzcWrapper started.
>Enter the LZX file name to compile('exit' to quit)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done( 3.084 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.631 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.59 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.531 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.52 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done( 0.511 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.501 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.541 seconds consumed)
>LzcWrapper started.
>Enter the LZX file name to compile('exit' to quit)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done( 3.084 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.631 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.59 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.531 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.52 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done( 0.511 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.501 seconds consumed)
01_empty_canvas.lzx
>compiling 01_empty_canvas.lzx. Done(0.541 seconds consumed)
Here is the source code. Feel free to test it by putting it in WEB-INF/classes and runing javac -classpath ..\lib\lps-<version>.jar <JavaFilename>
//LzcWrapper.java
import java.io.*;
public class LzcWrapper{
public static void main(String[] args) throws Exception{
System.out.println(">LzcWrapper started. \n>Enter the LZX file name to compile('exit' to quit)");
String[] param=new String[1];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(true){
param[0]=getFilename(br);
System.out.print(">compiling "+param[0]);
long mil=System.currentTimeMillis();
org.openlaszlo.compiler.Main.main(param);
double time=((double)(System.currentTimeMillis()-mil))/1000;
System.out.println(". Done("+time+" seconds consumed)");
}
}
private static String getFilename(BufferedReader br) throws IOException{
String line=br.readLine();
while(line==null||line.trim().length()==0){
line=br.readLine();
}
if(line.equals("exit")){
System.out.println(">LzcWrapper exited");
System.exit(0);
}
return line.trim();
}
}
//LzcWrapperGui.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class LzcWrapperGui{
public static void main(final String[] args) throws Exception{
if(args.length!=1){
System.out.println("please specify one LZX file.");
System.exit(0);
}
final String file=args[0];
JFrame w=new JFrame("LZX GUI Compiler");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(400,100);
w.setLocation(200,200);
Container con=w.getContentPane();
con.setLayout(new BorderLayout());
final JLabel label=new JLabel();
JButton bn=new JButton("Compile&Run "+file);
bn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
long mil=System.currentTimeMillis();
try{
org.openlaszlo.compiler.Main.main(args);
}catch(Exception e){e.printStackTrace();}
double time=((double)(System.currentTimeMillis()-mil))/1000;
label.setText("Done("+time+" seconds consumed)");
LzcWrapperGui.runSwf(file);
}
});
con.add(bn,"North");
con.add(label,"South");
w.setVisible(true);
}
static void runSwf(String lzxFile){
int pos=lzxFile.indexOf('.');
String swfFile=lzxFile.substring(0,pos)+".swf";
try{
Runtime.getRuntime().exec("Player_A1_DebugSA_10-14 "+swfFile);
}catch(Exception e){e.printStackTrace();}
}
}
______________________________
_________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user
On 11/19/05, Mika Göckel <[EMAIL PROTECTED]> wrote:
Oehm.... what about getting rid of the lzc exec call from the build file
in WEB-INF/lps/lfc and replace it with a direct call to the Class?
I changed it to
<target name="lzl" depends="chkUptoDate"
unless="${library}.notRequired" description="Build a .lzl library from
source">
<echo message="Compiling ${library}"/>
<echo message="arg: ${args} -o ${library}.lzl ${source}"/>
<java classpathref="lzcp" classname="org.openlaszlo.sc.Main">
<jvmarg value="-DLPS_HOME=${LPS_HOME}"/>
<arg line="${args} -o ${library}.lzl ${source}"/>
</java>
</target>
This avoids loading the jvm every time.
I didn't contribute the build.xml so far, because I hope that we switch
to ant-1.6.5 which will allow further improvements.
My full build.xml is attached (please be aware it's work in progress, so
it might not work out of the bix without minor fixing).
Cheers, Mika
Pablo Kang schrieb:
> You're probably taking a hit with the JVM loading every time you run lzc.
>
> pablo
>
> On Fri, 18 Nov 2005, Scott Evans wrote:
>
>> I'm in the midst of moving our build process to use lzc and produce a
>> standalone .swf file every time -- instead of doing the in-place type of
>> recompiles that you get through the OLS.
>>
>> But what I'm seeing so far is that rebuilds seem slower than they do
>> through a browser. *Something* is pegging the CPU for a while during
>> the
>> process, even if no files have changed. My source files get replaced on
>> the disk (we shuttle all our files off to a build location), but I keep
>> their timestamps, so as far as caching mechanisms go, the files should
>> look identical.
>>
>> My lzc invocation is:
>> lzc --mcache on --keepscriptcache --runtime=swf7 main.lzx
>>
>> Ideas?
>>
>>
>>
>> gse
>> _______________________________________________
>> Laszlo-user mailing list
>> [email protected]
>> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>>
> _______________________________________________
> Laszlo-user mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user
_______________________________________________ Laszlo-user mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-user
