Changeset 7785

Show
Ignore:
Timestamp:
03/25/07 15:28:29 (20 months ago)
Author:
jburke
Message:

Refs #2607. Allow profile file to contain build options off the dependencies object, and added a help action to explain how to use the build.

Location:
util/trunk/buildscripts
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • util/trunk/buildscripts/build.js

    r7780 r7785  
    66load("jslib/buildUtil.js"); 
    77 
     8var DojoBuildOptions = { 
     9        "profile": { 
     10                defaultValue: "base", 
     11                helpText: "The name of the profile to use for the build. It must be the first part of " 
     12                        + "the profile file name in the profiles/ directory. For instance, to use base.profile.js, " 
     13                        + "specify profile=base." 
     14        }, 
     15        "profileFile": { 
     16                defaultValue: "", 
     17                helpText: "A file path to the the profile file. Use this if your profile is outside of the profiles " 
     18                        + "directory. Do not specify the \"profile\" build option if you use \"profileFile\"." 
     19        }, 
     20        "action": { 
     21                defaultValue: "help", 
     22                helpText: "The build action(s) to run. Can be a comma-separated list, like action=clean,release. " 
     23                        + "The possible build actions are: clean, release." 
     24        }, 
     25        "version": { 
     26                defaultValue: "0.0.0.dev", 
     27                helpText: "The build will be stamped with this version string." 
     28        }, 
     29        "releaseName": { 
     30                defaultValue: "dojo", 
     31                helpText: "The name of the release directory." 
     32        }, 
     33        "loader": { 
     34                defaultValue: "default", 
     35                helpText: "The type of dojo loader to use. \"default\" or \"xdomain\" are acceptable values."            
     36        }, 
     37        "internStrings": { 
     38                defaultValue: true, 
     39                helpText: "Turn on or off widget template/dojo.uri.cache() file interning." 
     40        }, 
     41        "copyTests": { 
     42                defaultValue: true, 
     43                helpText: "Turn on or off copying of test files." 
     44        }, 
     45        "log": { 
     46                defaultValue: logger.TRACE, 
     47                helpText: "Sets the logging verbosity. See jslib/logger.js for possible integer values." 
     48        } 
     49}; 
     50 
     51//***************************************************************************** 
    852//Convert arguments to keyword arguments. 
    9 var kwArgs = buildUtil.convertArrayToObject(arguments); 
    10  
    11 //Set some defaults for some args if they are missing. 
    12 kwArgs.releaseName = kwArgs["releaseName"] || "dojo"; 
    13 kwArgs.releaseDir = "release/" + kwArgs["releaseName"] || "dojo"; 
    14 kwArgs.version = kwArgs["version"] || "0.0.0.dev"; 
    15 kwArgs.action = (kwArgs["action"] || "release").split(","); 
    16 kwArgs.loader = kwArgs["loader"] || "default"; 
    17 if(!kwArgs["profileFile"] && kwArgs["profile"]){ 
    18         kwArgs.profileFile = "profiles/" + kwArgs.profile + ".profile.js"; 
    19 } 
    20 if(typeof kwArgs["internStrings"] == "undefined"){ 
    21         kwArgs.internStrings = true;     
    22 } 
    23 if(kwArgs["log"]){ 
    24         logger.level = logger[kwArgs["log"]]; 
    25 } 
    26 if(typeof kwArgs["copyTests"] == "undefined"){ 
    27         kwArgs.copyTests = true;         
    28 } 
     53var kwArgs = _makeBuildOptions(arguments); 
     54 
     55//Set logging level. 
     56logger.level = kwArgs["log"]; 
    2957 
    3058//Execute the requested build actions 
     
    3866var buildTime = ((new Date().getTime() - buildTimerStart) / 1000); 
    3967logger.info("Build time: " + buildTime + " seconds"); 
     68//***************************************************************************** 
     69 
     70//********* Start help ************ 
     71function help(){ 
     72        var buildOptionText = ""; 
     73        for(var param in DojoBuildOptions){ 
     74                buildOptionText += param + "=" + DojoBuildOptions[param].defaultValue + "\n" 
     75                        + DojoBuildOptions[param].helpText + "\n\n"; 
     76        } 
     77 
     78        var helpText = "To run the build, you must have Java 1.4.2 or later installed.\n" 
     79                + "To run a build run the following command from this directory:\n\n" 
     80                + "> java -jar lib/custom_rhino.jar build.js [name=value...]\n\n" 
     81                + "Here is an example of a typical release build:\n\n" 
     82                + "> java -jar lib/custom_rhino.jar build.js profile=base action=release\n\n" 
     83                + "The possible name=value build options are shown below with the defaults as their values:\n\n" 
     84                + buildOptionText; 
     85         
     86        print(helpText); 
     87} 
     88//********* End help ********* 
    4089 
    4190//********* Start clean ************ 
     
    4998function release(){ 
    5099        logger.info("Using profile: " + kwArgs.profileFile); 
    51  
    52100        logger.info("Using version number: " + kwArgs.version + " for the release."); 
    53101         
    54102        clean(); 
    55          
    56         //Get the list of module directories we need to process. 
    57         //They will be in the dependencies.prefixes array. 
    58         kwArgs.profileProperties = buildUtil.evalProfile(kwArgs.profileFile); 
     103 
    59104        var dependencies = kwArgs.profileProperties.dependencies; 
    60105        var prefixes = dependencies.prefixes; 
     
    64109        var buildNoticeText = String(fileUtil.readFile("build_notice.txt")); 
    65110         
     111        //Get the list of module directories we need to process. 
     112        //They will be in the dependencies.prefixes array. 
    66113        //Copy each prefix dir to the releases and 
    67114        //operate on that copy. 
     
    159206 
    160207        //FIXME: Run xdgen if an xdomain build. 
     208        if(kwArgs.loader == "xdomain"){ 
     209 
     210        } 
    161211} 
    162212//********* End _releasePrefixPath ********* 
    163213 
     214//********* Start _makeBuildOptions ********* 
     215function _makeBuildOptions(/*Array*/scriptArgs){ 
     216        var kwArgs = {}; 
     217 
     218        //Parse the command line arguments 
     219        var kwArgs = buildUtil.convertArrayToObject(scriptArgs); 
     220        if(!kwArgs["profileFile"] && kwArgs["profile"]){ 
     221                kwArgs.profileFile = "profiles/" + kwArgs.profile + ".profile.js"; 
     222        } 
     223 
     224        //Load dependencies object from profile file, if there is one. 
     225        var dependencies = {}; 
     226        if(kwArgs["profileFile"]){ 
     227                var profileProperties = buildUtil.evalProfile(kwArgs.profileFile); 
     228                if(profileProperties){ 
     229                        kwArgs.profileProperties = profileProperties; 
     230                        dependencies = kwArgs.profileProperties.dependencies; 
     231                         
     232                        //Allow setting build options from on the profile's dependencies object 
     233                        for(var param in DojoBuildOptions){ 
     234                                if(typeof dependencies[param] != "undefined"){ 
     235                                        kwArgs[param] = dependencies[param]; 
     236                                } 
     237                        } 
     238                } 
     239        } 
     240 
     241        //Set up default options 
     242        for(var param in DojoBuildOptions){ 
     243                //Only use default if there is no value so far. 
     244                if(typeof kwArgs[param] == "undefined"){ 
     245                        kwArgs[param] = DojoBuildOptions[param].defaultValue; 
     246                } 
     247        } 
     248 
     249        //Set up some compound values 
     250        kwArgs.releaseDir = "release/" + kwArgs["releaseName"]; 
     251        kwArgs.action = kwArgs.action.split(","); 
     252         
     253        return kwArgs; 
     254} 
     255//********* End _makeBuildOptions ********* 
     256 
  • util/trunk/buildscripts/jslib/buildUtil.js

    r7780 r7785  
    11var buildUtil = {}; 
    22 
     3//FIXME: This should take the build kwArgs now instead. 
    34buildUtil.getDojoLoader = function(/*Object?*/dependencies){ 
    45        //summary: gets the type of Dojo loader for the build. For example default or 
     
    354355        } 
    355356         
    356         // dojo.requireLocalization is a special case as it pulls in dojo.i18n.loader at runtime 
     357        // dojo.requireLocalization is a special case as it pulls in dojo.i18n at runtime 
    357358        if(dojoContents.match(buildUtil.globalRequireLocalizationRegExp)){ 
    358                 //FIXME: Uncomment this line with i18n gets ported to 0.9 
    359                 //depList.push("../src/i18n/loader.js"); 
     359                depList.push("../../dojo/i18n.js"); 
    360360                dojoContents += new String(fileUtil.readFile(depList[depList.length-1])); 
    361361        }