Personal tools

How to Build

From OpenLaszlo

This page is entirely out of date. See SubversionBuildInstructions -bshine 6.11.07

Do this to build everything below:

 > ant build docs

The rest of these instructions describe how to build individual components, for faster incremental development.

Contents

Server

 > cd WEB-INF/lps/server
 > ant


Runtime Libraries

The runtime libraries are the LFC*.lzl files in WEB-INF/lps/lfc. These are built from the *.as files in that directory and its subdirectories.

There are actually five or ten LFC files (depending on the LPS version). Five of these files are used to build swf6 applications:

  • LFC6.lzl, used to build hello.lzx
  • LFC6-debug.lzl, used to build hello.lzx?debug=true, or any file with <canvas debug="true">. This contains the debugger nub.
  • LFC6-krank.lzl, and LFC5-krank-debug.lzl, used to build the (debug and non-debug) versions of applications that are then KRANKed. These contain the krank client, function metadata that is used to reconstruct the application state, and additional instructions that add metadata to objects that are created during initialization.
  • LFC6-profile.lzl, used to build applications that contain instrumentation for call profiling.

The other five are used to build swf5 applications (if you're running LPS 3.0b2).

There's an easy way to build the runtime libraries, and a (slightly) hard way. The easy way is to type 'ant build' in the WEB-INF/lps/lfc library. This builds all the versions of the library, but it takes a while.

The harder way is to run the 'buildlfc' shell script in that same directory. This starts an incremental builder, which only builds one version of the library, and does a much quicker incremental recompile when you only change a few source files. The reason it's harder is that there's a few different versions of buildlfc (debug, profile), and you have to use the one that you're testing against.

Ant task

Q. Is there a way to recompile the .as files without recompiling the entire server application?

A. There is: Use the build file in WEB-INF/lps/lfc:

 > cd WEB-INF/lps/lfc
 > ant build

This builds all five or ten LFC files (depending on the LPS version).

Incremental build

You will soon discover that 'ant build' takes a long time to recompile every file ten times after every one-line change that you make. Here's what we actually do during development:

  1. Pick a version to debug against, say swf6 debug. (It's generally easier to develop against the debug versions.)
  2. In a shell terminal window that is open to the lfc directory, invoke the 'buildlfc' command that builds that version of the LFC library --- say, 'buildlfcdebug'. It will spin for a while, and create a new build of that library, but it will stay open so that you can rebuild the library more quickly. You've already saved time because you're not building the other library versions.
  3. Open your test app with a URL that links against that version (in this case http://localhost:8080/lps-3.0b2/test.lzx?lzr=swf6&debug=true, to pick up the +debug swf6 version --- krank and profile default to off).
  4. Edit the LFC source(s).
  5. Press Enter in the 'buildlfc' terminal. This will rebuild the LFC library much faster than the first compilation.
  6. Press the browser Reload button, to relink the application and run it again.

Your edit-compile-debug cycle is (4-6), which is reasonably fast. (It's about the same speed as working on an LZX source file. You've got one more window to cycle through to rebuild the LFC library, but the monkeys here who are smarter than me use macros for this.)

The failure mode is to rebuild ONE version of the library, and link against ANOTHER. My favorite debugging technique if nothing seems to be having any effect is to introduce some change that you know will break everything, and see if it actually does.

Build with a batch file (windows)

You can also perform the incremental build with a batch file as follows. None of the Java tools (Javacc, Jython) need to be installed to do this. First, make sure you download the source distribution and the binary distribution.

  1. In the binary distribution, go to the directory %lps-home%/WEB-INF/lib. Copy the lps*.jar files (there should be two of them) into the corresponding lib directory of your source distribution.
  2. go to the %lps-home%/WEB-INF/lps/lfc directory of your source distribution. For each file starting with buildlfc, you will need to create a corresponding batch file. I will show the buildlfc batch file here; the rest can be recreated by copying the command line arguments in the respective bash file onto the last of this example batch file.
  3. create a batch file called 'buildlfc.bat' that looks like this:

set LPS_HOME=C:\downloads\rich_client\laszlo3.0b1\lps-3.0b1-src\lps-3.0b1-src\lps-3.0b1
set JAR_ROOT=..\..\lib

set CLASSPATH=%JAR_ROOT%\.
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\log4j-1.2.6.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\jdom.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\lps-3.0b1.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\commons-collections.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\activation.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\axis.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\batik-svggen.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\commons-discovery.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\commons-httpclient-2.0-rc1.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\commons-jexl-1.0-dev.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\commons-logging.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\ftp.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\iso-relax.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\jakarta-regexp-1.2.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\jaxrpc.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\jing.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\jython.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\saaj.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\saxon-6.5.3-lz-p1.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\swflib.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\wsdl4j.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\xmlrpx-1.2-b1.jar
set CLASSPATH=%CLASSPATH%;%JAR_ROOT%\xpp3-1.1.3.4d_b4.jar

java -DLPS_HOME=%LPS_HOME% -classpath %CLASSPATH% org.openlaszlo.sc.Main --incremental --runtime=swf6 -o LFC6.lzl --default LaszloLibrary.as


You need to change the LPS_HOME variable to your lps home. You could probably clean this up by putting the environment variable stuff in a seperate batch file and calling that. Also, probably not all of these jars need to be referenced, but its better to be safe than annoyed. 4. Open a DOS command prompt in your lfc directory, and type 'buildlfc' (without the quotes). You should see the build happening. For the debug build, create a file called 'buildlfcdebug.bat', and copy the contents of the above batch file into it. Substitute the following for the last line:


java -DLPS_HOME=%LPS_HOME% -classpath %CLASSPATH% org.openlaszlo.sc.Main --option nameFunctions -D$debug=true --incremental --runtime=swf6 -o LFC6-debug.lzl --default LaszloLibrary.as


Follow a similar process for creating the other build versions.

Installing the Libraries

Once a library has been built, it will automatically be picked up the next time you compile an application. You don't need to restart the server.

Schema

This creates the RELAX NG (lzx.rng) file from the RELAX NG CC (lzx.rnc) source file.

 > cd WEB-INF/lps/schema
 > ant

You need to restart the server to start using the new schema file.

Documentation

'ant doc' in the lps directory builds the documentation. You can also do this:

 > cd docs/src
 > ant