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     
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     if (BuilderApplication.opt_bjs_compile != null) {
25                  
26                 //BuilderApplication.compileBjs();
27         print("compile BJS comming soon");
28                 
29                 GLib.Process.exit(Posix.EXIT_SUCCESS);
30         }
31         if (BuilderApplication.opt_list_projects) {
32                  
33                 //BuilderApplication.compileBjs();
34         Project.Project.loadAll();
35                 print("Projects\n %s\n", Project.Project.listAllToString());
36                 GLib.Process.exit(Posix.EXIT_SUCCESS);
37         }
38     Project.Project.loadAll();
39     
40     if (BuilderApplication.opt_list_projects) {
41                  
42                 //BuilderApplication.compileBjs();
43
44                 print("Projects\n %s\n", Project.Project.listAllToString());
45                 GLib.Process.exit(Posix.EXIT_SUCCESS);
46         }
47         Project.Project cur_project = null;
48     if (BuilderApplication.opt_compile_project != null) {
49                  
50                  
51                 cur_project = Project.Project.getProjectByHash( BuilderApplication.opt_compile_project);
52                 
53                 if (cur_project == null) {
54                         GLib.error("invalid project %s, use --list-projects to show project ids",BuilderApplication.opt_compile_project);
55                 }
56                 
57         }
58         
59         if (BuilderApplication.opt_list_files) {
60                 if (cur_project == null) {
61                         GLib.error("missing project, use --project to select which project");
62                 }
63                 print("Files for %s\n %s\n", cur_project.name, cur_project.listAllFilesToString());
64                 GLib.Process.exit(Posix.EXIT_SUCCESS);
65         }
66     
67     if (BuilderApplication.opt_bjs_compile != null) {
68                 if (cur_project == null) {
69                         GLib.error("missing project, use --project to select which project");
70                 }       
71                 var file = cur_project.getByName(BuilderApplication.opt_bjs_compile);
72                 if (file == null) {
73                         GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
74                 }
75                 //BuilderApplication.compileBjs();
76         print(cur_project.toSource());
77                 
78                 GLib.Process.exit(Posix.EXIT_SUCCESS);
79         }
80         
81     
82         if (BuilderApplication.opt_compile_target != null) {
83                  
84                 Palete.ValaSourceCompiler.buildApplication();
85                 
86                 GLib.Process.exit(Posix.EXIT_SUCCESS);
87         }
88         
89          
90         
91         GLib.debug("project = %s\n", BuilderApplication.opt_compile_project);
92         
93         Gtk.init (ref args);
94          
95         GtkClutter.init (ref args);
96         new JsRender.Lang_Class();
97         GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
98         
99     
100     
101     // respond to other arguments
102     
103         /*var proj = Project.Project.getProject("Pman.Core");
104         if (proj == null) {
105                 print("could not load test project Pman.Core");
106                 return 0;
107         }
108         proj.scanDirs();
109         */
110
111         var w = Xcls_MainWindow.singleton();
112         //w.ref();
113         //w.project = proj;
114         
115         w.el.show_all();
116         // it looks like showall after children causes segfault on ubuntu 14.4
117         w.initChildren();
118         w.windowstate.switchState(WindowState.State.FILES);
119         
120         Gtk.main();
121     app = null;
122         
123         return 0;
124 }