dbgenerate.js
[app.Builder.js] / gtkrun.js
index 5d0dd81..696c39d 100644 (file)
--- a/gtkrun.js
+++ b/gtkrun.js
@@ -1,4 +1,4 @@
-#!/usr/bin/seed
+#!/usr/bin/seed 
 //<Script type="text/javascript">
 /**
  * runtime file
@@ -10,8 +10,8 @@
  * Might be the way to go for full runtime 
  * 
  * 
- * Usage
- * gtkrun.js /path/to/myproject
+ * Usage: (call with wrapper to set up directories..)
+ *    sh builder.sh
  * 
  * Concepts.. 
  * a) load dependancies.. (eg. gi's..) - derived later?
  * 
  */
 // autogen?
-Gtk = imports.gi.Gtk;
-Gdk = imports.gi.Gdk;
-Pango = imports.gi.Pango;
-GLib = imports.gi.GLib;
-Gio = imports.gi.Gio;
-GObject = imports.gi.GObject;
-GtkSource = imports.gi.GtkSource;
-WebKit = imports.gi.WebKit;
-Vte = imports.gi.Vte;
 
-File = imports.File.File;
+// sort out import path - this is  a bit of a mess..
+GIRepository = imports.gi.GIRepository;
+GLib        = imports.gi.GLib;
+
+// we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
+GIRepository.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
+//print(JSON.stringify(GIRepository.IRepository.get_search_path()));
+
+Gtk         = imports.gi.Gtk;
+Gdk         = imports.gi.Gdk;
+Pango       = imports.gi.Pango;
+
+Gio         = imports.gi.Gio;
+GObject     = imports.gi.GObject;
+GtkSource   = imports.gi.GtkSource;
+WebKit      = imports.gi.WebKit;
+Vte         = imports.gi.Vte;
+
+////Gdl         = imports.gi.Gdl;
+
+//GtkClutter  = imports.gi.GtkClutter;
 
+//if (GtkClutter) {    
+//    GtkClutter.init(Seed.argv);
+//}
+
+File    = imports.File.File;
+
+XObject = imports.XObject.XObject;
+//XObject.debug = true;
 Gtk.init(Seed.argv);
 
+
+imports.searchPath.push('/'); // allow global paths..
 // error checking todo..
 var files = File.list(Seed.argv[2]);
 var olist = [];
@@ -50,14 +70,20 @@ files.forEach(function(f) {
     if (!fp.match(/\.bjs$/)) {
         return;
     }
-    if (File.isFile(fp.replace(/\.bjs$/, '.js'))) {
-        // check file time..
+    var js = fp.replace(/\.bjs$/, '.js');
+    if (File.isFile(js)) {
+        // check file time.. = bjs is less than compiled file..
+        if (File.mtime(fp) < File.mtime(js)) {
+            XObject.log("LOADING" + js);
+            olist.push(imports[js]);
+            return;
+        }
+        
         
-        olist.push(imports[fp.replace(/\.bjs$/, '.js')]);
-        return;
     }
     var gtkbuilder =  new imports.Builder.Provider.File.Gtk.Gtk({ path : fp });
     gtkbuilder.loadItems(function() { });
+    XObject.log("COMPILING" + js);
     var fn = gtkbuilder.saveJS();
     if (fn === false) { // skip files that do not contain anythng!
         return;
@@ -71,4 +97,4 @@ files.forEach(function(f) {
 
           
 Gtk.main();
\ No newline at end of file