sync
[app.Builder.js] / src / Project / Gtk.vala
index 6f803c5..bca1667 100644 (file)
@@ -33,7 +33,11 @@ namespace Project {
                        this.xtype = "Gtk";
                        var gid = "project-gtk-%d".printf(gtk_id++);
                        this.id = gid;
-                       this.loadConfig();
+                       try {
+                               this.loadConfig();
+                       } catch (GLib.Error e )  {
+                               // is tihs ok?
+                       }
                
                }
                public Gee.HashMap<string,GtkValaSettings> compilegroups;
@@ -139,7 +143,7 @@ namespace Project {
                                if (    bb.length < target.length &&
                                        target.substring(0, bb.length) == bb) {
                                        
-                                       return prefix + target.substring(bb.length +1);
+                                       return prefix + target.substring(bb.length );
                                }
                                if (bb.length < 1) {
                                        throw new Error.INVALID_FORMAT ("Could not work out relative path %s to %s",
@@ -179,7 +183,7 @@ namespace Project {
                                GLib.debug("SCAN %s - skip - does not exist\n", dirname);
                                return ret;
                        }
-         
+                       var pathprefix = abspath ? dirname : in_path;
           
                        try {
                                var file_enum = dir.enumerate_children(
@@ -202,7 +206,7 @@ namespace Project {
                                                continue;
                                        }
                                        GLib.debug("SCAN ADD %s : %s", fn, next_file.get_content_type());
-                                       ret.add(dirname + "/" + fn);
+                                       ret.add(pathprefix + "/" + fn);
                                         
                                        // any other valid types???
                                
@@ -446,7 +450,27 @@ namespace Project {
                        return ret;
                        
                }
+               public string[] sourcedirs()
+               {
+                       string[] ret = {};
+                       var sources = this.compilegroups.get("_default_").sources;
+                       ret += this.firstPath();  
+                       for(var i =0; i< sources.size; i++) {
+                               
+                               var path = this.resolve_path( this.firstPath(), sources.get(i));
+                               if (path == this.firstPath()) {
+                                       continue;
+                               }
+                               if (Path.get_basename (path) == "vapi") {
+                                       continue;
+               
+                               }
+               //                      GLib.debug("Adding VAPIDIR: %s\n", path);
+                               ret += path;            
+                       }
+                       return ret;
                        
+               }       
 
        }
        // an object describing a build config (or generic ...)
@@ -459,7 +483,9 @@ namespace Project {
                public Gee.ArrayList<string> sources; // list of files+dirs (relative to project)
                public string target_bin;
 
-
+               public string execute_args;
+               
+               
                public GtkValaSettings(string name) 
                {
                        this.name = name;
@@ -467,6 +493,7 @@ namespace Project {
                        this.target_bin = "";
                        this.packages = new Gee.ArrayList<string>();
                        this.sources = new Gee.ArrayList<string>();
+                       this.execute_args = "";
                                
                }
                
@@ -476,14 +503,19 @@ namespace Project {
                        
                        this.name = el.get_string_member("name");
                        this.compile_flags = el.get_string_member("compile_flags");
+                       if ( el.has_member("execute_args")) {
+                               this.execute_args = el.get_string_member("execute_args");
+                       } else {
+                               this.execute_args = "";
+                       }
                        this.target_bin = el.get_string_member("target_bin");
                        // sources and packages.
                        this.sources = this.readArray(el.get_array_member("sources"));
                        this.packages = this.readArray(el.get_array_member("packages"));
-                       
+
                }
                
-               
+               // why not array of strings?
                
                public Gee.ArrayList<string> readArray(Json.Array ar) 
                {
@@ -499,6 +531,7 @@ namespace Project {
                        var ret = new Json.Object();
                        ret.set_string_member("name", this.name);
                        ret.set_string_member("compile_flags", this.compile_flags);
+                       ret.set_string_member("execute_args", this.execute_args);
                        ret.set_string_member("target_bin", this.target_bin);
                        ret.set_array_member("sources", this.writeArray(this.sources));
                        ret.set_array_member("packages", this.writeArray(this.packages));