[Laszlo-checkins] r11831 - in openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo: compiler sc
hqm@openlaszlo.org
hqm at openlaszlo.org
Wed Nov 19 13:51:16 PST 2008
Author: hqm
Date: 2008-11-19 13:51:13 -0800 (Wed, 19 Nov 2008)
New Revision: 11831
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
Log:
Change 20081119-hqm-q by hqm at badtzmaru.home on 2008-11-19 16:23:53 EST
in /Users/hqm/openlaszlo/trunk4
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: more fixes for swf9 <import>
New Features:
Bugs Fixed:
Technical Reviewer: dda
QA Reviewer: ptw
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
+ In order prevent the LFC from getting compiled into each loadable
library, I added the the compiler directive -external-library-path to
exclude it. I needed to then explicitly include a base application
class so that the file would compile into a real application swf. I
couldn't figure out how to get my LzBaseLoadableLib class to be
included from the LFC after I had excluded the whole library, so I
just made the SWF9Writer emit a little base class which extends Sprite
for the library.
I was never able to make the Flash "runtime shared library" feature
work for the LFC, I need to figure out why that is. But we don't need
it right now, because the LFC isn't getting copied into each loadable
library anymore.
Tests:
test/snippets/import-class.lzx
test/snippets/import-resource.lzx
generated library .swf files are nice and small now, they don't have the LFC in them
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java 2008-11-19 21:32:42 UTC (rev 11830)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java 2008-11-19 21:51:13 UTC (rev 11831)
@@ -68,6 +68,15 @@
"," + trimwhitespace+");\n");
// For swf9, make sure the global variable is referenced or the
// Flash class loader won't load it.
+ //
+ // TODO [hqm 2008-11] Note, we could also accomplish this by
+ // adding an explicit "-include dsetname" in the command line
+ // options to the flex compiler when we compile the library, to
+ // force it to link in this global var class, but it is simpler
+ // to just make a reference to it in the code here, and doesn't
+ // cost anything. I suppose some day the flex compiler may
+ // optimize out this useless statement, and then this hack would
+ // stop working.
mEnv.compileScript(dsetname+" == true;");
} catch (org.openlaszlo.xml.internal.MissingAttributeException err) {
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java 2008-11-19 21:32:42 UTC (rev 11830)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java 2008-11-19 21:51:13 UTC (rev 11831)
@@ -457,18 +457,27 @@
*/
public String makeLibraryPreamble() {
String source = "public class " + LIBRARY_CLASSNAME +
- " extends LzBaseLoadableLib {\n " + imports + "\n" +
+ " extends LzBaseLib {\n " + imports + "\n" +
"}\n";
+
return source;
}
public void closeSnippet() throws IOException {
+
+ // Define the base app class for an import library. Must be
+ // structured this way to conform to what the swf9 script
+ // compiler expects for constructing the main app class.
+ addScript("class LzBaseLib extends Sprite { \n" +
+ imports + "\n" +
+ "public function runToplevelDefinitions() {}\n" +
+ "public function exportClassDefs(link:Object) {\n" +
+ "this.runToplevelDefinitions();\n" +
+ "}\n" +
+ "}\n");
+
// Callback to let library know we're done loading
//
- // TODO [hqm 2008-11] This won't work, right? We want to call
- // this static method on the LzLibrary class, but LzLibrary is
- // in the main app's namespace. Do we need to pass in a
- // pointer back to the main app's LzLibrary class? Should this be in exportClassDefs?
addScript("LzLibrary.__LZsnippetLoaded('"+this.liburl+"')");
if (mCloseCalled) {
@@ -480,6 +489,7 @@
props.setProperty(org.openlaszlo.sc.Compiler.SWF9_APPLICATION_PREAMBLE, makeLibraryPreamble());
props.put(org.openlaszlo.sc.Compiler.SWF9_APP_CLASSNAME, LIBRARY_CLASSNAME);
props.put(org.openlaszlo.sc.Compiler.SWF9_WRAPPER_CLASSNAME, LIBRARY_CLASSNAME);
+ props.put(org.openlaszlo.sc.Compiler.SWF9_LOADABLE_LIB, "true");
/*
System.err.println(org.openlaszlo.sc.Compiler.SWF9_APPLICATION_PREAMBLE + "="+props.get( org.openlaszlo.sc.Compiler.SWF9_APPLICATION_PREAMBLE));
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2008-11-19 21:32:42 UTC (rev 11830)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2008-11-19 21:51:13 UTC (rev 11831)
@@ -495,6 +495,7 @@
public static String SWF9_WRAPPER_CLASSNAME = "SWF9WrapperClassName";
public static String SWF9_LFC_CLASSNAME = "SWF9LFCClassName";
public static String SWF9_LOADABLE_LIB = "SWF9LoadableLib";
+ public static String SWF9_USE_RUNTIME_SHARED_LIB = "SWF9RuntimeSharedLib";
public static String SWF8_LOADABLE_LIB = "SWF8LoadableLib";
public static String TRACK_LINES = "trackLines";
public static String VALIDATE_CACHES = "validateCaches";
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java 2008-11-19 21:32:42 UTC (rev 11830)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java 2008-11-19 21:51:13 UTC (rev 11831)
@@ -816,6 +816,14 @@
return LPS.getLFCDirectory() + File.separator + "LFC9" + dbgext + ".swc";
}
+ /**
+ * Get the relative URL of the LFC shared library for SWF9.
+ */
+ public static String getLFCLibraryRelativeURL(boolean useDebug) {
+ String dbgext = useDebug ? "-debug" : "";
+ return "LFC9" + dbgext + ".swf";
+ }
+
public static boolean isWindows() {
String osname = System.getProperty("os.name");
assert osname != null;
@@ -831,6 +839,8 @@
List cmd = new ArrayList();
String outfilebase;
String exeSuffix = isWindows() ? ".exe" : "";
+
+ boolean debug = options.getBoolean(Compiler.DEBUG_SWF9);
// NB: this code used to call execCompileCommand, and pass in the pathname of
// a shell script to invoke the flex compiler. It now calls callJavaCompileCommand
@@ -872,7 +882,7 @@
for (int i=1; i<=maxSubdirnum; i++) {
cmd.add("-compiler.source-path+=" + workdir.getPath() + File.separator + i);
}
- if (options.getBoolean(Compiler.DEBUG_SWF9)) {
+ if (debug) {
cmd.add("-debug=true");
}
cmd.add("-compiler.headless-server=true");
@@ -885,8 +895,26 @@
cmd.add("-default-size");
cmd.add(options.get(Compiler.CANVAS_WIDTH, "800"));
cmd.add(options.get(Compiler.CANVAS_HEIGHT, "600"));
- cmd.add("-compiler.library-path+=" + getLFCLibrary(options.getBoolean(Compiler.DEBUG_SWF9)));
+ if (options.getBoolean(Compiler.SWF9_USE_RUNTIME_SHARED_LIB)) { //
+ // TODO [hqm 2008-11] This usage of the Flash
+ // "runtime-shared-library" feature does not work yet. No matter
+ // what I try, when the app loads, it cannot find or load the
+ // LFC as a runtime shared library. When this does work, it
+ // will be a good option to reduce app download size when
+ // multiple Laszlo apps are served from the same server.
+ cmd.add("-runtime-shared-library-path="+ getLFCLibrary(debug) + "," +
+ "lib" + File.separator + getLFCLibraryRelativeURL(debug) +
+ ",," // specifies explicitly empty policy file arg
+ );
+ } else {
+ cmd.add("-compiler.library-path+=" + getLFCLibrary(debug));
+ }
+ if (options.getBoolean(Compiler.SWF9_LOADABLE_LIB)) {
+ // Exclude the LFC
+ cmd.add("-external-library-path+="+getLFCLibrary(debug));
+ }
+
// Add in WEB-INF/flexlib and APPDIR/flexlib to flex library search paths if they exist
if ((new File(getFlexPathname("flexlib"))).isDirectory()) {
cmd.add("-compiler.library-path+=" + getFlexPathname("flexlib"));
More information about the Laszlo-checkins
mailing list