You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2013/01/25 15:11:39 UTC

svn commit: r1438526 - in /flex/asjs/branches/develop/publisher: README build.properties build.xml index.html.template

Author: erikdebruin
Date: Fri Jan 25 14:11:38 2013
New Revision: 1438526

URL: http://svn.apache.org/viewvc?rev=1438526&view=rev
Log:
- updated ASJS Publisher to work with the Flex SDK on the AS side and VanillaSDK on the JS side
- updated the README to reflect current information

Modified:
    flex/asjs/branches/develop/publisher/README
    flex/asjs/branches/develop/publisher/build.properties
    flex/asjs/branches/develop/publisher/build.xml
    flex/asjs/branches/develop/publisher/index.html.template

Modified: flex/asjs/branches/develop/publisher/README
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/publisher/README?rev=1438526&r1=1438525&r2=1438526&view=diff
==============================================================================
--- flex/asjs/branches/develop/publisher/README (original)
+++ flex/asjs/branches/develop/publisher/README Fri Jan 25 14:11:38 2013
@@ -2,17 +2,13 @@ ASJS Publisher
 ==============
 
     The ASJS Publisher is a tool to cross-compile projects from ActionScript (AS) 
-    to Javascript (JS). On the AS side, a project needs to be built with the
-    FlexJS AS framework (instead of the regular Flex SDK). The Publisher collects 
-    the project's AS code and uses the FalconJS compiler to create JS code. This 
-    JS code is then combined with the FlexJS JS framework using the Google Closure
-    Builder. This tool takes all the JS files, calculates dependencies and creates
-    one, highly optimized and minified, JS file: FlexJS.js. This one file is
-    combined with a minimal HTML file and together these contain all code needed 
-    to play the project in a browser.
-
-    The Publisher also contains some targets that help with developing the FlexJS
-    JS framework, like a Linter to check the correct use of coding conventions. For
+    to Javascript (JS). On the AS side, a project can to be built with the regular 
+	Flex SDK). The Publisher collects the project's AS code and uses the FalconJx 
+	compiler to create JS code. This JS code is then combined with the 
+	VanillaSDK JS framework using the Google Closure Builder. This tool takes all 
+	the JS files, calculates dependencies and creates one, highly optimized and 
+	minified, JS file. This one JS file is combined with a minimal HTML file and 
+	together these contain all code needed to play the project in a browser. For
     more information, read on.
     
 Using the Publisher
@@ -25,37 +21,27 @@ Prerequisites
         
         https://developers.google.com/closure/
     
-    In particular it uses the Library, Linter, Compiler and Builder. In order
+    In particular it uses the Library, Compiler and Builder. In order
     to use the Publisher on your machine, you'll have to download/install these
     tools first.
 
-    1)  Prepare a root directory to hold the various tools.
-    
-    2)  Get the Google Closure Library into '<root>/library'
+    1)  Get the Google Closure Library
     
             svn checkout http://closure-library.googlecode.com/svn/trunk/ library
         
-    3)  Install the Google Closure Linter into '<root>/linter'
-
-            https://developers.google.com/closure/utilities/docs/linter_howto
-
-    4)  Download the Google Closure Compiler and unzip into '<root>/compiler'
+    2)  Download the Google Closure Compiler and unzip
         
             http://closure-compiler.googlecode.com/files/compiler-latest.zip
+
+	3)  Get the Falcon compilers 
     
-    5)  Get the Google Closure Builder into '<root>/builder'
-    
-            svn checkout http://closure-library.googlecode.com/svn/trunk/closure/bin/build/ builder
-    
+    		svn checkout https://svn.apache.org/repos/asf/flex/falcon/trunk falcon
+
 Preparing for publishing
 ------------------------
 
-    1)  The ASJS Publisher uses the FalconJS compiler, which in turn needs the
-        Falcon compiler. Get Falcon from SVN:
-        
-            https://svn.apache.org/repos/asf/incubator/flex/falcon/trunk
-            
-        And build it using the README as your guide.
+    1)  The ASJS Publisher uses the FalconJx compiler, which in turn needs the
+        Falcon compiler. Build both projects using the READMEs as your guide.
     
     2)  The Publisher is an ant script, 'build.xml', which uses 
         'build.properties' and command line arguments to set dynamic properties. 
@@ -65,34 +51,12 @@ Preparing for publishing
 Publishing
 ----------
 
-    A full run ('main') of the ant script takes 2 command line arguments: 
-    path.name and path.location. Usage is:
-    
-        ant -Dapp.name=<your.app.name.here> -Dapp.location=<your.app.location.here>
+    A full run ('main') of the ant script needs a single command line argument: 
+    project.main.file. You point this argument to the 'master' AS (no MXML yet)
+	of your project, like so:
     
-    'app.name' is the name of the FlexJS AS project you want to publish. 'app.location' 
-    is the full path to the directory this project lives in. If you're working 
-    from an intermediate FlexJS JS project (see below), the second argument is
-    not needed, as that type of project lives in the 'intermediate' directory
-    in the Publisher root.
-    
-    NOTE: as of 2012-12-06, the FalconJS compiler doesn't output JS that can be 
-    parsed by the new tool set. While this is being corrected, you'll have to 
-    create your own 'intermediate' JS project, or modify one of the examples 
-    (I've included 'FlexJSTest_dummy' in the repo). Make sure to not include the 
-    'falconJS' dependency (?) in the build.xml and if you don't want to loose 
-    your work, set CLEAN_INTERMEDIATE_JS to 'false' in build.properties.
-    
-    If you're doing work on the FlexJS JS framework, you should use 
-    
-        ant lint
-        
-    regularly, to make sure your code is formatted correctly and in perfect
-    condition to be parsed by the Google Closure Compiler.
+        ant -Dproject.main.file=../examples/VanillaSDK_POC/src/Example.as
     
 That's it, have fun!
 
 The Apache Flex Project
-    
-    <http://incubator.apache.org/flex/>
-    

Modified: flex/asjs/branches/develop/publisher/build.properties
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/publisher/build.properties?rev=1438526&r1=1438525&r2=1438526&view=diff
==============================================================================
--- flex/asjs/branches/develop/publisher/build.properties (original)
+++ flex/asjs/branches/develop/publisher/build.properties Fri Jan 25 14:11:38 2013
@@ -17,11 +17,14 @@
 ##
 ################################################################################
 
-# Clean out the previous run's intermediate files? Set false if working with a dummy set of JS intermediairies.
-CLEAN_INTERMEDIATE_JS=false
+# Location of the Google Closure Compiler
+DIR_CLOSURE_COMPILER=/Users/erik/Documents/ApacheFlex/dependencies/GoogleClosure/compiler
 
-# Location of the Google Closure Tools
-DIR_CLOSURE=/Users/erik/Documents/ApacheFlex/dependencies/GoogleClosure
+# Location of the Google Closure Library
+DIR_CLOSURE_LIBRARY=/Users/erik/Documents/ApacheFlex/dependencies/GoogleClosure/library
 
-# Location of the FalconJS mxmlc script
-FILE_FALCONJS_COMPILE_SCRIPT=/Users/erik/Documents/ApacheFlex/repo/falcon/compiler.js/bin/mxmlc
+# Location of the Vanilla SDK framework
+DIR_FRAMEWORK=/Users/erik/Documents/ApacheFlex/repo/asjs/frameworks/js/VanillaSDK
+
+# Location of the FalconJx mxmlc script
+FILE_FALCONJS_COMPILE_SCRIPT=/Users/erik/Documents/ApacheFlex/repo/falcon/compiler.jx/bin/mxmlc

Modified: flex/asjs/branches/develop/publisher/build.xml
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/publisher/build.xml?rev=1438526&r1=1438525&r2=1438526&view=diff
==============================================================================
--- flex/asjs/branches/develop/publisher/build.xml (original)
+++ flex/asjs/branches/develop/publisher/build.xml Fri Jan 25 14:11:38 2013
@@ -20,85 +20,96 @@
 <project name="asjsPublisher" default="main" basedir=".">
     <property file="${basedir}/build.properties" description="Properties for the ASJS Publisher" />
 
-    <property name="DIR_CLOSURE_LIBRARY" value="${DIR_CLOSURE}/library" />
-    <property name="FILE_CLOSURE_BUILDER" value="${DIR_CLOSURE}/builder/closurebuilder.py" />
-    <property name="FILE_CLOSURE_DEPENDENCIES" value="${DIR_CLOSURE_LIBRARY}/closure/goog/deps.js" />
-    <property name="FILE_CLOSURE_JAR" value="${DIR_CLOSURE}/compiler/compiler.jar" />
+    <basename property="PROJECT_NAME" file="${project.main.file}" suffix=".as" />
     
-    <property name="DIR_FRAMEWORK" value="${basedir}/../frameworks/js/src" />
+    <dirname property="DIR_PROJECT" file="${project.main.file}/.." />
 
-    <property name="DIR_INTERMEDIATE" value="${basedir}/intermediate" />
-    <property name="DIR_RELEASE" value="${basedir}/release" />
-
-    <property name="DIR_INTERMEDIATE_APPLICATION" value="${DIR_INTERMEDIATE}/${app.name}" />
-    <property name="DIR_RELEASE_APPLICATION" value="${DIR_RELEASE}/${app.name}" />
+    <property name="DIR_CLOSURE_THIRD_PARTY" location="${DIR_CLOSURE_LIBRARY}/third_party/closure/goog" />
+    <property name="DIR_CLOSURE_SCRIPTS" location="${DIR_CLOSURE_LIBRARY}/closure/bin/build" />
+    
+    <property name="DIR_INTERMEDIATE_APPLICATION" location="${DIR_PROJECT}/js-intermediate" />
+    <property name="DIR_RELEASE_APPLICATION" location="${DIR_PROJECT}/js-release" />
 
-    <property name="FILE_HTML_TEMPLATE" value="${basedir}/index.html.template" />
-    <property name="FILE_RELEASE" value="${DIR_RELEASE_APPLICATION}/FlexJS.js" />
+    <property name="FILE_DEPS" location="${DIR_INTERMEDIATE_APPLICATION}/deps.js" />
+    <property name="FILE_HTML_TEMPLATE" location="index.html.template" />
+    <property name="FILE_OUTPUT_MAIN" location="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.js" />
+    
+    <macrodef name="depsWriter">
+        <sequential>
+            <exec executable="python" failonerror="true" logError="true">
+                <arg value="${DIR_CLOSURE_SCRIPTS}/depswriter.py" />
+                <arg line="--root=${DIR_INTERMEDIATE_APPLICATION}" />
+                <arg line="--root_with_prefix='${DIR_INTERMEDIATE_APPLICATION}/goog goog'" />
+                <arg line="--root_with_prefix='${DIR_INTERMEDIATE_APPLICATION}/goog_thirdParty goog_thirdParty'" />
+                <arg line="--root_with_prefix='${DIR_INTERMEDIATE_APPLICATION}/VanillaSDK VanillaSDK'" />
+                <arg line="--output_file=${FILE_DEPS}" />
+            </exec>
+        </sequential>
+    </macrodef>
 
     <macrodef name="closureBuilder">
         <sequential>
             <exec executable="python" failonerror="true" logError="true">
-                <arg value="${FILE_CLOSURE_BUILDER}" />
-                <arg line="--root=${DIR_CLOSURE_LIBRARY}" />
-                <arg line="--root=${DIR_FRAMEWORK}" />
+                <arg value="${DIR_CLOSURE_SCRIPTS}/closurebuilder.py" />
+                <arg line="--compiler_jar=${DIR_CLOSURE_COMPILER}/compiler.jar" />
                 <arg line="--root=${DIR_INTERMEDIATE_APPLICATION}" />
                 <arg line="--output_mode=compiled" />
-                <arg line="--compiler_jar=${FILE_CLOSURE_JAR}" />
-                <arg line="--output_file=${FILE_RELEASE}" />
+                <arg line="--output_file=${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.js" />
                 <arg line="--compiler_flags=--compilation_level=ADVANCED_OPTIMIZATIONS" />
-                <arg line="--compiler_flags=--js=${FILE_CLOSURE_DEPENDENCIES}" />
+                <arg line="--compiler_flags=--js=${FILE_DEPS}" />
                 <arg line="--compiler_flags=--warning_level=VERBOSE" />
-                <arg line="--namespace=${app.name}" />
+                <arg line="--namespace=${PROJECT_NAME}" />
                 <arg line="--compiler_flags=--jscomp_error=checkTypes" />
             </exec>
         </sequential>
     </macrodef>
 
-    <!-- target name="main" description="Compiles framework files" depends="clean,createDirs,falconJS,closureBuilding,createHTML" / -->
-    <target name="main" description="Compiles framework files" depends="clean,createDirs,lint,closureBuilding,createHTML" />
-
-    <target name="clean" description="Clean up previous runs" depends="cleanIntermediate,cleanRelease">
-        <echo>Delete 'intermediate' and 'release' directories</echo>
-    </target>
-
-    <target name="checkDeleteIntermediate">
-        <condition property="deleteIntermediate">
-            <istrue value="${CLEAN_INTERMEDIATE_JS}" />
-        </condition>
-    </target>
-
-    <target name="cleanIntermediate" depends="checkDeleteIntermediate" if="deleteIntermediate">
-        <delete dir="${DIR_INTERMEDIATE}" />
-    </target>
-
-    <target name="cleanRelease">
-        <delete dir="${DIR_RELEASE}" />
-    </target>
-
+    <!-- target name="main" description="Compiles framework files" 
+            depends="clean,createDirs,prepareOutput,falconJx,calculateDependencies,closureBuilding,createIntermediateOutput,createReleaseOutput" / -->
+    <target name="main" description="Compiles framework files" 
+        depends="clean,createDirs,prepareOutput,falconJx,calculateDependencies,closureBuilding,createIntermediateOutput,createReleaseOutput" />
+    
     <target name="createDirs">
         <echo>Create 'intermediate' and 'release' directory structure</echo>
         <mkdir dir="${DIR_INTERMEDIATE_APPLICATION}" />
-        <mkdir dir="${DIR_INTERMEDIATE_APPLICATION}/js" />
         <mkdir dir="${DIR_RELEASE_APPLICATION}" />
     </target>
 
-    <target name="falconJS">
-        <echo>Compiling the AS project into intermediate JS</echo>
-        <copy todir="${DIR_INTERMEDIATE_APPLICATION}/as" flatten="true">
-            <fileset dir="${app.location}/${app.name}">
-                <include name="**/*.as"/>
-            </fileset>
+    <target name="prepareOutput">
+        <echo>Creating 'intermediate' and 'release' target directory requirements</echo>
+        <copy todir="${DIR_INTERMEDIATE_APPLICATION}/goog">
+            <fileset dir="${DIR_CLOSURE_LIBRARY}/closure/goog" />
+        </copy>
+        <copy todir="${DIR_INTERMEDIATE_APPLICATION}/goog_thirdParty">
+            <fileset dir="${DIR_CLOSURE_LIBRARY}/third_party/closure/goog" />
+        </copy>
+        <copy todir="${DIR_INTERMEDIATE_APPLICATION}/VanillaSDK">
+            <fileset dir="${DIR_FRAMEWORK}"/>
         </copy>
-        <exec executable="${FILE_FALCONJS_COMPILE_SCRIPT}">
-            <arg value="${DIR_INTERMEDIATE_APPLICATION}/as/${app.name}.as"/>
-            <arg value="-output"/>
-            <arg value="${DIR_INTERMEDIATE_APPLICATION}/js/${app.name}.js"/>
-        </exec>
     </target>
 
-    <target name="lint">
-        <echo>Lint-ing the FlexJS JS framework</echo>
+    <target name="falconJx">
+        <echo>Compiling the AS project into intermediate JS</echo>
+        <exec executable="${FILE_FALCONJS_COMPILE_SCRIPT}">
+            <arg value="${DIR_PROJECT}/src/${PROJECT_NAME}.as"/>
+            <arg value="-output=${FILE_OUTPUT_MAIN}"/>
+        </exec>
+        <!-- 
+            # Making sure that the main class' name doesn't get renamed 
+              during the compile, which would invalidate the call to it 
+              in the project's HTML
+        -->
+        <echo file="${FILE_OUTPUT_MAIN}" append="true">
+<![CDATA[
+// Ensures the symbol will be visible after compiler renaming.
+goog.exportSymbol('${PROJECT_NAME}', ${PROJECT_NAME});
+]]>
+        </echo>
+    </target>
+
+    <target name="calculateDependencies">
+        <echo>Calculating dependencies and writing them to 'deps.js'</echo>
+        <depsWriter />
     </target>
 
     <target name="closureBuilding">
@@ -106,9 +117,47 @@
         <closureBuilder />
     </target>
 
-    <target name="createHTML">
-        <echo>Creating playback HTML file from template</echo>
-        <copy file="${FILE_HTML_TEMPLATE}" tofile="${DIR_RELEASE_APPLICATION}/${app.name}.html" overwrite="true" />
-        <replace file="${DIR_RELEASE_APPLICATION}/${app.name}.html" token="@APPLICATION_NAME@" value="${app.name}" />
+    <target name="createIntermediateOutput">
+        <echo>Creating 'intermediate' playback project</echo>
+        <copy file="${FILE_HTML_TEMPLATE}" tofile="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.html" overwrite="true" />
+        <move  file="${DIR_INTERMEDIATE_APPLICATION}/goog/base.js" todir="${DIR_INTERMEDIATE_APPLICATION}" />
+        <replace file="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.html" token="@INTERMEDIATE_OPEN@" value="" />
+        <replace file="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.html" token="@INTERMEDIATE_CLOSE@" value="" />
+        <replace file="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.html" token="@RELEASE_OPEN@" value="!-- " />
+        <replace file="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.html" token="@RELEASE_CLOSE@" value=" --" />
+        <replace file="${DIR_INTERMEDIATE_APPLICATION}/${PROJECT_NAME}.html" token="@APPLICATION_NAME@" value="${PROJECT_NAME}" />
+    </target>
+
+    <target name="createReleaseOutput">
+        <echo>Creating 'release' playback project</echo>
+        <copy file="${FILE_HTML_TEMPLATE}" tofile="${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.html" overwrite="true" />
+        <replace file="${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.html" token="@INTERMEDIATE_OPEN@" value="!-- " />
+        <replace file="${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.html" token="@INTERMEDIATE_CLOSE@" value=" --" />
+        <replace file="${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.html" token="@RELEASE_OPEN@" value="" />
+        <replace file="${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.html" token="@RELEASE_CLOSE@" value="" />
+        <replace file="${DIR_RELEASE_APPLICATION}/${PROJECT_NAME}.html" token="@APPLICATION_NAME@" value="${PROJECT_NAME}" />
     </target>
+
+    <!--
+
+        CLEANUP
+
+    -->
+
+    <target name="clean" description="Clean up previous runs" depends="cleanIntermediate,cleanRelease">
+        <echo>Delete 'intermediate' and 'release' directories</echo>
+    </target>
+
+    <target name="cleanIntermediate">
+        <delete failonerror="false" includeemptydirs="true">
+            <fileset dir="${DIR_INTERMEDIATE_APPLICATION}" />
+		</delete>
+    </target>
+
+    <target name="cleanRelease">
+        <delete failonerror="false" includeemptydirs="true">
+            <fileset dir="${DIR_RELEASE_APPLICATION}" />
+		</delete>
+    </target>
+
 </project>

Modified: flex/asjs/branches/develop/publisher/index.html.template
URL: http://svn.apache.org/viewvc/flex/asjs/branches/develop/publisher/index.html.template?rev=1438526&r1=1438525&r2=1438526&view=diff
==============================================================================
--- flex/asjs/branches/develop/publisher/index.html.template (original)
+++ flex/asjs/branches/develop/publisher/index.html.template Fri Jan 25 14:11:38 2013
@@ -1,21 +1,18 @@
 <!DOCTYPE html>
 <html>
 <head>
-    <meta http-equiv="X-UA-Compatible" content="IE=edge" >
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 
-    <script type="text/javascript" src="./base.js"></script>
-    <!-- script type="text/javascript" src="./@APPLICATION_NAME@_deps.js"></script -->
-    <script type="text/javascript" src="./Example_deps.js"></script>
+    <@RELEASE_OPEN@script type="text/javascript" src="./@APPLICATION_NAME@.js"></script@RELEASE_CLOSE@>
+    <@INTERMEDIATE_OPEN@script type="text/javascript" src="./base.js"></script>
     <script type="text/javascript">
-        //goog.require("@APPLICATION_NAME@()");
-        goog.require("Example");
-    </script>
+        goog.require("@APPLICATION_NAME@");
+    </script@INTERMEDIATE_CLOSE@>
 </head>
 <body>
     <script type="text/javascript">
-        //new @APPLICATION_NAME@().init();
-        new Example().init();
+        new @APPLICATION_NAME@();
     </script>
 </body>
 </html>