Changeset 7764

Show
Ignore:
Timestamp:
03/22/07 18:06:52 (16 months ago)
Author:
jburke
Message:

Refs #2607. Starting non-ant build option. Does not work yet. This build approach should support any number of namespaces.

Location:
util/trunk/buildscripts
Files:
3 added
1 removed
10 modified

Legend:

Unmodified
Added
Removed
  • util/trunk/buildscripts/cldr/cldrArrayInherit.js

    r7760 r7764  
    4444dojo.require("dojo.json"); 
    4545 
     46load("fileUtil.js"); 
    4647load("buildUtil.js"); 
    4748 
    4849// limit search to gregorian.js files, which are the only ones to use Array as data type 
    49 var fileList = buildUtil.getFilteredFileList(dir, /\/gregorian\.js$/, true); 
     50var fileList = fileUtil.getFilteredFileList(dir, /\/gregorian\.js$/, true); 
    5051 
    5152for(var i= 0; i < fileList.length; i++){ 
     
    100101        }); 
    101102        if(hasChanged){ 
    102                 buildUtil.saveUtf8File(jsFileName, dojo.json.serialize(data)); 
     103                fileUtil.saveUtf8File(jsFileName, dojo.json.serialize(data)); 
    103104        } 
    104105} 
  • util/trunk/buildscripts/flattenResources.js

    r6717 r7764  
    3333dojo.require("dojo.i18n.common"); 
    3434dojo.require("dojo.json"); 
     35load("fileUtil.js"); 
    3536load("buildUtil.js"); 
    3637 
     
    9495//Flatten all bundles and modifying dojo.requireLocalization calls. 
    9596var prefixes = buildUtil.configPrefixes(profileFile); 
    96 var fileList = buildUtil.getFilteredFileList(releaseDir + "/src", /\.js$/, true); 
     97var fileList = fileUtil.getFilteredFileList(releaseDir + "/src", /\.js$/, true); 
    9798 
    9899for(var i= 0; i < fileList.length; i++){ 
     
    110111         
    111112        if(fileContents){ 
    112                 buildUtil.saveUtf8File(jsFileName, fileContents); 
     113                fileUtil.saveUtf8File(jsFileName, fileContents); 
    113114        } 
    114115} 
  • util/trunk/buildscripts/jslib/buildUtil.js

    r7755 r7764  
    11var buildUtil = {}; 
    2  
    3 buildUtil.getLineSeparator = function(){ 
    4         //summary: Gives the line separator for the platform. 
    5         //For web builds override this function. 
    6         return java.lang.System.getProperty("line.separator"); 
    7 } 
    82 
    93buildUtil.getDojoLoader = function(/*Object?*/dependencies){ 
     
    288282        var dependencies = null; 
    289283        var hostenvType = null; 
    290         var profileText = new String(buildUtil.readFile(profileFile)); 
    291          
    292         //Remove the call to getDependencyList.js because we want to call it manually. 
     284        var profileText = new String(fileUtil.readFile(profileFile)); 
     285         
     286        //Remove the call to getDependencyList.js because it is not supported anymore. 
    293287        profileText = profileText.replace(/load\(("|')getDependencyList.js("|')\)/, ""); 
    294288        eval(profileText); 
     289         
     290        //Build up the prefixes so the rest of the scripts 
     291        //do not have to guess where things are at. 
     292        if(!dependencies["prefixes"]){ 
     293                dependencies.prefixes = []; 
     294        } 
     295         
     296        //Find prefixes that are used. 
     297        var usedPrefixes = ["dojo"]; 
     298        xxx 
     299         
    295300        return { 
    296301                dependencies: dependencies, 
     
    318323        for(var i = 0; i < depList.length; i++){ 
    319324                //Make sure we have a JS string and not a Java string by using new String(). 
    320                 dojoContents += new String(buildUtil.readFile(depList[i])) + "\r\n"; 
     325                dojoContents += new String(fileUtil.readFile(depList[i])) + "\r\n"; 
    321326        } 
    322327         
     
    324329        if(dojoContents.match(buildUtil.globalRequireLocalizationRegExp)){ 
    325330                depList.push("../src/i18n/loader.js"); 
    326                 dojoContents += new String(readFile(depList[depList.length-1])); 
     331                dojoContents += new String(fileUtil.readFile(depList[depList.length-1])); 
    327332        } 
    328333 
     
    387392        //returned from buildUtil.getDependencyList() 
    388393 
    389         var lineSeparator = buildUtil.getLineSeparator(); 
     394        var lineSeparator = fileUtil.getLineSeparator(); 
    390395 
    391396        //Cycle through the layers to create the content for each layer. 
     
    552557         
    553558        var bundleRegExp = new RegExp("nls[/]?([\\w\\-]*)/" + bundleName + ".js$"); 
    554         var bundleFiles = buildUtil.getFilteredFileList(filePath + "nls/", bundleRegExp, true); 
     559        var bundleFiles = fileUtil.getFilteredFileList(filePath + "nls/", bundleRegExp, true); 
    555560         
    556561        //Find the list of locales supported by looking at the path names. 
     
    744749        //Make sure dojo is in the list. 
    745750        var dojoPath = releaseDir.replace(/^.*(\/|\\)release(\/|\\)/, "release/"); 
    746         prefixes.push(["dojo", dojoPath + "/src"]); 
    747751 
    748752        var skiplist = dependencies["internSkipList"] || []; 
     
    760764 
    761765        //Intern strings for all files in widget dir (xdomain and regular files) 
    762         var fileList = buildUtil.getFilteredFileList(releaseDir + "/src/widget", 
     766        var fileList = fileUtil.getFilteredFileList(releaseDir + "/src/widget", 
    763767                /\.js$/, true); 
    764768 
     
    773777        var resourceContent = new String(readText(resourceFile)); 
    774778        resourceContent = buildUtil.interningRegexpMagic(loader, resourceContent, srcRoot, prefixes, skiplist); 
    775         buildUtil.saveUtf8File(resourceFile, resourceContent); 
     779        fileUtil.saveUtf8File(resourceFile, resourceContent); 
    776780} 
    777781 
     
    852856} 
    853857 
    854 buildUtil.isValueInArray = function(value, ary){ 
     858buildUtil.isValueInArray = function(/*Object*/value, /*Array*/ary){ 
     859        //summary: sees if value is in the ary array. Uses == to see if the 
     860        //array item matches value. 
    855861        for(var i = 0; i < ary.length; i++){ 
    856862                if(ary[i] == value){ 
    857                         return true; 
    858                 } 
    859         } 
    860         return false; 
    861 } 
    862  
    863  
    864 //Recurses startDir and finds matches to the files that match regExpFilter. 
    865 //Ignores files/directories that start with a period (.). 
    866 buildUtil.getFilteredFileList = function(startDir, regExpFilter, makeUnixPaths, startDirIsJavaObject){ 
    867         var files = []; 
    868  
    869         var topDir = startDir; 
    870         if(!startDirIsJavaObject){ 
    871                 topDir = new java.io.File(startDir); 
    872         } 
    873  
    874         if(topDir.exists()){ 
    875                 var dirFileArray = topDir.listFiles(); 
    876                 for (var i = 0; i < dirFileArray.length; i++){ 
    877                         var file = dirFileArray[i]; 
    878                         if(file.isFile()){ 
    879                                 var filePath = file.getPath(); 
    880                                 if(makeUnixPaths){ 
    881                                         //Make sure we have a JS string. 
    882                                         filePath = String(filePath); 
    883                                         if(filePath.indexOf("/") == -1){ 
    884                                                 filePath = filePath.replace(/\\/g, "/"); 
    885                                         } 
    886                                 } 
    887                                 if(!file.getName().match(/^\./) && filePath.match(regExpFilter)){ 
    888                                         files.push(filePath); 
    889                                 } 
    890                         }else if(file.isDirectory() && !file.getName().match(/^\./)){ 
    891                                 var dirFiles = this.getFilteredFileList(file, regExpFilter, makeUnixPaths, true); 
    892                                 files.push.apply(files, dirFiles); 
    893                         } 
    894                 } 
    895         } 
    896  
    897         return files; 
    898 } 
    899  
    900 buildUtil.ensureEndSlash = function(path){ 
    901         if(path.charAt(path.length) != '/' || path.charAt(path.length) != '\\'){ 
    902                 path += "/"; 
    903         } 
    904         return path; 
    905 } 
    906  
    907 buildUtil.readFile = function(/*String*/path, /*String?*/encoding){ 
    908         encoding = encoding || "utf-8"; 
    909         var file = new java.io.File(path); 
    910         var lineSeparator = buildUtil.getLineSeparator(); 
    911         var input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)); 
    912         try { 
    913                 var stringBuffer = new java.lang.StringBuffer(); 
    914                 var line = ""; 
    915                 while((line = input.readLine()) !== null){ 
    916                         stringBuffer.append(line); 
    917                         stringBuffer.append(lineSeparator); 
    918                 } 
    919                 return stringBuffer.toString(); 
    920         } finally { 
    921                 input.close(); 
    922         } 
    923 } 
    924  
    925 buildUtil.saveUtf8File = function(/*String*/fileName, /*String*/fileContents){ 
    926         buildUtil.saveFile(fileName, fileContents, "utf-8"); 
    927 } 
    928  
    929 buildUtil.saveFile = function(/*String*/fileName, /*String*/fileContents, /*String?*/encoding){ 
    930         var outFile = new java.io.File(fileName); 
    931         var outWriter; 
    932         if(encoding){ 
    933                 outWriter = new java.io.OutputStreamWriter(new java.io.FileOutputStream(outFile), encoding); 
    934         }else{ 
    935                 outWriter = new java.io.OutputStreamWriter(new java.io.FileOutputStream(outFile)); 
    936         } 
    937  
    938         var os = new java.io.BufferedWriter(outWriter); 
    939         try{ 
    940                 os.write(fileContents); 
    941         }finally{ 
    942                 os.close(); 
    943         } 
    944 } 
    945  
    946 buildUtil.deleteFile = function(fileName){ 
    947         var file = new java.io.File(fileName); 
    948         if(file.exists()){ 
    949                 file["delete"](); 
    950         } 
     863                        return true; //boolean 
     864                } 
     865        } 
     866        return false; //boolean 
     867} 
     868 
     869buildUtil.convertArrayToObject = function(/*Array*/ary){ 
     870        //summary: converts an array that has String members of "name=value" 
     871        //into an object, where the properties on the object are the names in the array 
     872        //member name/value pairs. 
     873        var result = {}; 
     874        for(var i = 0; i < ary.length; i++){ 
     875                var parts = ary[i].split("="); 
     876                if(parts.length != 2){ 
     877                        throw "Malformed name/value pair: [" + ary[i] + "]. Format should be name=value"; 
     878                } 
     879                result[parts[0]] = parts[1]; 
     880        } 
     881        return result; //Object 
    951882} 
    952883 
     
    974905                                copyrightText += singleLineMatches.join("\r\n"); 
    975906                        } 
    976                         copyrightText += buildUtil.getLineSeparator(); 
     907                        copyrightText += fileUtil.getLineSeparator(); 
    977908                }else{ 
    978909                        copyrightText = copyright; 
     
    1012943buildUtil.stripComments = function(/*String*/startDir, /*boolean*/suppressDojoCopyright){ 
    1013944        //summary: strips the JS comments from all the files in "startDir", and all subdirectories. 
    1014         var copyright = suppressDojoCopyright ? "" : (new String(buildUtil.readFile("copyright.txt")) + buildUtil.getLineSeparator()); 
    1015         var fileList = buildUtil.getFilteredFileList(startDir, /\.js$/, true); 
     945        var copyright = suppressDojoCopyright ? "" : (new String(fileUtil.readFile("copyright.txt")) + fileUtil.getLineSeparator()); 
     946        var fileList = fileUtil.getFilteredFileList(startDir, /\.js$/, true); 
    1016947        if(fileList){ 
    1017948                for(var i = 0; i < fileList.length; i++){ 
     
    1026957                                 
    1027958                                //Read in the file. Make sure we have a JS string. 
    1028                                 var fileContents = new String(buildUtil.readFile(fileList[i])); 
     959                                var fileContents = new String(fileUtil.readFile(fileList[i])); 
    1029960 
    1030961                                //Do comment removal. 
     
    1036967 
    1037968                                //Write out the file with appropriate copyright. 
    1038                                 buildUtil.saveUtf8File(fileList[i], fileContents); 
    1039                         } 
    1040                 } 
    1041         } 
    1042 } 
    1043  
    1044  
     969                                fileUtil.saveUtf8File(fileList[i], fileContents); 
     970                        } 
     971                } 
     972        } 
     973} 
     974 
     975 
  • util/trunk/buildscripts/jslib/convertTestsToXDomain.js

    r7757 r7764  
    55var xdDojoUrl = arguments[1]; 
    66 
     7load("fileUtil.js"); 
    78load("buildUtil.js"); 
    89 
    9 var fileList = buildUtil.getFilteredFileList(startDir, /\.(html|htm)$/, true); 
     10var fileList = fileUtil.getFilteredFileList(startDir, /\.(html|htm)$/, true); 
    1011 
    1112for(var i = 0; i < fileList.length; i++){ 
    1213        var fileName = fileList[i];      
    13         var fileContents = String(buildUtil.readFile(fileName)); 
     14        var fileContents = String(fileUtil.readFile(fileName)); 
    1415        fileContents = fileContents.replace(/src\=\".*dojo.js"/, 'src="' + xdDojoUrl + '"'); 
    15         buildUtil.saveUtf8File(fileName, fileContents); 
     16        fileUtil.saveUtf8File(fileName, fileContents); 
    1617} 
  • util/trunk/buildscripts/makeDojoJs.js

    r7739 r7764  
    11//START of the "main" part of the script. 
    22//This is the entry point for this script file. 
     3load("fileUtil.js"); 
    34load("buildUtil.js"); 
    45 
     
    1213 
    1314//Save the dojo.js contents. It is always the first result. 
    14 buildUtil.saveFile(releaseDir + "/" + dojoFileName, result[0].contents); 
     15fileUtil.saveFile(releaseDir + "/" + dojoFileName, result[0].contents); 
    1516 
    1617//Save the other layers, if there are any. 
    1718for(var i = 1; i < result.length; i++){ 
    18         buildUtil.saveFile(releaseDir + "/" + result[i].layerName, result[i].contents); 
     19        fileUtil.saveFile(releaseDir + "/" + result[i].layerName, result[i].contents); 
    1920} 
    2021 
     
    2627} 
    2728 
    28 buildUtil.saveFile(releaseDir + "/build.txt", buildText); 
     29fileUtil.saveFile(releaseDir + "/build.txt", buildText); 
    2930 
    3031print(buildText); 
  • util/trunk/buildscripts/makeDojoJsWeb.js

    r7739 r7764  
    7575 
    7676                //Add copyright 
    77                 var copyright = new String(buildUtil.readFile("copyright.txt")); 
    78                 var buildNotice = new String(buildUtil.readFile("build_notice.txt")); 
     77                var copyright = new String(fileUtil.readFile("copyright.txt")); 
     78                var buildNotice = new String(fileUtil.readFile("build_notice.txt")); 
    7979                contents = copyright + buildNotice + contents; 
    8080                compressedContents = copyright + buildNotice + compressedContents; 
     
    9393 
    9494                //Save files to disk 
    95                 buildUtil.saveUtf8File(buildCachePath + "dojo.js", contents); 
    96                 buildUtil.saveUtf8File(buildCachePath + "compressed/dojo.js", compressedContents); 
    97                 buildUtil.saveUtf8File(buildCachePath + "build.txt", buildContents); 
     95                fileUtil.saveUtf8File(buildCachePath + "dojo.js", contents); 
     96                fileUtil.saveUtf8File(buildCachePath + "compressed/dojo.js", compressedContents); 
     97                fileUtil.saveUtf8File(buildCachePath + "build.txt", buildContents); 
    9898                 
    9999                result = "OK"; 
  • util/trunk/buildscripts/setXdDojoConfig.js

    r7415 r7764  
    44var xdUrl = arguments[1]; 
    55 
     6load("fileUtil.js"); 
    67load("buildUtil.js"); 
    78load("buildUtilXd.js"); 
    89 
    9 var fileContents = new String(buildUtil.readFile(dojoFile)); 
     10var fileContents = new String(fileUtil.readFile(dojoFile)); 
    1011fileContents = buildUtilXd.setXdDojoConfig(fileContents, xdUrl); 
    11 buildUtil.saveFile(dojoFile, fileContents); 
     12fileUtil.saveFile(dojoFile, fileContents); 
    1213 
    1314 
  • util/trunk/buildscripts/webbuild/makeWebBuildModuleList.js

    r7415 r7764  
    4444dojo.require("dojo.json"); 
    4545 
     46load("../fileUtil.js"); 
    4647load("../buildUtil.js"); 
    4748 
    4849//Get a list of files that might be modules. 
    49 var fileList = buildUtil.getFilteredFileList(srcRoot, /\.js$/, true); 
     50var fileList = fileUtil.getFilteredFileList(srcRoot, /\.js$/, true); 
    5051 
    5152var provideRegExp = /dojo\.provide\(\".*\"\)/g; 
     
    5758for(var i = 0; i < fileList.length; i++){ 
    5859        var fileName = fileList[i]; 
    59         var fileContents = new String(buildUtil.readFile(fileName)); 
     60        var fileContents = new String(fileUtil.readFile(fileName)); 
    6061 
    6162        var matches = fileContents.match(provideRegExp); 
     
    9192 
    9293//Output the results. 
    93 buildUtil.saveFile(outputFileName, "var treeData = " + dojo.json.serialize(treeData) + ";"); 
     94fileUtil.saveFile(outputFileName, "var treeData = " + dojo.json.serialize(treeData) + ";"); 
    9495 
  • util/trunk/buildscripts/webbuild/webbuild.js

    r7460 r7764  
    77//Define some methods that are defined in Rhino, but we need web equivalents 
    88//in order for the build scripts to work. 
    9 buildUtil.readFile = readText = readFile = function(uri){ 
     9fileUtil.readFile = readText = readFile = function(uri){ 
    1010        return dojo.hostenv.getText(uri); 
    1111} 
     
    1616 
    1717//Define some overrides for the buildUtil functions. 
    18 buildUtil.getLineSeparator = function(){ 
     18fileUtil.getLineSeparator = function(){ 
    1919        //summary: Gives the line separator for the platform. 
    2020        //For web builds override this function. 
  • util/trunk/buildscripts/xdgen.js

    r6717 r7764  
    77        var jsFileNames = []; 
    88        for(var i = 0; i < srcDirs.length; i++){ 
    9                 var fileList = buildUtil.getFilteredFileList(srcDirs[i].prefixPath, filePathRegExp, true); 
     9                var fileList = fileUtil.getFilteredFileList(srcDirs[i].prefixPath, filePathRegExp, true); 
    1010                if(fileList){ 
    1111                        for(var j = 0; j < fileList.length; j++){ 
     
    3636 
    3737//Find the bundles that need to be flattened. 
     38load("fileUtil.js"); 
    3839load("buildUtil.js"); 
    3940 
     
    4546//Any other arguments to this file are directories to search. 
    4647for(var i = 3; i < arguments.length; i++){ 
     48xxx broken 
    4749        srcDirs.push({prefix: "dojo", prefixPath: arguments[i]}); 
    4850} 
     
    7577                        var xdContents = buildUtilXd.makeXdContents(readText(jsFileName), djConfig.baseRelativePath, prefixes); 
    7678                } 
    77                 buildUtil.saveUtf8File(xdFileName, xdContents); 
     79                fileUtil.saveUtf8File(xdFileName, xdContents); 
    7880        } 
    7981}else if(action == "xdremove"){ 
     
    8385        //Run makeXdContents on each file and save the XD file contents to a xd.js file. 
    8486        for(j = 0; j < jsFileNames.length; j++){ 
    85                 buildUtil.deleteFile(jsFileNames[j].path); 
     87                fileUtil.deleteFile(jsFileNames[j].path); 
    8688        } 
    8789}