3 // an object describing a build config (or generic ...)
4 public class GtkValaSettings : Object {
6 public GtkValaSettings? parent;
8 public string compile_flags; // generic to all.
9 public Gee.ArrayList<string> packages; // list of packages?? some might be genericly named?
10 public Gee.ArrayList<string> sources; // list of files+dirs (relative to project)
11 public string target_bin;
13 public string execute_args;
16 public GtkValaSettings(string name)
19 this.compile_flags = "";
21 this.packages = new Gee.ArrayList<string>();
22 this.sources = new Gee.ArrayList<string>();
23 this.execute_args = "";
28 public GtkValaSettings.from_json(Json.Object el) {
31 this.name = el.get_string_member("name");
32 this.compile_flags = el.get_string_member("compile_flags");
33 if ( el.has_member("execute_args")) {
34 this.execute_args = el.get_string_member("execute_args");
36 this.execute_args = "";
38 this.target_bin = el.get_string_member("target_bin");
39 // sources and packages.
40 this.sources = this.readArray(el.get_array_member("sources"));
41 this.packages = this.readArray(el.get_array_member("packages"));
45 // why not array of strings?
47 public Gee.ArrayList<string> readArray(Json.Array ar)
49 var ret = new Gee.ArrayList<string>();
50 for(var i =0; i< ar.get_length(); i++) {
51 ret.add(ar.get_string_element(i));
56 public Json.Object toJson()
58 var ret = new Json.Object();
59 ret.set_string_member("name", this.name);
60 ret.set_string_member("compile_flags", this.compile_flags);
61 ret.set_string_member("execute_args", this.execute_args);
62 ret.set_string_member("target_bin", this.target_bin);
63 ret.set_array_member("sources", this.writeArray(this.sources));
64 ret.set_array_member("packages", this.writeArray(this.packages));
67 public Json.Array writeArray(Gee.ArrayList<string> ar) {
68 var ret = new Json.Array();
69 for(var i =0; i< ar.size; i++) {
70 ret.add_string_element(ar.get(i));
74 public bool has_file(JsRender.JsRender file)
77 GLib.debug("Checking %s has file %s", this.name, file.path);
78 var pr = (Gtk) file.project;
79 for(var i = 0; i < this.sources.size;i++) {
80 var path = pr.resolve_path( pr.resolve_path_combine_path( pr.firstPath(), this.sources.get(i)));
81 GLib.debug("check %s", path);
83 if (path == file.path) {
88 GLib.debug("CANT FIND IT");