Changeset 20
- Timestamp:
- 11/16/05 14:10:33 (3 years ago)
- Files:
-
- jsolait/trunk/jsolait/jsolait.js (modified) (1 diff)
- jsolait/trunk/jsolait/lib/lang.js (modified) (1 diff)
- jsolait/trunk/tools/build.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jsolait/trunk/jsolait/jsolait.js
r19 r20 372 372 373 373 ///The paths of the modules that come with jsolait. 374 mod.knownModuleURIs={codecs:"%(baseURI)s/lib/codecs.js", 375 crypto:"%(baseURI)s/lib/crypto.js", 376 dom:"%(baseURI)s/lib/dom.js", 377 forms:"%(baseURI)s/lib/forms.js", 378 iter:"%(baseURI)s/lib/iter.js", 379 jsonrpc:"%(baseURI)s/lib/jsonrpc.js", 380 lang:"%(baseURI)s/lib/lang.js", 381 sets:"%(baseURI)s/lib/sets.js", 382 testing:"%(baseURI)s/lib/testing.js", 383 urllib:"%(baseURI)s/lib/urllib.js", 384 xml:"%(baseURI)s/lib/xml.js", 385 xmlrpc:"%(baseURI)s/lib/xmlrpc.js"}; 374 //do not edit the following lines, it will be replaced by the build script 375 /*@moduleURIs begin*/ 376 mod.knownModuleURIs={"codecs":"%(baseURI)s/lib/codecs.js", 377 "crypto":"%(baseURI)s/lib/crypto.js", 378 "dom":"%(baseURI)s/lib/dom.js", 379 "forms":"%(baseURI)s/lib/forms.js", 380 "iter":"%(baseURI)s/lib/iter.js", 381 "jsonrpc":"%(baseURI)s/lib/jsonrpc.js", 382 "lang":"%(baseURI)s/lib/lang.js", 383 "sets":"%(baseURI)s/lib/sets.js", 384 "testing":"%(baseURI)s/lib/testing.js", 385 "urllib":"%(baseURI)s/lib/urllib.js", 386 "xml":"%(baseURI)s/lib/xml.js", 387 "xmlrpc":"%(baseURI)s/lib/xmlrpc.js"}; 388 /*@moduleURIs end*/ 386 389 387 390 ///The base URIs to search for modules in. They may contain StringFormating symbols e.g '%(baseURI)s/lib' 388 391 mod.moduleSearchURIs = [".", "%(baseURI)s/lib"]; 389 392 390 393 ///The location where jsolait is installed. 391 mod.baseURI = "./jsolait"; 394 //do not edit the following lines, it will be replaced by the build script 395 /*@baseURI begin*/ 396 mod.baseURI="./jsolait"; 397 /*@baseURI end*/ 392 398 393 399 /** jsolait/trunk/jsolait/lib/lang.js
r13 r20 50 50 var p = s.search(/\n/); 51 51 if(p>=0){ 52 return s.slice(0,p +1);52 return s.slice(0,p); 53 53 }else{ 54 54 return s; jsolait/trunk/tools/build.js
r10 r20 1 1 Module("build", "0.0.1", function(mod){ 2 3 mod.sourcePath = '../jsolait'; 4 mod.buildPath = '../build/jsolait'; 5 mod.docPath = '../build/doc'; 6 7 mod.jsolaitBaseURI='./jsolait'; 8 mod.libFolders=['lib', 'lib3rdparty']; 9 10 var lang = imprt('lang'); 2 11 3 12 var fs= new ActiveXObject("Scripting.FileSystemObject"); 4 13 var wshShell= new ActiveXObject("WScript.Shell"); 5 14 var ForReading = 1, ForWriting = 2; 6 7 var lang = imprt('lang'); 15 16 var Set = imprt('sets').Set; 17 mod.preprocessFiles=new Set([fs.getFile(fs.buildPath(mod.sourcePath, 'jsolait.js')).Path]); 8 18 9 19 10 20 mod.parse = function(file){ 11 21 var s=file.OpenAsTextStream(ForReading).readAll(); 12 var p = new lang.Parser(s, this.gn); 13 22 23 if(mod.preprocessFiles.contains(file.Path)){ 24 print('preprossessing', file); 25 s=mod.preprocess(s); 26 } 27 28 var p = new lang.Parser(s, mod.gn); 29 14 30 try{ 15 31 p.parseStatements(p.next()); … … 18 34 throw file.Path + '(' + (l[0] ) + ',' +l[1] + ') ' + e + ' near:\n' + p._working.slice(0,200); 19 35 } 20 } 36 37 return s; 38 }; 39 40 mod.preprocess=function(s){ 41 s=s.split(/\/\*@(moduleURIs) begin\*\/((\/\*@\1 end\*\/){0}|.|\n)*\/\*@\1 end\*\//); 42 43 if(s.length>1){ 44 var mods=[]; 45 for(var i=0;i<mod.libFolders.length;i++){ 46 var libFolder = mod.libFolders[i]; 47 try{ 48 var fldr = fs.getFolder(fs.buildPath(mod.sourcePath,libFolder)); 49 }catch(e){ 50 var fldr=null; 51 } 52 if(fldr){ 53 var sfe = new Enumerator(fldr.Files); 54 for (;!sfe.atEnd(); sfe.moveNext()){ 55 var f = sfe.item(); 56 if(f.name.slice(-3) == ".js"){ 57 var modName= f.name.slice(0,-3); 58 mods.push('"' + modName + '":"%(baseURI)s/'+libFolder+'/' + modName + '.js"'); 59 } 60 } 61 } 62 } 63 64 65 modDirs='mod.knownModuleURIs={' + mods.join(',') + '};'; 66 s=s.join(modDirs); 67 }else{ 68 s=s.join("mod.knownModuleURIs={};"); 69 } 70 s=s.replace(/\/\*@(baseURI) begin\*\/((\/\*@\1 end\*\/){0}|.|\n)*\/\*@\1 end\*\//, 'mod.baseURI="' + mod.jsolaitBaseURI + '";'); 71 return s; 72 }; 21 73 22 mod.compressFile=function(file, out){ 23 var s=file.OpenAsTextStream(ForReading).readAll(); 74 mod.compressFile=function(s, out){ 24 75 var c =new lang.Compressor(s); 25 76 var tkn; … … 29 80 } 30 81 out.close(); 31 } 82 }; 32 83 33 84 mod.buildFile = function(src, dest){ 34 85 print("parsing", src); 35 mod.parse(src);86 var s= mod.parse(src); 36 87 print("compressing", src, '->', dest.Path); 37 mod.compressFile(s rc, dest);38 } 88 mod.compressFile(s, dest); 89 } ; 39 90 40 91 mod.buildDir = function(src, dest){ … … 67 118 68 119 69 } 120 }; 70 121 71 122 … … 73 124 this.gn = new lang.GlobalNode(); 74 125 try{ 75 fs.createFolder( '../build/jsolait');126 fs.createFolder(mod.buildPath); 76 127 }catch(e){ 77 128 78 129 } 130 79 131 80 mod.buildDir(fs.getFolder( '../jsolait/'), fs.getFolder('../build/jsolait'));132 mod.buildDir(fs.getFolder(mod.sourcePath), fs.getFolder(mod.buildPath)); 81 133 try{ 82 fs.createFolder( '../build/doc');134 fs.createFolder(mod.docPath); 83 135 }catch(e){ 84 136 } 85 137 86 var dp = new lang.DocParser(fs.createTextFile(fs.buildPath( '../build/doc', 'doc.xml')), true);138 var dp = new lang.DocParser(fs.createTextFile(fs.buildPath(mod.docPath, 'doc.xml')), true); 87 139 dp.printGlobalNode(this.gn); 88 140 89 } 90 }) 141 }; 142 });
