Changeset 20

Show
Ignore:
Timestamp:
11/16/05 14:10:33 (3 years ago)
Author:
Jan-Klaas Kollhof
Message:

changed core file to allow the build script to update the moduleSearchURIs, fixed new line handling in lang module, updated build script.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • jsolait/trunk/jsolait/jsolait.js

    r19 r20  
    372372             
    373373    ///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*/     
    386389     
    387390    ///The base URIs to search for modules in. They may contain StringFormating symbols e.g '%(baseURI)s/lib' 
    388391    mod.moduleSearchURIs = [".", "%(baseURI)s/lib"]; 
    389      
     392        
    390393    ///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*/ 
    392398     
    393399    /** 
  • jsolait/trunk/jsolait/lib/lang.js

    r13 r20  
    5050        var p = s.search(/\n/); 
    5151        if(p>=0){ 
    52             return s.slice(0,p+1); 
     52            return s.slice(0,p); 
    5353        }else{ 
    5454            return s; 
  • jsolait/trunk/tools/build.js

    r10 r20  
    11Module("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'); 
    211     
    312    var fs= new ActiveXObject("Scripting.FileSystemObject"); 
    413    var wshShell= new ActiveXObject("WScript.Shell"); 
    514    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]); 
    818     
    919     
    1020    mod.parse = function(file){ 
    1121        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         
    1430        try{ 
    1531            p.parseStatements(p.next()); 
     
    1834            throw file.Path + '(' + (l[0] ) + ',' +l[1] + ') ' +   e + ' near:\n' + p._working.slice(0,200); 
    1935        }  
    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    }; 
    2173     
    22     mod.compressFile=function(file, out){ 
    23         var s=file.OpenAsTextStream(ForReading).readAll(); 
     74    mod.compressFile=function(s, out){ 
    2475        var c =new lang.Compressor(s); 
    2576        var tkn; 
     
    2980        } 
    3081        out.close(); 
    31     } 
     82    }; 
    3283     
    3384    mod.buildFile = function(src, dest){ 
    3485        print("parsing", src); 
    35         mod.parse(src); 
     86        var s= mod.parse(src); 
    3687        print("compressing", src, '->', dest.Path); 
    37         mod.compressFile(src, dest);         
    38     }     
     88        mod.compressFile(s, dest);         
     89    }    ; 
    3990     
    4091    mod.buildDir = function(src, dest){ 
     
    67118 
    68119 
    69     } 
     120    }; 
    70121     
    71122     
     
    73124        this.gn = new lang.GlobalNode(); 
    74125        try{ 
    75             fs.createFolder('../build/jsolait'); 
     126            fs.createFolder(mod.buildPath); 
    76127        }catch(e){ 
    77128         
    78129        } 
     130                        
    79131         
    80         mod.buildDir(fs.getFolder('../jsolait/'), fs.getFolder('../build/jsolait')); 
     132        mod.buildDir(fs.getFolder(mod.sourcePath), fs.getFolder(mod.buildPath)); 
    81133        try{ 
    82             fs.createFolder('../build/doc'); 
     134            fs.createFolder(mod.docPath); 
    83135        }catch(e){ 
    84136        } 
    85137         
    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); 
    87139        dp.printGlobalNode(this.gn); 
    88140     
    89     } 
    90 }) 
     141    }; 
     142});