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      
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                 
51         }
52         
53         if (BuilderApplication.opt_list_files) {
54                 if (cur_project == null) {
55                         GLib.error("missing project, use --project to select which project");
56                 }
57                 print("Files for %s\n %s\n", cur_project.name, cur_project.listAllFilesToString());
58                 GLib.Process.exit(Posix.EXIT_SUCCESS);
59         }
60     
61     if (BuilderApplication.opt_bjs_compile != null) {
62                 if (cur_project == null) {
63                         GLib.error("missing project, use --project to select which project");
64                 }       
65                 var file = cur_project.getByName(BuilderApplication.opt_bjs_compile);
66                 if (file == null) {
67                         GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
68                 }
69                 //BuilderApplication.compileBjs();
70         print(file.toSourceCode());
71                 
72                 GLib.Process.exit(Posix.EXIT_SUCCESS);
73         }
74         
75     
76         if (BuilderApplication.opt_compile_target != null) {
77                  
78                 Palete.ValaSourceCompiler.buildApplication();
79                 
80                 GLib.Process.exit(Posix.EXIT_SUCCESS);
81         }
82         
83          
84         
85         GLib.debug("project = %s\n", BuilderApplication.opt_compile_project);
86         
87         Gtk.init (ref args);
88          
89         GtkClutter.init (ref args);
90         new JsRender.Lang_Class();
91         GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
92         
93     
94     
95     // respond to other arguments
96     
97         /*var proj = Project.Project.getProject("Pman.Core");
98         if (proj == null) {
99                 print("could not load test project Pman.Core");
100                 return 0;
101         }
102         proj.scanDirs();
103         */
104
105         var w = Xcls_MainWindow.singleton();
106         //w.ref();
107         //w.project = proj;
108         
109         w.el.show_all();
110         // it looks like showall after children causes segfault on ubuntu 14.4
111         w.initChildren();
112         w.windowstate.switchState(WindowState.State.FILES);
113         
114         Gtk.main();
115     app = null;
116         
117         return 0;
118 }