debug/log changes
[app.Builder.js] / gtkrun.js
1 #!/usr/bin/seed
2 //<Script type="text/javascript">
3 /**
4  * runtime file
5  * takes a gtk project directory, and turns it into an application!
6  * by compling the files into JS files..
7  * 
8  * Initially developed for runtime testing. (the vte runner)
9  * 
10  * Might be the way to go for full runtime 
11  * 
12  * 
13  * Usage
14  * gtkrun.js /path/to/myproject
15  * 
16  * Concepts.. 
17  * a) load dependancies.. (eg. gi's..) - derived later?
18  * Gtk.init()
19  * 
20  * loop the files (find .bjs)
21  *   - comple to js (if not exist // or force enabled..)
22  * b) load all the files
23  * 
24  * Gtk.main();
25  * 
26  */
27 // autogen?
28
29 // sort out import path!!!
30  
31  
32 Gtk         = imports.gi.Gtk;
33 Gdk         = imports.gi.Gdk;
34 Pango       = imports.gi.Pango;
35 GLib        = imports.gi.GLib;
36 Gio         = imports.gi.Gio;
37 GObject     = imports.gi.GObject;
38 GtkSource   = imports.gi.GtkSource;
39 WebKit      = imports.gi.WebKit;
40 Vte         = imports.gi.Vte;
41
42 GtkClutter  = imports.gi.GtkClutter;
43
44 if (GtkClutter) {    
45     GtkClutter.init(Seed.argv);
46 }
47
48 File    = imports.File.File;
49
50 XObject = imports.XObject.XObject;
51 //XObject.debug = true;
52 Gtk.init(Seed.argv);
53
54
55 imports.searchPath.push('/'); // allow global paths..
56 // error checking todo..
57 var files = File.list(Seed.argv[2]);
58 var olist = [];
59
60 var gtkbuilder = false;
61 files.forEach(function(f) {
62     var fp = Seed.argv[2] + '/' + f;
63     if (!fp.match(/\.bjs$/)) {
64         return;
65     }
66     var js = fp.replace(/\.bjs$/, '.js');
67     if (File.isFile(js)) {
68         // check file time.. = bjs is less than compiled file..
69         if (File.mtime(fp) < File.mtime(js)) {
70             XObject.log("LOADING" + js);
71             olist.push(imports[js]);
72             return;
73         }
74         
75         
76     }
77     var gtkbuilder =  new imports.Builder.Provider.File.Gtk.Gtk({ path : fp });
78     gtkbuilder.loadItems(function() { });
79     XObject.log("COMPILING" + js);
80     var fn = gtkbuilder.saveJS();
81     if (fn === false) { // skip files that do not contain anythng!
82         return;
83     }
84     olist.push(imports[fn]);
85     
86     
87 });
88
89
90
91           
92 Gtk.main();
93