sync
[app.Builder.js] / src / Palete / ValaSource.vala
index 62e59fc..f8d05b2 100644 (file)
@@ -34,10 +34,13 @@ namespace Palete {
                JsRender.JsRender file;
                public int line_offset = 0;
                
+               public Gee.ArrayList<Spawn> children;
                public ValaSource( ) 
                {
                        base();
                        this.compiler = null;
+                       this.children = new Gee.ArrayList<Spawn>();
+                       
                }
                public void dumpCode(string str) 
                {
@@ -194,6 +197,9 @@ namespace Palete {
                         
                }
                
+
+               
+               
                public void spawnExecute(JsRender.JsRender file)
                {
                        // race condition..
@@ -219,8 +225,8 @@ namespace Palete {
                        } else {
                            args += pr.firstBuildModule();
                        }
-                       args += "--output";
-                       args += "/tmp/testrun";
+                       //args += "--output"; -- set up by the module -- defaults to testrun
+                       //args += "/tmp/testrun";
                        
                        // assume code is in home...
                        try {
@@ -228,7 +234,7 @@ namespace Palete {
                            this.compiler.output_line.connect(compile_output_line);
                            this.compiler.complete.connect(runResult);
                            this.compiler.run(); 
-                       
+                               this.children.add(this.compiler); //keep a reference...
                         
                        } catch (GLib.Error e) {
                            GLib.debug(e.message);
@@ -238,7 +244,7 @@ namespace Palete {
                        return;
                         
                }
-               public bool compile_output_line(   string str )
+               public void compile_output_line(   string str )
                {
                        this.compile_output(str);
                }
@@ -360,10 +366,54 @@ namespace Palete {
                public void runResult(int res, string output, string stderr)
                {
                        this.compiler = null;
-                   print("OUT: %s\n\n----\nERR:%s", output, stderr);
-                   var exec = new Spawn("/tmp", { "/tmp/testrun" });
-                   exec.run(); 
+                       var exe = "/tmp/testrun";
+                       var mod = "";
+                       var pr = (Project.Gtk)(this.file.project);
+                       
+                       
+                       
+                       if (this.file.build_module.length > 0 ) {
+                   mod =  this.file.build_module;
+                       } else {
+                           mod =  pr.firstBuildModule();
+                       }
+                       if (mod.length < 1) {
+                               return;
+                       }
+                       var cg =  pr.compilegroups.get(mod);
+                       if (cg.target_bin.length > 0) {
+                               exe = cg.target_bin;
+                       }
+                       
+                       
+                       if (!GLib.FileUtils.test(exe, GLib.FileTest.EXISTS)) {
+                               print("Missing output file: %s\n",exe);
+                               return;
+                       }
+                       string[] args = "/usr/bin/gnome-terminal -x /usr/bin/gdb -ex=r --args".split(" ");
 
+                       
+                       // runs gnome-terminal, with gdb .. running the application..
+                       // fixme -- need a system/which
+                       
+                       args += exe;
+                       if (cg.execute_args.length > 0) {
+                               var aa = cg.execute_args.split(" ");
+                               for (var i =0; i < aa.length; i++) {
+                                       args += aa[i];
+                               }
+                       }
+
+                   print("OUT: %s\n\n----\nERR:%s\n", output, stderr);
+                   
+                   // should be home directory...
+                   
+                   
+                   
+            var exec = new Spawn(GLib.Environment.get_home_dir() , args);
+            exec.detach = true;
+                   exec.run(); 
+                       
                }
        }