Changeset 7764
- Timestamp:
- 03/22/07 18:06:52 (16 months ago)
- Location:
- util/trunk/buildscripts
- Files:
-
- 3 added
- 1 removed
- 10 modified
-
build.js (added)
-
buildUtil.test.js (deleted)
-
cldr/cldrArrayInherit.js (modified) (2 diffs)
-
flattenResources.js (modified) (3 diffs)
-
jslib/buildUtil.js (modified) (14 diffs)
-
jslib/convertTestsToXDomain.js (modified) (1 diff)
-
jslib/fileUtil.js (added)
-
jslib/logger.js (added)
-
makeDojoJs.js (modified) (3 diffs)
-
makeDojoJsWeb.js (modified) (2 diffs)
-
setXdDojoConfig.js (modified) (1 diff)
-
webbuild/makeWebBuildModuleList.js (modified) (3 diffs)
-
webbuild/webbuild.js (modified) (2 diffs)
-
xdgen.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
util/trunk/buildscripts/cldr/cldrArrayInherit.js
r7760 r7764 44 44 dojo.require("dojo.json"); 45 45 46 load("fileUtil.js"); 46 47 load("buildUtil.js"); 47 48 48 49 // 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);50 var fileList = fileUtil.getFilteredFileList(dir, /\/gregorian\.js$/, true); 50 51 51 52 for(var i= 0; i < fileList.length; i++){ … … 100 101 }); 101 102 if(hasChanged){ 102 buildUtil.saveUtf8File(jsFileName, dojo.json.serialize(data));103 fileUtil.saveUtf8File(jsFileName, dojo.json.serialize(data)); 103 104 } 104 105 } -
util/trunk/buildscripts/flattenResources.js
r6717 r7764 33 33 dojo.require("dojo.i18n.common"); 34 34 dojo.require("dojo.json"); 35 load("fileUtil.js"); 35 36 load("buildUtil.js"); 36 37 … … 94 95 //Flatten all bundles and modifying dojo.requireLocalization calls. 95 96 var prefixes = buildUtil.configPrefixes(profileFile); 96 var fileList = buildUtil.getFilteredFileList(releaseDir + "/src", /\.js$/, true);97 var fileList = fileUtil.getFilteredFileList(releaseDir + "/src", /\.js$/, true); 97 98 98 99 for(var i= 0; i < fileList.length; i++){ … … 110 111 111 112 if(fileContents){ 112 buildUtil.saveUtf8File(jsFileName, fileContents);113 fileUtil.saveUtf8File(jsFileName, fileContents); 113 114 } 114 115 } -
util/trunk/buildscripts/jslib/buildUtil.js
r7755 r7764 1 1 var 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 }8 2 9 3 buildUtil.getDojoLoader = function(/*Object?*/dependencies){ … … 288 282 var dependencies = null; 289 283 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. 293 287 profileText = profileText.replace(/load\(("|')getDependencyList.js("|')\)/, ""); 294 288 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 295 300 return { 296 301 dependencies: dependencies, … … 318 323 for(var i = 0; i < depList.length; i++){ 319 324 //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"; 321 326 } 322 327 … … 324 329 if(dojoContents.match(buildUtil.globalRequireLocalizationRegExp)){ 325 330 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])); 327 332 } 328 333 … … 387 392 //returned from buildUtil.getDependencyList() 388 393 389 var lineSeparator = buildUtil.getLineSeparator();394 var lineSeparator = fileUtil.getLineSeparator(); 390 395 391 396 //Cycle through the layers to create the content for each layer. … … 552 557 553 558 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); 555 560 556 561 //Find the list of locales supported by looking at the path names. … … 744 749 //Make sure dojo is in the list. 745 750 var dojoPath = releaseDir.replace(/^.*(\/|\\)release(\/|\\)/, "release/"); 746 prefixes.push(["dojo", dojoPath + "/src"]);747 751 748 752 var skiplist = dependencies["internSkipList"] || []; … … 760 764 761 765 //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", 763 767 /\.js$/, true); 764 768 … … 773 777 var resourceContent = new String(readText(resourceFile)); 774 778 resourceContent = buildUtil.interningRegexpMagic(loader, resourceContent, srcRoot, prefixes, skiplist); 775 buildUtil.saveUtf8File(resourceFile, resourceContent);779 fileUtil.saveUtf8File(resourceFile, resourceContent); 776 780 } 777 781 … … 852 856 } 853 857 854 buildUtil.isValueInArray = function(value, ary){ 858 buildUtil.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. 855 861 for(var i = 0; i < ary.length; i++){ 856 862 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 869 buildUtil.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 951 882 } 952 883 … … 974 905 copyrightText += singleLineMatches.join("\r\n"); 975 906 } 976 copyrightText += buildUtil.getLineSeparator();907 copyrightText += fileUtil.getLineSeparator(); 977 908 }else{ 978 909 copyrightText = copyright; … … 1012 943 buildUtil.stripComments = function(/*String*/startDir, /*boolean*/suppressDojoCopyright){ 1013 944 //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); 1016 947 if(fileList){ 1017 948 for(var i = 0; i < fileList.length; i++){ … … 1026 957 1027 958 //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])); 1029 960 1030 961 //Do comment removal. … … 1036 967 1037 968 //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 5 5 var xdDojoUrl = arguments[1]; 6 6 7 load("fileUtil.js"); 7 8 load("buildUtil.js"); 8 9 9 var fileList = buildUtil.getFilteredFileList(startDir, /\.(html|htm)$/, true);10 var fileList = fileUtil.getFilteredFileList(startDir, /\.(html|htm)$/, true); 10 11 11 12 for(var i = 0; i < fileList.length; i++){ 12 13 var fileName = fileList[i]; 13 var fileContents = String( buildUtil.readFile(fileName));14 var fileContents = String(fileUtil.readFile(fileName)); 14 15 fileContents = fileContents.replace(/src\=\".*dojo.js"/, 'src="' + xdDojoUrl + '"'); 15 buildUtil.saveUtf8File(fileName, fileContents);16 fileUtil.saveUtf8File(fileName, fileContents); 16 17 } -
util/trunk/buildscripts/makeDojoJs.js
r7739 r7764 1 1 //START of the "main" part of the script. 2 2 //This is the entry point for this script file. 3 load("fileUtil.js"); 3 4 load("buildUtil.js"); 4 5 … … 12 13 13 14 //Save the dojo.js contents. It is always the first result. 14 buildUtil.saveFile(releaseDir + "/" + dojoFileName, result[0].contents);15 fileUtil.saveFile(releaseDir + "/" + dojoFileName, result[0].contents); 15 16 16 17 //Save the other layers, if there are any. 17 18 for(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); 19 20 } 20 21 … … 26 27 } 27 28 28 buildUtil.saveFile(releaseDir + "/build.txt", buildText);29 fileUtil.saveFile(releaseDir + "/build.txt", buildText); 29 30 30 31 print(buildText); -
util/trunk/buildscripts/makeDojoJsWeb.js
r7739 r7764 75 75 76 76 //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")); 79 79 contents = copyright + buildNotice + contents; 80 80 compressedContents = copyright + buildNotice + compressedContents; … … 93 93 94 94 //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); 98 98 99 99 result = "OK"; -
util/trunk/buildscripts/setXdDojoConfig.js
r7415 r7764 4 4 var xdUrl = arguments[1]; 5 5 6 load("fileUtil.js"); 6 7 load("buildUtil.js"); 7 8 load("buildUtilXd.js"); 8 9 9 var fileContents = new String( buildUtil.readFile(dojoFile));10 var fileContents = new String(fileUtil.readFile(dojoFile)); 10 11 fileContents = buildUtilXd.setXdDojoConfig(fileContents, xdUrl); 11 buildUtil.saveFile(dojoFile, fileContents);12 fileUtil.saveFile(dojoFile, fileContents); 12 13 13 14 -
util/trunk/buildscripts/webbuild/makeWebBuildModuleList.js
r7415 r7764 44 44 dojo.require("dojo.json"); 45 45 46 load("../fileUtil.js"); 46 47 load("../buildUtil.js"); 47 48 48 49 //Get a list of files that might be modules. 49 var fileList = buildUtil.getFilteredFileList(srcRoot, /\.js$/, true);50 var fileList = fileUtil.getFilteredFileList(srcRoot, /\.js$/, true); 50 51 51 52 var provideRegExp = /dojo\.provide\(\".*\"\)/g; … … 57 58 for(var i = 0; i < fileList.length; i++){ 58 59 var fileName = fileList[i]; 59 var fileContents = new String( buildUtil.readFile(fileName));60 var fileContents = new String(fileUtil.readFile(fileName)); 60 61 61 62 var matches = fileContents.match(provideRegExp); … … 91 92 92 93 //Output the results. 93 buildUtil.saveFile(outputFileName, "var treeData = " + dojo.json.serialize(treeData) + ";");94 fileUtil.saveFile(outputFileName, "var treeData = " + dojo.json.serialize(treeData) + ";"); 94 95 -
util/trunk/buildscripts/webbuild/webbuild.js
r7460 r7764 7 7 //Define some methods that are defined in Rhino, but we need web equivalents 8 8 //in order for the build scripts to work. 9 buildUtil.readFile = readText = readFile = function(uri){9 fileUtil.readFile = readText = readFile = function(uri){ 10 10 return dojo.hostenv.getText(uri); 11 11 } … … 16 16 17 17 //Define some overrides for the buildUtil functions. 18 buildUtil.getLineSeparator = function(){18 fileUtil.getLineSeparator = function(){ 19 19 //summary: Gives the line separator for the platform. 20 20 //For web builds override this function. -
util/trunk/buildscripts/xdgen.js
r6717 r7764 7 7 var jsFileNames = []; 8 8 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); 10 10 if(fileList){ 11 11 for(var j = 0; j < fileList.length; j++){ … … 36 36 37 37 //Find the bundles that need to be flattened. 38 load("fileUtil.js"); 38 39 load("buildUtil.js"); 39 40 … … 45 46 //Any other arguments to this file are directories to search. 46 47 for(var i = 3; i < arguments.length; i++){ 48 xxx broken 47 49 srcDirs.push({prefix: "dojo", prefixPath: arguments[i]}); 48 50 } … … 75 77 var xdContents = buildUtilXd.makeXdContents(readText(jsFileName), djConfig.baseRelativePath, prefixes); 76 78 } 77 buildUtil.saveUtf8File(xdFileName, xdContents);79 fileUtil.saveUtf8File(xdFileName, xdContents); 78 80 } 79 81 }else if(action == "xdremove"){ … … 83 85 //Run makeXdContents on each file and save the XD file contents to a xd.js file. 84 86 for(j = 0; j < jsFileNames.length; j++){ 85 buildUtil.deleteFile(jsFileNames[j].path);87 fileUtil.deleteFile(jsFileNames[j].path); 86 88 } 87 89 }