src/Project/Gtk.vala
[app.Builder.js] / src / Project / Gtk.vala
index 722da71..345a647 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",
@@ -163,7 +167,7 @@ namespace Project {
                 *  
                 */
                
-               public Gee.ArrayList<string> filesAll(string in_path)
+               public Gee.ArrayList<string> filesAll(string in_path,bool abspath = true)
                {
                        var ret =  new Gee.ArrayList<string>();
                        
@@ -179,11 +183,11 @@ 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(
-                                       GLib.FileAttribute.STANDARD_DISPLAY_NAME
+                                       "standard::*"
                                        GLib.FileQueryInfoFlags.NONE, 
                                        null
                                );
@@ -198,8 +202,11 @@ namespace Project {
                                                GLib.debug("SKIP %s not regular  ", fn);
                                                continue;
                                        }
-                                       GLib.debug("SCAN ADD %s : %s", fn, fn.get_content_type());
-                                       ret.add(in_path + "/" + fn);
+                                       if (!Regex.match_simple("^text", next_file.get_content_type())) {
+                                               continue;
+                                       }
+                                       GLib.debug("SCAN ADD %s : %s", fn, next_file.get_content_type());
+                                       ret.add(pathprefix + "/" + fn);
                                         
                                        // any other valid types???
                                
@@ -212,9 +219,9 @@ namespace Project {
                        return ret;
                }
                
-               public Gee.ArrayList<string> filesForCompile(string in_path)
+               public Gee.ArrayList<string> filesForCompile(string in_path, bool abspath = true)
                {
-                       var allfiles = this.filesAll(in_path);
+                       var allfiles = this.filesAll(in_path,abspath);
                        var ret =  new Gee.ArrayList<string>();
                        
                        
@@ -267,6 +274,7 @@ namespace Project {
                        
                        for (var i = 0; i < allfiles.size; i ++) {
                                var fn = allfiles.get(i);
+                               var bn  = GLib.Path.get_basename(fn);
                                try {
                                        
                                        if (Regex.match_simple("\\.vala\\.c$", fn)) {
@@ -279,16 +287,34 @@ namespace Project {
                                                GLib.debug("SKIP %s - .bjs",fn);
                                                continue;
                                        }
-                                       if (Regex.match_simple("\\.o$", fn)) {
+                                       
+                                       if (Regex.match_simple("\\~$", fn)) {
+                                               GLib.debug("SKIP %s - ~",fn);
+                                               continue;
+                                       }
+                                       if (Regex.match_simple("\\.stamp$", fn)) {
                                                GLib.debug("SKIP %s - .o",fn);
                                                continue;
                                        }
-                                       if (Regex.match_simple("\\~$", fn)) {
-                                               GLib.debug("SKIP %s - ~",fn);
+                                       if ("stamp-h1" == bn) {
+                                               GLib.debug("SKIP %s - .o",fn);
                                                continue;
                                        }
                                        
-                                       if (Regex.match_simple("^\\.", GLib.Path.get_basename(fn))) {
+                                       // confgure.am
+                                       if ("config.h" == bn || "config.h.in" == bn || "config.log" == bn  || "configure" == bn ) {
+                                               if (allfiles.index_of( in_path +"/configure.ac") > -1) {
+                                                       continue;
+                                               }
+                                       }
+                                       // makefile
+                                       if ("Makefile" == bn || "Makefile.in" == bn ) {
+                                               if (allfiles.index_of( in_path +"/Makefile.am") > -1) {
+                                                       continue;
+                                               }
+                                       }
+                                       
+                                       if (Regex.match_simple("^\\.", bn)) {
                                                GLib.debug("SKIP %s - hidden",fn);
                                                continue;
                                        }
@@ -424,7 +450,25 @@ 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.get_basename (path) == "vapi") {
+                                       continue;
+               
+                               }
+               //                      GLib.debug("Adding VAPIDIR: %s\n", path);
+                               ret += path;            
+                       }
+                       return ret;
                        
+               }       
 
        }
        // an object describing a build config (or generic ...)
@@ -461,7 +505,7 @@ namespace Project {
                        
                }
                
-               
+               // why not array of strings?
                
                public Gee.ArrayList<string> readArray(Json.Array ar) 
                {