Changeset 7450

Show
Ignore:
Timestamp:
02/25/07 22:46:42 (21 months ago)
Author:
jburke
Message:

References #2366. Have something primitive working for the build cache. Still need to do more testing, and something is weird with compression -- failure in makeDojoJsWeb.js when trying to make it.

Location:
branches/0.4/buildscripts
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.4/buildscripts/makeDojoJsWeb.js

    r7448 r7450  
    44load("buildUtilXd.js"); 
    55 
    6 var depList = new String(arguments[0]); 
    7 var provideList = new String(arguments[1]); 
    8 var version = new String(arguments[2]); 
    9 var xdDojoUrl = new String(arguments[3]); 
    10 var doCompression = new String(arguments[4]); 
     6var result = "ERROR"; 
    117 
    12 if(typeof(doCompression) != "undefined" && doCompression == "true"){ 
    13         doCompression = true; 
    14 }else{ 
    15         doCompression = false; 
    16 } 
     8var buildDirectory = new String(arguments[0]); 
     9var depList = new String(arguments[1]); 
     10var provideList = new String(arguments[2]); 
     11var version = new String(arguments[3]); 
     12var xdDojoUrl = new String(arguments[4]); 
    1713 
    1814depList = depList.split(","); 
     
    5248        load('../dojo.js'); 
    5349        dojo.require("dojo.string.extras"); 
    54          
    55         var contents = ""; 
     50        dojo.require("dojo.crypto.MD5"); 
     51 
     52        var buildSigDir = dojo.crypto.MD5.compute(dependencyResult.depList.sort().join(","), dojo.crypto.outputTypes.Hex); 
    5653        try{ 
    57                 contents = buildUtil.makeDojoJs(dependencyResult, version).dojoContents; 
     54                var contents = buildUtil.makeDojoJs(dependencyResult, version).dojoContents; 
     55                var compressedContents = ""; 
    5856                var prefixes = [["dojo", "src"]]; 
    5957         
     
    7371                } 
    7472 
    75                 //Compress code, if desired. 
    76                 if(doCompression){ 
    77                         contents = buildUtil.optimizeJs("dojo.js", contents, "", doCompression); 
    78                 } 
     73                //Compress code. 
     74                compressedContents = buildUtil.optimizeJs("dojo.js", contents, "", true); 
    7975 
    8076                //Add copyright 
    81                 contents = new String(buildUtil.readFile("copyright.txt")) 
    82                         + new String(buildUtil.readFile("build_notice.txt")) 
    83                         + contents; 
     77                var copyright = new String(buildUtil.readFile("copyright.txt")); 
     78                var buildNotice = new String(buildUtil.readFile("build_notice.txt")); 
     79                contents = copyright + buildNotice + contents; 
     80                compressedContents = copyright + buildNotice + compressedContents; 
     81                 
     82                //Prep cache location 
     83                var buildCachePath = buildDirectory + "/" + buildSigDir + "/"; 
     84 
     85                //Create needed directories for cache location. 
     86                var dirFile = new java.io.File(buildCachePath + "compressed"); 
     87                var dirsOk = dirFile.mkdirs(); 
     88 
     89                result = "dirFile: " + dirFile.getAbsolutePath() + ", dirsOK: " + dirsOk; 
     90                 
     91                //Save files to disk 
     92                buildUtil.saveUtf8File(buildCachePath + "dojo.js", contents); 
     93                buildUtil.saveUtf8File(buildCachePath + "compressed/dojo.js", compressedContents); 
     94                 
     95                result = "OK"; 
    8496        }catch(e){ 
    85                 contents = "dojo.js build error: " + e;  
     97                result += "ERROR: " + e;         
    8698        } 
    8799 
    88         print(contents); 
     100        print(result); 
    89101} 
  • branches/0.4/buildscripts/webbuild.php

    r7448 r7450  
    11<? 
    22        $buildScriptsDir = "/Users/jrbsilver/svn/dojo/branches/0.4/buildscripts"; 
     3        $buildCacheDir = "/Users/jrbsilver/svn/dojo/branches/0.4/buildscripts/webbuild/webbuildtemp/0.4.2rc1/web/buildscripts"; 
    34        $depList = isset($_POST['depList']) ? $_POST['depList'] : null; 
    45        $provideList = isset($_POST['provideList']) ? $_POST['provideList'] : 'null'; 
    56        $version = isset($_POST['version']) ? $_POST['version'] : '0.0.0dev'; 
    67        $xdDojoUrl = isset($_POST['xdDojoUrl']) ? $_POST['xdDojoUrl'] : ''; 
    7         $doCompression = isset($_POST['doCompression']) ? $_POST['doCompression'] : 'false'; 
    88 
    99        if(!isset($depList)){ 
     
    1717                header("Content-disposition: attachment; filename=dojo.js"); 
    1818                 
    19                 $dojoContents = `/usr/bin/java -jar $buildScriptsDir/lib/custom_rhino.jar $buildScriptsDir/makeDojoJsWeb.js $depList $provideList $version $xdDojoUrl $doCompression`; 
     19                $dojoContents = `/usr/bin/java -jar $buildScriptsDir/lib/custom_rhino.jar $buildScriptsDir/makeDojoJsWeb.js $buildCacheDir/dojobuilds $depList $provideList $version $xdDojoUrl`; 
    2020 
    2121                print($dojoContents); 
  • branches/0.4/buildscripts/webbuild/index.html

    r7448 r7450  
    113113        dojo.require("dojo.widget.TreeEmphasizeOnSelect"); 
    114114        dojo.require("dojo.html.iframe"); 
     115        dojo.require("dojo.crypto.MD5"); 
     116        dojo.require("dojo.string.extras"); 
    115117 
    116118        //assign output node on load. 
     
    124126        } 
    125127         
     128        function getCachedBuildUrl(depList){ 
     129                var doCompression = document.masterForm.doCompression[1].checked ? true : false; 
     130                var sortedFileList = depList.sort().join(","); 
     131                var buildKey = dojo.crypto.MD5.compute(sortedFileList, dojo.crypto.outputTypes.Hex); 
     132                return "dojobuilds/" + buildKey + (doCompression ? "/compressed" : "") + "/dojo.js"; 
     133        } 
     134 
    126135        function sendDependencyResultToServer(dependencyResult){ 
    127136                clearOutput(); 
    128137 
     138                //Find out if the build result is already on the server. 
     139                var cachedBuildUrl = getCachedBuildUrl(dependencyResult.depList); 
     140                dojo.io.bind({ 
     141                        //Add an URL marker for the server to know if this is an existence query. 
     142                        //Mostly helpful in the Safari 2.0 case where it doesn't support HEAD 
     143                        //requests. This marker should be used to filter server logs when trying to find 
     144                        //download counts. 
     145                        url: cachedBuildUrl + "?query=exist", 
     146                        method: "HEAD", 
     147                        mimetype: "text/plain", 
     148                        handle: function(type, data, xhr, kwArgs){ 
     149                                var httpStatus = parseInt(xhr.status, 10); 
     150                                if(httpStatus >= 400){ 
     151                                        //Build does not exist. Ask server to make it. 
     152                                        requestServerBuild(dependencyResult); 
     153                                }else{ 
     154                                        outputBuildResults(dependencyResult); 
     155                                        window.location = "../" + cachedBuildUrl; 
     156                                } 
     157                        } 
     158                }); 
     159        } 
     160 
     161        function requestServerBuild(dependencyResult){ 
    129162                var depListForm = document.depListForm; 
    130                 depListForm.action = "../webbuild.php"; 
    131                 depListForm.depList.value = dependencyResult.depList.join(","); 
    132                 depListForm.provideList.value = dependencyResult.provideList && dependencyResult.provideList.length > 0 ? dependencyResult.provideList.join(",") : "null"; 
    133                 depListForm.version.value = version; 
    134                 depListForm.xdDojoUrl.value = xdDojoUrl; 
    135                 depListForm.doCompression.value = document.masterForm.doCompression[1].checked ? true : false; 
    136  
     163                 
     164                //Ask the server to build the result. 
     165                dojo.io.bind({ 
     166                        url: "../webbuild.php", 
     167                        method: "POST", 
     168                        mimetype: "text/plain", 
     169                        content: { 
     170                                depList: dependencyResult.depList.join(","), 
     171                                provideList: (dependencyResult.provideList && dependencyResult.provideList.length > 0) ? dependencyResult.provideList.join(",") : "null", 
     172                                version: version, 
     173                                xdDojoUrl: xdDojoUrl 
     174                        }, 
     175                        handle: function(type, data, xhr, kwArgs){ 
     176                                if(type == "load" && dojo.string.trim(data).indexOf("OK") == 0){ 
     177                                        outputBuildResults(dependencyResult); 
     178                                        window.location = "../" + getCachedBuildUrl(dependencyResult.depList); 
     179                                }else{ 
     180                                        alert("Build " + type + " [" + data + "]"); 
     181                                } 
     182                        } 
     183                }); 
     184 
     185        } 
     186 
     187        function outputBuildResults(dependencyResult){ 
    137188                //reset the hidden frame so we can do another build. 
    138189                setTimeout(function(){ 
     
    155206                        } 
    156207                } 
    157  
    158                 //Submit form to generate custom dojo.js file. 
    159                 depListForm.submit(); 
    160208        } 
    161209