resources/RooUsage.txt
[app.Builder.js] / src / Main.vala
1 /**
2  * Test the writer code...
3
4
5 */
6  
7 int main (string[] args) {
8         
9         
10         
11         
12         new JsRender.Lang_Class();
13
14         var app =  BuilderApplication.singleton(  args);
15         
16         if (BuilderApplication.opt_debug  || BuilderApplication.opt_compile_project == null) {
17                 GLib.Log.set_handler(null, 
18                         GLib.LogLevelFlags.LEVEL_DEBUG | GLib.LogLevelFlags.LEVEL_WARNING, 
19                         (dom, lvl, msg) => {
20                         print("%s: %s\n", dom, msg);
21                 });
22         }
23         
24      
25         if (BuilderApplication.opt_list_projects) {
26                  
27                 //BuilderApplication.compileBjs();
28         Project.Project.loadAll();
29                 print("Projects\n %s\n", Project.Project.listAllToString());
30                 GLib.Process.exit(Posix.EXIT_SUCCESS);
31         }
32     Project.Project.loadAll();
33     
34     if (BuilderApplication.opt_list_projects) {
35                  
36                 //BuilderApplication.compileBjs();
37
38                 print("Projects\n %s\n", Project.Project.listAllToString());
39                 GLib.Process.exit(Posix.EXIT_SUCCESS);
40         }
41         Project.Project cur_project = null;
42     if (BuilderApplication.opt_compile_project != null) {
43                  
44                  
45                 cur_project = Project.Project.getProjectByHash( BuilderApplication.opt_compile_project);
46                 
47                 if (cur_project == null) {
48                         GLib.error("invalid project %s, use --list-projects to show project ids",BuilderApplication.opt_compile_project);
49                 }
50                 cur_project.scanDirs();
51                 
52                 
53         }
54         
55         if (BuilderApplication.opt_list_files) {
56                 if (cur_project == null) {
57                         GLib.error("missing project, use --project to select which project");
58                 }
59                 print("Files for %s\n %s\n", cur_project.name, cur_project.listAllFilesToString());
60                 GLib.Process.exit(Posix.EXIT_SUCCESS);
61         }
62     
63     if (BuilderApplication.opt_bjs_compile != null) {
64                 if (cur_project == null) {
65                         GLib.error("missing project, use --project to select which project");
66                 }       
67                 var file = cur_project.getByName(BuilderApplication.opt_bjs_compile);
68                 if (file == null) {
69                         GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
70                 }
71                 //BuilderApplication.compileBjs();
72                 file.loadItems();
73         var str = file.toSourceCode();
74           
75           
76         if (!BuilderApplication.opt_debug) {
77                 print("%s", str);
78                 GLib.Process.exit(Posix.EXIT_SUCCESS);
79                 }
80                 
81                 // dump the node tree
82                 file.tree.dumpProps();
83                 
84                 
85         var str_ar = str.split("\n");
86         for(var i =0;i<str_ar.length;i++) {
87                 var node = file.tree.lineToNode(i+1);
88                 var prop = node == null ? null : node.lineToProp(i+1);
89                 print("%d: %s   :  %s\n", 
90                         i+1, 
91                         node == null ? "......"  : (prop == null ? "????????" : prop),
92                         str_ar[i]
93                         );
94         }
95                 
96                 GLib.Process.exit(Posix.EXIT_SUCCESS);
97         }
98         
99     
100         if (BuilderApplication.opt_compile_target != null) {
101                  
102                 Palete.ValaSourceCompiler.buildApplication();
103                 
104                 GLib.Process.exit(Posix.EXIT_SUCCESS);
105         }
106         
107          
108         
109         GLib.debug("project = %s\n", BuilderApplication.opt_compile_project);
110         
111         Gtk.init (ref args);
112          
113         GtkClutter.init (ref args);
114
115         GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
116         
117     
118     
119     // respond to other arguments
120     
121         /*var proj = Project.Project.getProject("Pman.Core");
122         if (proj == null) {
123                 print("could not load test project Pman.Core");
124                 return 0;
125         }
126         proj.scanDirs();
127         */
128
129         var w = Xcls_MainWindow.singleton();
130         //w.ref();
131         //w.project = proj;
132         
133         w.el.show_all();
134         // it looks like showall after children causes segfault on ubuntu 14.4
135         w.initChildren();
136         w.windowstate.switchState(WindowState.State.FILES);
137         
138         Gtk.main();
139     app = null;
140         
141         return 0;
142 }