public signal void compiled(Json.Object res);
+ public signal void compile_output(string str);
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)
{
return true;
}
+
+
+
+
+ public void spawnExecute(JsRender.JsRender file)
+ {
+ // race condition..
+ if (this.compiler != null) {
+ return;
+ }
+ if (!(file.project is Project.Gtk)) {
+ return;
+ }
+ var pr = (Project.Gtk)(file.project);
+
+
+ this.file = file;
+ this.line_offset = 0;
+
+ string[] args = {};
+ args += BuilderApplication._self;
+ args += "--project";
+ args += this.file.project.fn;
+ args += "--target";
+ if (this.file.build_module.length > 0 ) {
+ args += this.file.build_module;
+ } else {
+ args += pr.firstBuildModule();
+ }
+ //args += "--output"; -- set up by the module -- defaults to testrun
+ //args += "/tmp/testrun";
+
+ // assume code is in home...
+ try {
+ this.compiler = new Spawn( GLib.Environment.get_home_dir(), args);
+ 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);
+ this.compiler = null;
+
+ }
+ return;
+
+ }
+ public void compile_output_line( string str )
+ {
+ this.compile_output(str);
+ }
/**
* Used to compile a non builder file..
*/
{
// race condition..
if (this.compiler != null) {
- return;
+ return false;
}
var pr = (Project.Gtk)(file.project);
if (path == file.path) {
foundit = true;
break;
- }
+ }
}
if (!foundit) {
+ }
+
+ public void runResult(int res, string output, string stderr)
+ {
+ this.compiler = null;
+ 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();
+
}
}