Changeset 7304

Show
Ignore:
Timestamp:
02/13/07 17:36:18 (22 months ago)
Author:
jburke
Message:

(merge from 0.4 branch) References #2366. Got a working comment stripping. Adjusted web build shell script to use comment stripping.

Location:
trunk/buildscripts
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/buildscripts/build.xml

    r7205 r7304  
    481481        <!-- end gen-strip-docs task --> 
    482482 
     483        <!-- strip-resource-comments --> 
     484                <target name="strip-resource-comments"> 
     485                <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true"  
     486                                logerror="true"> 
     487                        <arg value="stripComments.js" /> 
     488                        <arg value="${release_dir}"/> 
     489                </java> 
     490        </target> 
     491        <!-- end strip-resource-comments --> 
     492 
    483493        <!-- src task --> 
    484494        <target name="src" 
  • trunk/buildscripts/buildUtil.js

    r7285 r7304  
    860860                        //Don't process dojo.js since it has already been processed. 
    861861                        //Don't process dojo.js.uncompressed.js because it is huge. 
    862                         if(!fileList[i].match(/dojo\.js$/) && !fileList[i].match(/dojo\.js\.uncompressed\.js$/)){ 
     862                        //Don't process anything that might be in a buildscripts folder (only a concern for webbuild.sh) 
     863                        if(!fileList[i].match(/dojo\.js$/) 
     864                                && !fileList[i].match(/dojo\.js\.uncompressed\.js$/) 
     865                                && !fileList[i].match(/buildscripts/)){ 
    863866                                print("Stripping comments from file: " + fileList[i]); 
    864867                                 
     
    870873                                 
    871874                                //Get rid of cr, lf, since it messes up matching. 
    872                                 fileContents = fileContents.replace(/\r/g, "__DOJOCARRIAGERETURN__").replace(/\n/g, "__DOJONEWLINE__"); 
    873                                 var multiLineMatches = fileContents.match(/\/\*.*?copyright.*?\*\//gi); 
     875                                copyrightFileContents = fileContents.replace(/\r/g, "__DOJOCARRIAGERETURN__").replace(/\n/g, "__DOJONEWLINE__"); 
     876                                var multiLineMatches = copyrightFileContents.match(/\/\*.*?copyright.*?\*\//gi); 
    874877 
    875878                                //Finalize copyright notice. 
     
    887890 
    888891                                //Remove whitespace. 
    889                                 var commandResults = buildUtil.runCommand("java -jar lib/custom_rhinoPrettyPrint.jar -strict -opt -1 -p " + fileList[i]); 
     892                                var context = Packages.org.mozilla.javascript.Context.enter(); 
     893                                try{ 
     894                                        // Use the interpreter for interactive input (copied this from Main rhino class). 
     895                                        context.setOptimizationLevel(-1); 
     896                                         
     897                                        var script = context.compileString(fileContents, fileList[i], 1, null); 
     898                                        fileContents = new String(context.decompileScript(script, 0)); 
     899                                }catch(e){ 
     900                                        print("Could not strip comments for file: " + fileList[i]); 
     901                                }finally{ 
     902                                        Packages.org.mozilla.javascript.Context.exit(); 
     903                                } 
    890904                                 
    891                                 if(commandResults.error){ 
    892                                         print("ERROR. Skipping file. Error is: " + commandResults.error); 
    893                                 }else{ 
    894                                         fileContents = commandResults.result; 
    895          
    896                                         //Replace the spaces with tabs. 
    897                                         //Ideally do this in the pretty printer rhino code. 
    898                                         fileContents = fileContents.replace(/    /g, "\t"); 
    899                                          
    900                                         //Write out the file with appropriate copyright. 
    901                                         buildUtil.saveUtf8File(fileList[i], copyrightText + buildUtil.getLineSeparator() + fileContents); 
    902                                 } 
    903                         } 
    904                 } 
    905         } 
    906 } 
    907  
    908 buildUtil.runCommand = function(/*String*/commandLineCommand){ 
    909         //summary: runs a command on the command line. 
    910         var process = java.lang.Runtime.getRuntime().exec(commandLineCommand); 
    911         var resultReader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream())); 
    912         var resultLine = null; 
    913         var result = ""; 
    914         var lineSeparator = buildUtil.getLineSeparator(); 
    915  
    916         var error = ""; 
    917         var errorReader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getErrorStream())); 
    918         //Only read one line of error, since waiting for all of it seems to hang. 
    919         //TODO: Fix that. There should be a way to get the complete error message. 
    920         if((resultLine = errorReader.readLine()) != null){ 
    921                 error += new String(resultLine) + lineSeparator; 
    922         } 
    923  
    924         if(error){ 
    925                 error = error.replace(/^\s*/, "").replace(/\s*$/, ""); 
    926         }else{ 
    927                 while((resultLine = resultReader.readLine()) != null){ 
    928                         result += new String(resultLine) + lineSeparator; 
    929                 } 
    930         } 
    931  
    932         return {result: result, error: error}; //String 
    933 } 
     905                                //Replace the spaces with tabs. 
     906                                //Ideally do this in the pretty printer rhino code. 
     907                                fileContents = fileContents.replace(/    /g, "\t"); 
     908                                 
     909                                //Write out the file with appropriate copyright. 
     910                                buildUtil.saveUtf8File(fileList[i], copyrightText + buildUtil.getLineSeparator() + fileContents); 
     911                        } 
     912                } 
     913        } 
     914} 
     915 
  • trunk/buildscripts/webbuild/webbuild.sh

    r7287 r7304  
    1818#Do xdajax build. 
    1919#Mark the dojo.js has an xdomain build, complete with xdomain path for Dojo. 
    20 ant -Dprofile=ajax -DreleaseName=$version -DdojoLoader=xdomain -Dversion=$version$versionSuffix -DxdDojoUrl=$xdDojoUrl clean release intern-strings xd-dojo-config 
     20ant -Dprofile=ajax -DreleaseName=$version -DdojoLoader=xdomain -Dversion=$version$versionSuffix -DxdDojoUrl=$xdDojoUrl clean release intern-strings xd-dojo-config strip-resource-comments 
    2121 
    22 #src folders/buildscripts for the webbuild stuff. 
    23 mkdir ../release 
    24  
    25 cd ../release 
     22cd ../release/$version 
    2623mkdir web 
    2724cd web 
    28 cp -r ../../src . 
    29 cp -r ../../buildscripts . 
    30 cp -r ../../dojo.js . 
    31 cp -r ../../iframe_history.html . 
    32 cp -r ../../flash6_gateway.swf . 
    33 cp -r ../../DojoFileStorageProvider.jar . 
    34 cp -r ../../storage_dialog.swf . 
    35 cp -r ../../Storage_version6.swf . 
    36 cp -r ../../Storage_version8.swf . 
     25cp -r ../../../src . 
     26cp -r ../../../buildscripts . 
     27cp -r ../../../dojo.js . 
     28cp -r ../../../iframe_history.html . 
     29cp -r ../../../flash6_gateway.swf . 
     30cp -r ../../../DojoFileStorageProvider.jar . 
     31cp -r ../../../storage_dialog.swf . 
     32cp -r ../../../Storage_version6.swf . 
     33cp -r ../../../Storage_version8.swf . 
    3734 
    3835#Stamp the web build with the xd Dojo URL and version. 
     
    4340#Generate the list of modules for the web build process. 
    4441java -jar ../lib/custom_rhino.jar makeWebBuildModuleList.js ../../src treeData.js 
    45 cd ../../.. 
     42 
     43#Got to buildscripts dir and run stripComments for web build. 
     44cd .. 
     45java -jar lib/custom_rhino.jar stripComments.js ../src 
    4646 
    4747#Now in release folder. Bundle it all up. 
    48 mv web/ $version/ 
     48cd ../../.. 
    4949zip -r dojo-$version.zip $version/* 
    5050mv dojo-$version.zip ../.. 
    5151 
    52 #Return to start directory. 
     52#Return to start directory 
    5353cd ../../..