Two very important first steps when using the OpenLaszlo command-line compiler are to
1. Set the environment variable
LPS_HOMEto the directory in which OpenLaszlo is installed or unzipped. For example, I have OpenLaszlo unzipped in
C:\openlaszlo, so I set my environment variable as
2. Place the OpenLaszlo directory with the
lzcexecutable in your path. On my Windows machine, with
LPS_HOMEset as described in step #1, I add the following to my path:
You know you have been successful with these first two steps if you can run
lzc --helpfrom your root directory and see something like the following screen snapshot (click on snapshot to see larger version).
lzc --helpexample demonstrates, these are several
lzccompiler options you can use. These are described in greater detail in Chapter 49 ("Understanding Compilation") of the OpenLaszlo Application Developer's Guide.
The command-line option you might use the most is the one that controls the supported runtime to compiler the OpenLaszlo application code to. Although the
--runtimecompiler option in the
--helpdisplay shown above indicates that
svgare possible runtimes to specify, these are actually simply reserved for future use and will instead compile to DHTML if specified. The listed runtime options that actually are currently supported are
swf7(the default if no runtime is specified),
The next screen snapshot shows how to use the command-line
lzccompiler to compile to the three primarly supported runtimes.
The commands above will lead to the generated files shown in the next screen snapshot.
As the screen snapshot above shows, the runtime environment of the compiled files is easy to determine from the name of the files.
-voption for the
lzccommand-line compiler prints out compiler progress. The output from the
-voption is highly verbose, so you'd probably want to specify a log file with that option. The next screen snapshot demonstrates the use of these two command-line options together.
Note how large this log file is. Note also the relative size of the source file (
example1.lzx). The log created from the
-voption is 4475 times larger than the source file being compiled and nearly 21 times larger than the compiled
example1.jsfile. In other words, you definitely want to specify a log file for the
There are many advantages to using OpenLaszlo's Deployer's Console or using URLs with request types (lzt) and Laszlo runtime (lzr) as URL parameters. However, there are times when the command-line compiler is advantageous (such as part of scripted builds).