| | 8 | var 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 | //***************************************************************************** |
| 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 | | } |
| | 53 | var kwArgs = _makeBuildOptions(arguments); |
| | 54 | |
| | 55 | //Set logging level. |
| | 56 | logger.level = kwArgs["log"]; |
| | 68 | //***************************************************************************** |
| | 69 | |
| | 70 | //********* Start help ************ |
| | 71 | function 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 ********* |
| | 214 | //********* Start _makeBuildOptions ********* |
| | 215 | function _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 | |