src/Main.vala
[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         var str_ar = str.split("\n");
76         for(var i =0;i<str_ar.length;i++) {
77                 var node = file.tree.lineToNode(i);
78                 print("%d: %s   :  %s", 
79                         i+1, 
80         }
81                 
82                 GLib.Process.exit(Posix.EXIT_SUCCESS);
83         }
84         
85     
86         if (BuilderApplication.opt_compile_target != null) {
87                  
88                 Palete.ValaSourceCompiler.buildApplication();
89                 
90                 GLib.Process.exit(Posix.EXIT_SUCCESS);
91         }
92         
93          
94         
95         GLib.debug("project = %s\n", BuilderApplication.opt_compile_project);
96         
97         Gtk.init (ref args);
98          
99         GtkClutter.init (ref args);
100
101         GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
102         
103     
104     
105     // respond to other arguments
106     
107         /*var proj = Project.Project.getProject("Pman.Core");
108         if (proj == null) {
109                 print("could not load test project Pman.Core");
110                 return 0;
111         }
112         proj.scanDirs();
113         */
114
115         var w = Xcls_MainWindow.singleton();
116         //w.ref();
117         //w.project = proj;
118         
119         w.el.show_all();
120         // it looks like showall after children causes segfault on ubuntu 14.4
121         w.initChildren();
122         w.windowstate.switchState(WindowState.State.FILES);
123         
124         Gtk.main();
125     app = null;
126         
127         return 0;
128 }