3 only one queue exists for the whole program
7 public class ValaCompileQueue : Object
10 ValaCompileRequest? next_request = null;
11 ValaCompileRequest? cur_request = null;
12 ValaCompileRequest? last_request = null;
17 int countdown_start = 5;
20 uint countdown_running = 0;
26 public ValaCompileQueue()
28 //start timeout for compiler.
32 public void addFile( ValaCompileRequestType reqtype, JsRender.JsRender file , string alt_code, bool force)
34 var add = new ValaCompileRequest(
43 if (file.project.xtype == "Gtk" && file.targetName().has_suffix(".vala")) {
46 this.add(add , force);
48 if (file.project.xtype == "Roo" && file.targetName().has_suffix(".js")) {
49 this.next_request = null;
50 this.cur_request = add;
51 add.runJavascript(this);
56 public void addProp( ValaCompileRequestType requestType,
57 JsRender.JsRender file,
59 JsRender.NodeProp prop,
63 if (prop.name == "xns" || prop.name == "xtype") {
66 var add = new ValaCompileRequest(
74 if (file.project.xtype == "Gtk") {
75 this.add(add , false); // delayed?
77 if (file.project.xtype == "Roo" ) {
78 this.next_request = null;
79 this.cur_request = add;
80 add.runJavascript(this);
83 void add(ValaCompileRequest req, bool force)
85 GLib.debug("Add compile request to queue %s", req.file.path);
86 if (this.next_request != null && this.next_request.eq(req)) {
87 this.countdown = this.last_request == null || force ? 1 : this.countdown_start;
89 if (this.countdown_running < 1) {
90 this.startCountdown();
94 if (this.cur_request != null && this.cur_request.eq(req)) { // ingore
95 GLib.debug("Ingore - its' running Add compile request to queue %s", req.file.path);
98 if (this.last_request != null && this.last_request.eq(req)) { // ingore
99 GLib.debug("Ingore - its same as last request %s", req.file.path);
102 this.next_request = req;
103 // quick if no previous
104 this.countdown = this.last_request == null || force ? 1 : this.countdown_start;
105 if (this.countdown_running < 1) {
106 this.startCountdown();
111 public void startCountdown()
113 this.countdown_running = GLib.Timeout.add_seconds(1, () => {
114 if (this.next_request == null && this.cur_request == null) {
115 this.countdown_running = 0;
120 if (this.cur_request == null) {
123 if (this.cur_request != null) {
126 GLib.debug("Timeout running %d", this.timeout);
127 if (this.timeout < 1) {
128 GLib.debug("Timeout canceling %s", this.cur_request.file.path);
129 this.cur_request.cancel();
130 this.cur_request = null;
134 if (this.countdown < 1) {
136 this.countdown_running = 0;
140 return true; // keep going.
147 // called on each tick/timeout
148 // not called if compiler is running..
152 var req = this.next_request;
153 this.next_request = null;
154 this.cur_request = req;
157 if (!req.run(this)) {
158 GLib.debug("run failed- give up on this one - should we show a problem??");
159 this.onCompileFail();
162 this.showSpinner(true);
166 public void onCompileFail()
168 this.cur_request = null;
169 this.showSpinner(false);
172 public void onCompileComplete(ValaCompileRequest req)
174 this.cur_request = null;
175 req.file.project.last_request = req; // technically it should update compile group.
176 this.last_request = req;
177 this.showSpinner(false);
179 BuilderApplication.updateCompileResults();
182 public void onCompilerOutput( string str )
184 // send output to all windows (of this project?)
187 public void showSpinner(bool state)
189 foreach (var win in BuilderApplication.windows) {
191 win.statusbar_compile_spinner.start();
193 win.statusbar_compile_spinner.stop();
198 // handle execution of result..-------
200 public void killChildren(int pid)
205 var cn = "/proc/%d/task/%d/children".printf(pid,pid);
206 if (!FileUtils.test(cn, GLib.FileTest.EXISTS)) {
207 GLib.debug("%s doesnt exist - killing %d", cn, pid);
213 FileUtils.get_contents(cn, out cpids);
216 if (cpids.length > 0) {
217 this.killChildren(int.parse(cpids));
220 } catch (GLib.FileError e) {
223 GLib.debug("killing %d", pid);
228 public void execResult(ValaCompileRequest req)
231 this.killChildren(this.terminal_pid);
232 this.terminal_pid = 0;
234 var exe = req.target();
235 var pr = (Project.Gtk) req.file.project;
236 var cg = pr.compilegroups.get(exe);
238 if (!GLib.FileUtils.test(exe, GLib.FileTest.EXISTS)) {
239 print("Missing output file: %s\n",exe);
242 var gdb_cfg= pr.path + "/build/.gdb-script";
243 if (!GLib.FileUtils.test(gdb_cfg, GLib.FileTest.EXISTS)) {
244 pr.writeFile("build/.gdb-script", "set debuginfod enabled off\nr");
249 string[] args = "/usr/bin/gnome-terminal --disable-factory --wait -- /usr/bin/gdb -x".split(" ");
254 if (cg.execute_args.length > 0) {
256 var aa = cg.execute_args.split(" ");
257 for (var i =0; i < aa.length; i++) {
264 // should be home directory...
269 var exec = new Spawn(pr.path , args);
270 exec.env = GLib.Environ.get();
275 this.terminal_pid = exec.pid;
276 GLib.debug("Child PID = %d", this.terminal_pid);
278 } catch(GLib.Error e) {
279 GLib.debug("Failed to spawn: %s", e.message);