JSDOC/Packer.js
[gnome.introspection-doc-generator] / JSDOC / Packer.js
index f7a3246..172374b 100644 (file)
@@ -2,7 +2,7 @@
 XObject         = imports.XObject.XObject;
 File            = imports.File.File;
 
-TextStream      = imports.TextStream.TextStream;
+TextStream      = imports.JSDOC.TextStream.TextStream ;
 TokenReader     = imports.TokenReader.TokenReader;
 ScopeParser     = imports.ScopeParser.ScopeParser;
 TokenStream     = imports.TokenStream.TokenStream;
@@ -28,6 +28,7 @@ var x = new  Packer({
     files : [ "/location/of/file1.js", "/location/of/file2.js", ... ],
     target : "/tmp/output.js",
     debugTarget : "/tmp/output.debug.js", // merged file without compression.
+    debugTranslateTarget : "/tmp/output.translate.js", // merged with translation
     translateJSON: "/tmp/translate.json",
     
     
@@ -86,15 +87,30 @@ Packer = function(cfg)
     
     var link = false;
     if (cfg.autoBuild) {
+        
+        function dateString(d){
+            function pad(n){return n<10 ? '0'+n : n}
+            return d.getFullYear() +
+                 pad(d.getMonth()+1)+
+                 pad(d.getDate())+'_'+
+                 pad(d.getHours())+
+                 pad(d.getMinutes())+
+                 pad(d.getSeconds());
+        }
+
+        
+        
         var version = 0;
         this.files.forEach(function(f) {
             version = Math.max(File.mtime(f), version);
         });
+        var version  = dateString(new Date(version));
+        
         var dirname = GLib.path_get_dirname(this.files[0]);
         var outname = this.module ? this.module : GLib.path_get_basename(dirname);
         this.target = dirname + '/compiled/' + outname + '-' + version + '.js';
          if (File.exists(this.target)) {
-            print("Target file already exists");
+            print("Target file already exists: " + this.target);
             Seed.quit();
         }
         this.prefix = dirname +'/';
@@ -218,6 +234,8 @@ Packer.prototype = {
                 continue;
             }
            
+            // debug Target
+            
             if (this.debugTarget) {
                 File.append(this.debugTarget, File.read(file));
             }
@@ -239,16 +257,7 @@ Packer.prototype = {
                 print("compare : " + mt + "=>" + ot);
                 if (mt >= ot) {
                     continue;
-                    /*
-                    // then the min'files time is > than original..
-                    var str = File.read(minfile);
-                    print("using MIN FILE  "+ minfile);
-                    if (str.length) {
-                        File.append(outpath, str + "\n");
-                    }
                     
-                    continue;
-                    */
                 }
                 
             }
@@ -338,6 +347,8 @@ Packer.prototype = {
             }
             
         }
+        print("Output file: " + this.target);
+        if (this.debugTarget) print("Output debug file: " + this.debugTarget);
         
          
     
@@ -360,7 +371,8 @@ Packer.prototype = {
             keepWhite : true,  
             keepComments : true, 
             sepIdents : true,
-            collapseWhite : false
+            collapseWhite : false,
+            filename : fn
         });
         this.timerPrint("START" + fn);
         
@@ -396,6 +408,7 @@ Packer.prototype = {
         
         var out = CompressWhite(new TokenStream(toks), this, this.keepWhite); // do not kill whitespace..
         
+        
         this.timerPrint("Compressed");
         return out;