Author: dda
Date: 2008-01-04 12:58:33 -0800 (Fri, 04 Jan 2008)
New Revision: 7730
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
Log:
Change 20080104-dda-o by [EMAIL PROTECTED] on 2008-01-04 15:01:54 EST
in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
for http://svn.openlaszlo.org/openlaszlo/branches/devildog
Summary: SWF9: Added buildSharedLibrary option
New Features: none
Bugs Fixed: LPP-5234
Technical Reviewer: ptw (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: (pending)
Documentation: none
Release Notes: none
Details:
- Added --option buildSharedLibrary option, which does the compile step, but
not the final (application) link step for SWF9. This lets us build LFC9.lzl
As part of the compile step for the shared library, we do not include
the reference to the shared library (which is normally part of the compile
step).
- As before, with buildSharedLibrary option is NOT set, the application 'top
level'
code is put into DefaultApplication, which inherits from LzApplication.
Now, with buildSharedLirary set to true, any 'top level' code is put
into the LzApplication class, which does not extend anything.
This should allow us to build a complete system, including creating
appliations,
without our current (handbuilt) bootstrap LFC9.swc.
- Perhaps in the future we'll rename LzAppliation to be LfcApplication or
something else,
I left a TODO in for that.
- Some small rearrangement of static final variables to be more sensible.
Tests:
To test, made the following addition to WEB-INF/lps/lfc:
if [ "$runtime" == "dhtml" ]; then
suffix="js"
fi
+if [ "$runtime" == "swf9" ]; then
+ options="${options} --option buildSharedLibrary=true"
+fi
ant -Dlfc.output=${output:-LFC${runtime#swf}.${suffix:-"lzl"}}
-Dlfc.runtime=${runtime} -Dlfc.source=LaszloLibrary.lzs \
-Dlfc.options="${options}" lfc
Then, when running buildlfc --runtime=swf9, this produces a LFC9.lzl .
This change to buildlfc is not included with this review because it isn't quite
right-
I expect the knowledge of how to build a SWF9 lfc should be in build.xml.
Also, the output file is LFC9.lzl by default - in order for it to be useful to
link
applications, it needs to be named with .swc extension. The link step
is expecting the name 'LFC9.swc'
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
===================================================================
---
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
2008-01-04 20:56:39 UTC (rev 7729)
+++
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
2008-01-04 20:58:33 UTC (rev 7730)
@@ -394,6 +394,7 @@
// TODO [2004-03-11 ptw] share with CompilationEnvironment.java
public static String ACTIVATION_OBJECT = "createActivationObject";
+ public static String BUILD_SHARED_LIBRARY = "buildSharedLibrary";
public static String COMPUTE_METAREFERENCES = "computeMetaReferences";
public static String CONDITIONAL_COMPILATION = "conditionalCompilation";
public static String ALLOW_ROOT = "allowRoot";
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
===================================================================
---
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
2008-01-04 20:56:39 UTC (rev 7729)
+++
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
2008-01-04 20:58:33 UTC (rev 7730)
@@ -46,6 +46,13 @@
*/
public static final boolean USE_COMPILER_DEBUG_FLAG = true;
+ /* The user 'main' class is DefaultApplication which extends LfcApplication
*/
+ public final static String DEFAULT_APP_CLASSNAME = "DefaultApplication";
+
+ // TODO: [2008-1-4 dda] make this LfcApplication when we remove our
+ // bootstrapping toy-lfc library.
+ public final static String DEFAULT_LIB_CLASSNAME = "LzApplication";
+
/**
* Saved program node, to show during debugging
*/
@@ -219,6 +226,19 @@
}
}
+ // Get the bytes in a file
+ public byte[] getBytes(String filename)
+ throws IOException
+ {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(filename);
+ return getBytes(fis);
+ }
+ finally {
+ closeit(fis);
+ }
+ }
public byte[] getBytes(InputStream is)
throws IOException
@@ -646,7 +666,8 @@
public byte[] flexCompile(List tunits, String tempdir, String apptype)
throws IOException
{
- assert (apptype != null) : "application class type never set";
+ boolean buildSharedLibrary =
options.getBoolean(Compiler.BUILD_SHARED_LIBRARY);
+ assert (apptype != null && !buildSharedLibrary) : "application class type
never set";
String outfilebase = "app.swf";
String outfilename = tempdir + File.separator + outfilebase;
@@ -660,7 +681,8 @@
if (!swf9Warnings)
cmd += " -compiler.show-actionscript-warnings=false";
cmd += " -compiler.source-path+=.";
- cmd += " -library-path+=" + getLFCLibrary();
+ if (!buildSharedLibrary)
+ cmd += " -library-path+=" + getLFCLibrary();
if (USE_COMPILER_DEBUG_FLAG)
cmd += " -debug=true";
cmd += " -output " + swcfilebase;
@@ -671,6 +693,10 @@
execCompileCommand(cmd, tempdir, tunits, swcfilename);
+ if (buildSharedLibrary) {
+ return getBytes(swcfilename);
+ }
+
TranslationUnit stubtunit = new TranslationUnit();
stubtunit.setName("_stubapp");
stubtunit.addText(" import flash.display.Sprite\n" +
@@ -695,15 +721,7 @@
// empty list of translation units, so no error line number translation
execCompileCommand(cmd, tempdir, new ArrayList(), outfilename);
-
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(outfilename);
- return getBytes(fis);
- }
- finally {
- closeit(fis);
- }
+ return getBytes(outfilename);
}
public List makeTranslationUnits(SimpleNode translatedNode, boolean
compress, boolean obfuscate)
@@ -812,6 +830,7 @@
String tempdir = getCompilationTempDir().getPath();
boolean hasErrors = false;
String apptype = null;
+ boolean buildSharedLibrary =
options.getBoolean(Compiler.BUILD_SHARED_LIBRARY);
if (DEBUG_OUTPUT) {
emitFile(tempdir + File.separator + "source.txt", savedSource);
@@ -822,25 +841,33 @@
for (Iterator iter = tunits.iterator(); iter.hasNext(); ) {
TranslationUnit tunit = (TranslationUnit)iter.next();
- String name = tunit.getName();
-
String preamble = DEFAULT_FILE_PREAMBLE;
String epilog = DEFAULT_FILE_EPILOG;
if (tunit.isDefaultTranslationUnit()) {
- apptype = name;
- preamble += "public class " + name +
- " extends " + TranslationUnit.DEFAULT_APP_EXTENDS_CLASSNAME +
- " {\n";
- preamble += " function _lzAppInit () {\n";
- preamble += " lzApplicationInstance = this;\n";
- preamble += " return 0;\n";
- preamble += " }\n";
- preamble += " var _lzAppInitIgnored = _lzAppInit();\n";
+ if (buildSharedLibrary) {
+ String name = DEFAULT_LIB_CLASSNAME;
+ tunit.setName(name);
+ preamble += "public class " + name + " {\n";
+ epilog = "\n}" + epilog;
+ }
+ else {
+ String name = DEFAULT_APP_CLASSNAME;
+ apptype = name;
+ tunit.setName(name);
+ preamble += "public class " + name +
+ " extends " + DEFAULT_LIB_CLASSNAME +
+ " {\n";
+ preamble += " function _lzAppInit () {\n";
+ preamble += " lzApplicationInstance = this;\n";
+ preamble += " return 0;\n";
+ preamble += " }\n";
+ preamble += " var _lzAppInitIgnored = _lzAppInit();\n";
- epilog = "\n}" + epilog;
+ epilog = "\n}" + epilog;
- addGlobalVar("lzApplicationInstance", name, null);
+ addGlobalVar("lzApplicationInstance", name, null);
+ }
}
writeOutputFile(tunit, preamble, epilog);
}
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
===================================================================
---
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
2008-01-04 20:56:39 UTC (rev 7729)
+++
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
2008-01-04 20:58:33 UTC (rev 7730)
@@ -18,9 +18,6 @@
public class TranslationUnit
{
- public final static String DEFAULT_APP_CLASSNAME = "DefaultApplication";
- public final static String DEFAULT_APP_EXTENDS_CLASSNAME = "LzApplication";
-
private String name; // name of class
private StringBuffer contents = new StringBuffer();
private SortedMap lnums = new TreeMap();
@@ -38,10 +35,7 @@
}
public TranslationUnit(boolean isDefaultTranslationUnit) {
- if (isDefaultTranslationUnit) {
- this.name = DEFAULT_APP_CLASSNAME;
- this.isDefault = true;
- }
+ this.isDefault = isDefaultTranslationUnit;
}
public void setName(String name) {
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins