Changeset 7448
- Timestamp:
- 02/25/07 14:00:41 (21 months ago)
- Location:
- branches/0.4/buildscripts
- Files:
-
- 4 modified
-
buildUtil.js (modified) (3 diffs)
-
makeDojoJsWeb.js (modified) (2 diffs)
-
webbuild.php (modified) (2 diffs)
-
webbuild/index.html (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/buildscripts/buildUtil.js
r7414 r7448 405 405 fileContents = String(fileContents); 406 406 407 var modifiedContents = null;407 var modifiedContents = fileContents; 408 408 409 409 if(fileContents.match(buildUtil.globalRequireLocalizationRegExp)){ … … 858 858 } 859 859 860 buildUtil.optimizeJs = function(/*String fileName*/fileName, /*String*/fileContents, /*String*/copyright, /*boolean*/doCompression){ 861 //summary: either strips comments from string or compresses it. 862 863 //Look for copyright. If so, maintain it. 864 //If no copyright text passed in, assume want a really stripped 865 //version. 866 copyright = copyright || ""; 867 var copyrightText = ""; 868 if(copyright){ 869 var singleLineMatches = fileContents.match(/\/\/.*copyright.*$/gi); 870 871 //Get rid of cr, lf, since it messes up matching. 872 var copyrightFileContents = fileContents.replace(/\r/g, "__DOJOCARRIAGERETURN__").replace(/\n/g, "__DOJONEWLINE__"); 873 var multiLineMatches = copyrightFileContents.match(/\/\*.*?copyright.*?\*\//gi); 874 875 //Finalize copyright notice. 876 if((multiLineMatches && multiLineMatches.length > 0) || (singleLineMatches && singleLineMatches.length > 0)){ 877 if(multiLineMatches && multiLineMatches.length > 0){ 878 copyrightText += multiLineMatches.join("\r\n").replace(/__DOJOCARRIAGERETURN__/g, "\r").replace(/__DOJONEWLINE__/g, "\n"); 879 } 880 if(singleLineMatches && singleLineMatches.length > 0){ 881 copyrightText += singleLineMatches.join("\r\n"); 882 } 883 copyrightText += buildUtil.getLineSeparator(); 884 }else{ 885 copyrightText = copyright; 886 } 887 } 888 889 //Use rhino to help do minifying/compressing. 890 var context = Packages.org.mozilla.javascript.Context.enter(); 891 try{ 892 // Use the interpreter for interactive input (copied this from Main rhino class). 893 context.setOptimizationLevel(-1); 894 895 var script = context.compileString(fileContents, fileName, 1, null); 896 if(doCompression){ 897 //Apply compression using custom compression call in Dojo-modified rhino. 898 fileContents = new String(context.compressScript(script, 0, fileContents, 1)); 899 }else{ 900 //Strip comments 901 fileContents = new String(context.decompileScript(script, 0)); 902 //Replace the spaces with tabs. 903 //Ideally do this in the pretty printer rhino code. 904 fileContents = fileContents.replace(/ /g, "\t"); 905 } 906 }finally{ 907 Packages.org.mozilla.javascript.Context.exit(); 908 } 909 910 return copyrightText + fileContents; 911 } 912 860 913 buildUtil.stripComments = function(/*String*/startDir, /*boolean*/suppressDojoCopyright){ 861 914 //summary: strips the JS comments from all the files in "startDir", and all subdirectories. … … 875 928 var fileContents = new String(buildUtil.readFile(fileList[i])); 876 929 877 //Look for copyright. If so, maintain it. 878 var singleLineMatches = fileContents.match(/\/\/.*copyright.*$/gi); 879 880 //Get rid of cr, lf, since it messes up matching. 881 copyrightFileContents = fileContents.replace(/\r/g, "__DOJOCARRIAGERETURN__").replace(/\n/g, "__DOJONEWLINE__"); 882 var multiLineMatches = copyrightFileContents.match(/\/\*.*?copyright.*?\*\//gi); 883 884 //Finalize copyright notice. 885 var copyrightText = ""; 886 if((multiLineMatches && multiLineMatches.length > 0) || (singleLineMatches && singleLineMatches.length > 0)){ 887 if(multiLineMatches && multiLineMatches.length > 0){ 888 copyrightText += multiLineMatches.join("\r\n").replace(/__DOJOCARRIAGERETURN__/g, "\r").replace(/__DOJONEWLINE__/g, "\n"); 889 } 890 if(singleLineMatches && singleLineMatches.length > 0){ 891 copyrightText += singleLineMatches.join("\r\n"); 892 } 893 copyrightText += buildUtil.getLineSeparator(); 894 }else{ 895 copyrightText = copyright; 930 //Do comment removal. 931 try{ 932 fileContents = buildUtil.optimizeJs(fileList[i], fileContents, copyright, false); 933 }catch(e){ 934 print("Could not strip comments for file: " + fileList[i] + ", error: " + e); 896 935 } 897 936 898 //Remove whitespace.899 var context = Packages.org.mozilla.javascript.Context.enter();900 try{901 // Use the interpreter for interactive input (copied this from Main rhino class).902 context.setOptimizationLevel(-1);903 904 var script = context.compileString(fileContents, fileList[i], 1, null);905 fileContents = new String(context.decompileScript(script, 0));906 }catch(e){907 print("Could not strip comments for file: " + fileList[i]);908 }finally{909 Packages.org.mozilla.javascript.Context.exit();910 }911 912 //Replace the spaces with tabs.913 //Ideally do this in the pretty printer rhino code.914 fileContents = fileContents.replace(/ /g, "\t");915 916 937 //Write out the file with appropriate copyright. 917 buildUtil.saveUtf8File(fileList[i], copyrightText + fileContents); 918 } 919 } 920 } 921 } 922 938 buildUtil.saveUtf8File(fileList[i], fileContents); 939 } 940 } 941 } 942 } 943 944 -
branches/0.4/buildscripts/makeDojoJsWeb.js
r7426 r7448 8 8 var version = new String(arguments[2]); 9 9 var xdDojoUrl = new String(arguments[3]); 10 var doCompression = new String(arguments[4]); 11 12 if(typeof(doCompression) != "undefined" && doCompression == "true"){ 13 doCompression = true; 14 }else{ 15 doCompression = false; 16 } 10 17 11 18 depList = depList.split(","); … … 46 53 dojo.require("dojo.string.extras"); 47 54 48 var contents = buildUtil.makeDojoJs(dependencyResult, version).dojoContents; 49 var prefixes = [["dojo", "src"]]; 55 var contents = ""; 56 try{ 57 contents = buildUtil.makeDojoJs(dependencyResult, version).dojoContents; 58 var prefixes = [["dojo", "src"]]; 59 60 //Make sure any dojo.requireLocalization calls are modified 61 //so that they inform the loader of valid locales that can be loaded. 62 contents = buildUtil.modifyRequireLocalization(contents, djConfig.baseRelativePath, prefixes); 63 64 //Convert requireLocalization calls into xdRequireLocalization calls. 65 contents = contents.replace(/dojo\.requireLocalization\s*\(/g, "dojo.xdRequireLocalization("); 66 67 //Intern strings. 68 contents = buildUtil.interningRegexpMagic("xdomain", contents, djConfig.baseRelativePath, prefixes, [], true); 69 70 //Set the xdomain dojo url 71 if(xdDojoUrl){ 72 contents = buildUtilXd.setXdDojoConfig(contents, xdDojoUrl); 73 } 50 74 51 //Make sure any dojo.requireLocalization calls are modified 52 //so that they inform the loader of valid locales that can be loaded. 53 contents = buildUtil.modifyRequireLocalization(contents, djConfig.baseRelativePath, prefixes); 54 55 //Convert requireLocalization calls into xdRequireLocalization calls. 56 contents = contents.replace(/dojo\.requireLocalization\s*\(/g, "dojo.xdRequireLocalization("); 57 58 //Add copyright, and intern strings. 59 contents = new String(buildUtil.readFile("copyright.txt")) + buildUtil.interningRegexpMagic("xdomain", contents, djConfig.baseRelativePath, prefixes, [], true); 60 61 if(xdDojoUrl){ 62 contents = buildUtilXd.setXdDojoConfig(contents, xdDojoUrl); 75 //Compress code, if desired. 76 if(doCompression){ 77 contents = buildUtil.optimizeJs("dojo.js", contents, "", doCompression); 78 } 79 80 //Add copyright 81 contents = new String(buildUtil.readFile("copyright.txt")) 82 + new String(buildUtil.readFile("build_notice.txt")) 83 + contents; 84 }catch(e){ 85 contents = "dojo.js build error: " + e; 63 86 } 64 87 65 88 print(contents); 66 89 } -
branches/0.4/buildscripts/webbuild.php
r7278 r7448 5 5 $version = isset($_POST['version']) ? $_POST['version'] : '0.0.0dev'; 6 6 $xdDojoUrl = isset($_POST['xdDojoUrl']) ? $_POST['xdDojoUrl'] : ''; 7 $doCompression = isset($_POST['doCompression']) ? $_POST['doCompression'] : 'false'; 7 8 8 9 if(!isset($depList)){ … … 16 17 header("Content-disposition: attachment; filename=dojo.js"); 17 18 18 $dojoContents = `/usr/bin/java -jar $buildScriptsDir/lib/custom_rhino.jar $buildScriptsDir/makeDojoJsWeb.js $depList $provideList $version $xdDojoUrl `;19 $dojoContents = `/usr/bin/java -jar $buildScriptsDir/lib/custom_rhino.jar $buildScriptsDir/makeDojoJsWeb.js $depList $provideList $version $xdDojoUrl $doCompression`; 19 20 20 21 print($dojoContents); -
branches/0.4/buildscripts/webbuild/index.html
r7286 r7448 133 133 depListForm.version.value = version; 134 134 depListForm.xdDojoUrl.value = xdDojoUrl; 135 depListForm.doCompression.value = document.masterForm.doCompression[1].checked ? true : false; 135 136 136 137 //reset the hidden frame so we can do another build. … … 375 376 376 377 <table id="outerTable"> 377 <tr><td colspan=3><h2>Dojo Builder ( highlyexperimental)378 <tr><td colspan=3><h2>Dojo Builder (experimental) 378 379 <div id="version">for version @VERSION@</div> 379 380 </h2></td></tr> … … 527 528 <table class="labelRow_table" width=100% cellpadding=1><tr> 528 529 <td id="dependencyRow_Arrow" class="labelRow_toggler"><div id="dependencyRow_toggler" class="toggler">–</div></td> 529 <td id="dependencyRow_Title" class="labelRow_title"> Modules to include:</td>530 <td id="dependencyRow_Title" class="labelRow_title">Resources to include:</td> 530 531 <td id="dependencyRow_Arrow" class="labelRow_values"></td> 531 532 </tr></table> … … 548 549 <td class="tree"><div id="treeContainer"></div></td> 549 550 </tr> 550 <tr><td class="underLabel">Enter module names separated by line returns and/or commas. <br>551 "Quotes" around module names are optional.</td>551 <tr><td class="underLabel">Enter resource names separated by line returns and/or commas. <br> 552 "Quotes" around resource names are optional.</td> 552 553 <td class="colSpacer"> </td> 553 554 <td class="underLabel">Double click items above to add them to the list.</td> … … 558 559 </tr> 559 560 560 <tr style="display:none"><td colspan=3 class="rowSpacer"> </td></tr>561 <tr style="display:none"><td colspan=3 class="labelRow outsetBorder" id="optionsRow_label" onclick="toggleRow('optionsRow')">561 <tr><td colspan=3 class="rowSpacer"> </td></tr> 562 <tr><td colspan=3 class="labelRow outsetBorder" id="optionsRow_label" onclick="toggleRow('optionsRow')"> 562 563 <table class="labelRow_table" width=100% cellpadding=1><tr> 563 564 <td id="optionsRow_Arrow" class="labelRow_toggler"><div id="optionsRow_toggler" class="toggler">–</div></td> … … 567 568 </td> 568 569 </tr> 569 <tr id="optionsRow" style="display:none">570 <tr id="optionsRow"> 570 571 <td class="colSpacer"> </td> 571 572 <td> 572 573 <table> 573 <tr><td class="fieldLabel">Profile name:</td> 574 <td class="field"><input id="profileName"></td> 575 <td class="colSpacer"> </td> 576 <td class="check"><input id="tellDojo" type="checkbox"></td> 577 <td class="checkLabel"><label for="tellDojo">Let dojo know about this profile</label><br> 578 <span class="note">(anonymous, for usage pattern info gathering only)</span></td> 579 </tr> 580 581 <tr><td class="check"><input id="strip" type="checkbox"></td> 582 <td class="checkLabel"><label for="strip">Strip whitespace</label></td> 583 </tr> 584 585 <tr><td class="check"><input id="removeComments" type="checkbox"></td> 586 <td class="checkLabel"><label for="removeComments">Remove comments</label></td> 587 </tr> 588 589 <tr><td class="check"><input id="compress" type="checkbox"></td> 590 <td class="checkLabel"><label for="compress">Compress the contents (very slow)</label></td> 591 </tr> 574 <tr><td class="radio"><input id="minify" name="doCompression" type="radio" value="false" CHECKED></td> 575 <td class="radioLabel"><label for="minify">Minify <span class="underLabel">Removes comments, but code is still readable for debugging</span></label></td> 576 </tr> 577 578 <tr><td class="radio" style="vertical-align: top"><input id="compress" name="doCompression" type="radio" value="false"></td> 579 <td class="radioLabel"><label for="compress">Compress <span class="underLabel">Modifies code to shrink size, but is harder to debug. Gives about a 10% file reduction when comparing its gzipped size to the gzipped size of the Minify option (tool does not do gzipping, you must do it yourself)</span></label></td> 580 </tr> 592 581 <!-- 593 582 --> … … 634 623 <input type="hidden" name="depList" value="" /> 635 624 <input type="hidden" name="provideList" value="" /> 636 <input type="hidden" name="version" value="" /> 637 <input type="hidden" name="compress" value="false" /> 625 <input type="hidden" name="version" value="" /> 638 626 <input type="hidden" name="xdDojoUrl" value="" /> 627 <input type="hidden" name="doCompression" value="" /> 639 628 </form> 640 629