Changeset 12009
- Timestamp:
- 01/11/08 19:15:42 (6 months ago)
- Location:
- util/trunk/buildscripts
- Files:
-
- 5 modified
-
build.js (modified) (3 diffs)
-
jslib/buildUtil.js (modified) (5 diffs)
-
jslib/buildUtilXd.js (modified) (7 diffs)
-
jslib/dojoGuardEnd.jsfrag (modified) (1 diff)
-
jslib/dojoGuardStart.jsfrag (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
util/trunk/buildscripts/build.js
r11907 r12009 131 131 nlsIgnoreString += (nlsIgnoreString ? "|" : "") + buildUtil.regExpEscape(nameSegment); 132 132 133 134 //Burn in scope names for dojo.js/xd.js if requested. 135 if(kwArgs.scopeMap && (layerName.match(/dojo\.xd\.js$/) || layerName.match(/dojo\.js$/))){ 136 fileContents = buildUtil.setScopeNames(fileContents, kwArgs.scopeMap); 137 } 138 133 139 //Burn in xd path for dojo if requested, and only do this in dojo.xd.js. 134 140 if(layerName.match(/dojo\.xd\.js/) && kwArgs.xdDojoPath){ … … 143 149 var uncompressedContents = layerLegalText + fileContents; 144 150 if(layerName.match(/\.xd\.js$/) && !layerName.match(/dojo(\.xd)?\.js/)){ 145 uncompressedContents = buildUtilXd.makeXdContents(uncompressedContents, prefixes );151 uncompressedContents = buildUtilXd.makeXdContents(uncompressedContents, prefixes, kwArgs); 146 152 } 147 153 fileUtil.saveUtf8File(uncompressedFileName, uncompressedContents); … … 246 252 247 253 if(kwArgs.loader == "xdomain"){ 248 buildUtilXd.xdgen(prefixName, prefixPath, prefixes, layerIgnoreRegExp );254 buildUtilXd.xdgen(prefixName, prefixPath, prefixes, layerIgnoreRegExp, kwArgs); 249 255 } 250 256 -
util/trunk/buildscripts/jslib/buildUtil.js
r11919 r12009 92 92 + "will be generated in each module prefix's release directory which maps the " 93 93 + "short symbol names to more descriptive names." 94 } 94 }, 95 "scopeMap": { 96 defaultValue: "", 97 helpText: "Change the default dojo, dijit and dojox scope names to soemthing else. Useful if you want to " 98 + "use Dojo as part of a JS library, but want to make a self-contained library with no external dojo/dijit/dojox " 99 + "references. Format is a string that contains no spaces, and is similar to the djConfig.scopeMap value (note that the " 100 + "backslashes below are required to avoid shell escaping):\n" 101 + "scopeMap: [[\\\"dojo\\\",\\\"mydojo\\\"],[\\\"dijit\\\",\\\"mydijit\\\"][\\\"dojox\\\",\\\"mydojox\\\"]]" 102 }, 103 "xdScopeArgs": { 104 defaultValue: "", 105 helpText: "If the loader=xdomain build option is used, then the value of this option " 106 + "will be used as the arguments to the function that defines the modules in the .xd.js files. " 107 + "This allows for more than one version of the same module to be in a page. See documentation on " 108 + "djConfig.scopeMap for more information." 109 }, 110 "xdDojoScopeName": { 111 defaultValue: "dojo", 112 helpText: "If the loader=xdomain build option is used, then the value of this option " 113 + "will be used instead of 'dojo' for the 'dojo._xdResourceLoaded()' calls that are done in the .xd.js files. " 114 + "This allows for dojo to be under a different scope name but still allow xdomain loading with that scope name." 115 } 95 116 }; 96 117 … … 183 204 dojo._loadedUrls.push(buildscriptsPath + "../../dojo/_base/_loader/hostenv_"+hostenvType+".js"); 184 205 } 185 186 dojo._loadedUrls.push(buildscriptsPath + "jslib/dojoGuardEnd.jsfrag");187 206 } 188 207 … … 372 391 } 373 392 374 393 394 //Add the loader files if this is a loader layer. 375 395 if(layerName == "dojo.js"){ 376 396 buildUtil.includeLoaderFiles("default", hostenvType, buildscriptsPath); … … 398 418 var depList = buildUtil.determineUriList(layer.dependencies, layerUris, dependencies["filters"]); 399 419 420 421 //Add the final closure guard to the list. 422 if(layerName == "dojo.js" || layerName == "dojo.xd.js"){ 423 depList.push(buildscriptsPath + "jslib/dojoGuardEnd.jsfrag"); 424 } 425 400 426 //Store the layer URIs that are in this file as well as all files it depends on. 401 427 namedLayerUris[layer.name] = layerUris.concat(depList); … … 1212 1238 } 1213 1239 1240 buildUtil.setScopeNames = function(/*String*/fileContents, /*String*/scopeMap){ 1241 //summary: burns in the scope names into the file contents. 1242 //scopeMap should be a [["name","value"],["name","value"]] string. Notice the lack of spaces. 1243 //Single quotes can be used instead of double quotes. 1244 return fileContents.replace(/var\s+sMap\s+=\s+null/, "var sMap = " + scopeMap); 1245 } 1246 1214 1247 buildUtil.symctr = 0; 1215 1248 buildUtil.symtbl = null; -
util/trunk/buildscripts/jslib/buildUtilXd.js
r11782 r12009 44 44 /*String*/prefixPath, 45 45 /*Array*/prefixes, 46 /*RegExp*/optimizeIgnoreRegExp 46 /*RegExp*/optimizeIgnoreRegExp, 47 /*Object*/kwArgs 47 48 ){ 48 49 //summary: generates the .xd.js files for a build. … … 66 67 //need to have special xd contents. 67 68 if(jsFileName.match(/\/nls\//) && fileContents.indexOf("dojo.provide(") == -1){ 68 var xdContents = buildUtilXd.makeXdBundleContents(prefixName, prefixPath, jsFileName, fileContents, prefixes );69 var xdContents = buildUtilXd.makeXdBundleContents(prefixName, prefixPath, jsFileName, fileContents, prefixes, kwArgs); 69 70 }else{ 70 xdContents = buildUtilXd.makeXdContents(fileContents, prefixes );71 xdContents = buildUtilXd.makeXdContents(fileContents, prefixes, kwArgs); 71 72 } 72 73 fileUtil.saveUtf8File(xdFileName, xdContents); … … 77 78 //START makeXdContents function 78 79 //Function that generates the XD version of the module file's contents 79 buildUtilXd.makeXdContents = function(fileContents, prefixes ){80 buildUtilXd.makeXdContents = function(fileContents, prefixes, kwArgs){ 80 81 var dependencies = []; 81 82 … … 115 116 //Build the xd file contents. 116 117 var xdContentsBuffer = []; 117 xdContentsBuffer.push( "dojo._xdResourceLoaded({\n");118 xdContentsBuffer.push((kwArgs.xdDojoScopeName || "dojo") + "._xdResourceLoaded({\n"); 118 119 119 120 //Add in dependencies section. … … 130 131 131 132 //Add the contents of the file inside a function. 132 //Pass in dojo as an argument to the function to help with133 //allowing multiple versions of dojo in a page.134 xdContentsBuffer.push("\ndefineResource: function( dojo){");133 //Pass in module names to allow for multiple versions of modules in a page. 134 var scopeArgs = kwArgs.xdScopeArgs || "dojo, dijit, dojox"; 135 xdContentsBuffer.push("\ndefineResource: function(" + scopeArgs + "){"); 135 136 //Remove requireLocalization calls, since that will mess things up. 136 137 //String() part is needed since fileContents is a Java object. … … 144 145 145 146 //START makeXdBundleContents function 146 buildUtilXd.makeXdBundleContents = function(prefix, prefixPath, srcFileName, fileContents, prefixes ){147 buildUtilXd.makeXdBundleContents = function(prefix, prefixPath, srcFileName, fileContents, prefixes, kwArgs){ 147 148 //logger.info("Flattening bundle: " + srcFileName); 148 149 … … 169 170 170 171 //Now make a proper xd.js file out of the content. 171 return buildUtilXd.makeXdContents(fileContents, prefixes );172 return buildUtilXd.makeXdContents(fileContents, prefixes, kwArgs); 172 173 } 173 174 //END makeXdBundleContents function -
util/trunk/buildscripts/jslib/dojoGuardEnd.jsfrag
r7898 r12009 1 }; 1 2 })(); -
util/trunk/buildscripts/jslib/dojoGuardStart.jsfrag
r7898 r12009 1 if(typeof dojo == "undefined"){ 1 ;(function(){ 2 3 /* 4 dojo, dijit, and dojox must always be the first three, and in that order. 5 djConfig.scopeMap = [ 6 ["dojo", "fojo"], 7 ["dijit", "fijit"], 8 ["dojox", "fojox"] 9 10 ] 11 */ 12 13 //The null below can be relaced by a build-time value. 14 var sMap = null; 15 16 //See if new scopes need to be defined. 17 if((sMap || (typeof djConfig != "undefined" && djConfig.scopeMap)) && (typeof window != "undefined")){ 18 var scopeDef = "", scopePrefix = "", scopeSuffix = "", scopeMap = {}, scopeMapRev = {}; 19 sMap = sMap || djConfig.scopeMap; 20 for(var i = 0; i < sMap.length; i++){ 21 //Make local variables, then global variables that use the locals. 22 var newScope = sMap[i]; 23 scopeDef += "var " + newScope[0] + " = {}; " + newScope[1] + " = " + newScope[0] + ";" + newScope[1] + "._scopeName = '" + newScope[1] + "';"; 24 scopePrefix += (i == 0 ? "" : ",") + newScope[0]; 25 scopeSuffix += (i == 0 ? "" : ",") + newScope[1]; 26 scopeMap[newScope[0]] = newScope[1]; 27 scopeMapRev[newScope[1]] = newScope[0]; 28 } 29 30 eval(scopeDef + "dojo._scopeArgs = [" + scopeSuffix + "];"); 31 32 dojo._scopePrefixArgs = scopePrefix; 33 dojo._scopePrefix = "(function(" + scopePrefix + "){"; 34 dojo._scopeSuffix = "})(" + scopeSuffix + ")"; 35 dojo._scopeMap = scopeMap; 36 dojo._scopeMapRev = scopeMapRev; 37 }