OpenLaszlo Developer Hints
From OpenLaszlo
I often find myself making experimental changes to the LFC (Laszlo Foundation Classes) which are included with each application. This page describes how the LFC and other includes are built.
First, set up your OpenLaszlo build environment. See http://wiki.openlaszlo.org/SubversionBuildInstructions for details.
Contents |
LFC overview
All LFC source files are found in WEB-INF/lps/lfc/. Once compiled for the various runtimes, the LFC binary files are found in lps/includes/lfc/, for example, lps/includes/lfc/LFCdhtml.js.
All the default base classes for OpenLaszlo can be found here. There are several file types:
.lzs: Javascript with OpenLaszlo compiler extensions, for example, to include files see #include "compiler/Library.lzs" in LaszloLibrary.lzs. Used for portions of the LFC that aren't runtime specific, for example, everything not in kernel/*.
.js: JavaScript. Used for HTML5-specific code, for example, kernel/dhtml/*.
.as: Actionscript. Used for Flash-specific code, for example, kernel/swf9/*.
The compiler treats all files the same way. We use .as and .js to designate code that uses runtime-specific features. If you find a bug that only happens in a specific runtime, see the appropriate kernel directory. If the bug happens across runtimes, check outside the kernel directory.
Rebuilding the LFC
Once the LFC is rebuilt, you can refresh your application and see the changes immediately. There's no need to restart the OpenLaszlo server but be sure to clear your browser cache.
Before rebuilding the LFC, cd to WEB-INF/lps/lfc/. Use ant build to rebuild all versions of the LFC and ant clean to force a clean build.
To rebuild the LFC for a specific runtime, you use one of the buildlfc commands found in WEB-INF/lps/lfc/, either buildlfc, buildlfcdebug, buildlfcprofile or buildlfcbacktrace.
Example LFC Build
For example, to rebuild the non-debug HTML5 LFC, type:
$ cd WEB-INF/lps/lfc/
$ ./buildlfc --runtime=dhtml
Buildfile: /Users/maxcarlson/openlaszlo/trunk-clean/WEB-INF/lps/lfc/build.xml
[echo] build.url is ${build.url}
[echo] dont-need-svn-info is ${dont-need-svn-info}
get-env:
get-svn-info:
read-svn-info:
build-version-info:
[echo] version.id computed from /Users/maxcarlson/openlaszlo/trunk-clean/versions.xml as 5.0.x
[echo] release computed from /Users/maxcarlson/openlaszlo/trunk-clean/versions.xml as Latest
build-opt:
init:
lfc:
[echo] build.url is http://svn.openlaszlo.org/openlaszlo/trunk
[echo] dont-need-svn-info is true
get-env:
get-svn-info:
read-svn-info:
build-version-info:
build-opt:
init:
lzl:
[echo] Compiling /Users/maxcarlson/openlaszlo/trunk-clean/lps/includes/lfc/LFCdhtml.js
BUILD SUCCESSFUL
Total time: 6 seconds
Shortcuts to rebuild the LFC
Here's a list of aliases I use to rebuild common LFC variants, straight from my ~/.profile:
alias bd='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfc --runtime=dhtml; popd;' alias bdd='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfcdebug --runtime=dhtml; popd;' alias bdp='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfcprofile --runtime=dhtml; popd;' alias bdb='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfcbacktrace --runtime=dhtml; popd;' alias bs='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfc --runtime=swf10; popd;' alias bsd='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfcdebug --runtime=swf10; popd;' alias bsb='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfcbacktrace --runtime=swf10; popd;' alias bsp='pushd $LPS_HOME/WEB-INF/lps/lfc/; ./buildlfcprofile --runtime=swf10; popd;'
These are nice because you can run them from any directory without losing your place.
HTML Javascript Includes
Besides the LFC, there are Javascript includes that are used to embed applications in HTML, for example, lps/includes/embednew.js. The source for these files can be found in lps/includes/source/. Use ant build to rebuild any changes and ant clean to force a clean build.
Like the LFC, once the includes are rebuilt, you can refresh your application and see the changes immediately. There's no need to restart the OpenLaszlo server but be sure to clear your browser cache.
Example Javascript include build
$ cd lps/includes/source/
$ ant build
Buildfile: /Users/maxcarlson/openlaszlo/trunk-clean/lps/includes/source/build.xml
[echo] build.url is ${build.url}
[echo] dont-need-svn-info is ${dont-need-svn-info}
get-env:
get-svn-info:
read-svn-info:
build-version-info:
[echo] version.id computed from /Users/maxcarlson/openlaszlo/trunk-clean/versions.xml as 5.0.x
[echo] release computed from /Users/maxcarlson/openlaszlo/trunk-clean/versions.xml as Latest
build-opt:
init:
embed:
[echo] build.url is http://svn.openlaszlo.org/openlaszlo/trunk
[echo] dont-need-svn-info is true
get-env:
get-svn-info:
read-svn-info:
build-version-info:
build-opt:
init:
compress:
[echo] Compiling ../embed-compressed.js
...
BUILD SUCCESSFUL
Total time: 14 seconds
Shortcuts to rebuild the LFC
Here's the alias I use to rebuild my Javascript includes:
alias ci='pushd $LPS_HOME/lps/includes/source;ant; popd;'

