3 // an object describing a build config (or generic ...)
4 public class GtkValaSettings : Object {
5 public string name { get; set; }
10 public Gee.ArrayList<string> sources; // list of files+dirs (relative to project)
13 public string execute_args;
15 public bool loading_ui = true;
16 public bool is_library = false;
18 public GtkValaSettings(Gtk project, string name)
21 this.project = project;
24 this.sources = new Gee.ArrayList<string>();
25 this.execute_args = "";
29 public GtkValaSettings.from_json(Gtk project, Json.Object el) {
31 this.project = project;
32 this.name = el.get_string_member("name");
33 if (el.has_member("is_library")) {
34 this.is_library = el.get_boolean_member("is_library");
36 if ( el.has_member("execute_args")) {
37 this.execute_args = el.get_string_member("execute_args");
39 this.execute_args = "";
41 // sources and packages.
42 this.sources = this.filterFiles(this.project.readArray(el.get_array_member("sources")));
47 // why not array of strings?
51 public Json.Object toJson()
53 var ret = new Json.Object();
54 ret.set_string_member("name", this.name);
55 ret.set_boolean_member("is_library", this.is_library);
56 ret.set_string_member("execute_args", this.execute_args);
58 ret.set_array_member("sources", this.writeArray( this.filterFiles(this.sources)));
63 public Json.Array writeArray(Gee.ArrayList<string> ar) {
64 var ret = new Json.Array();
65 for(var i =0; i< ar.size; i++) {
66 ret.add_string_element(ar.get(i));
70 public bool has_file(JsRender.JsRender file)
73 //GLib.debug("Checking %s has file %s", this.name, file.path);
74 var pr = (Gtk) file.project;
75 for(var i = 0; i < this.sources.size;i++) {
76 var path = pr.path + "/" + this.sources.get(i);
77 //GLib.debug("check %s =%s or %s", path , file.path, file.targetName());
79 if (path == file.path || path == file.targetName()) {
80 //GLib.debug("GOT IT");
84 //GLib.debug("CANT FIND IT");
89 public Gee.ArrayList<string> filterFiles( Gee.ArrayList<string> ar)
91 var ret = new Gee.ArrayList<string>();
92 foreach(var f in ar) {
93 if (null == this.project.getByRelPath(f)) {
101 public string writeMesonExe(string resources)
104 var cgname = this.name;
105 if (!this.is_library) {
107 $cgname = executable('$cgname',
109 sources: [ $(cgname)_src $resources ],
115 foreach(var p in this.project.packages) {
119 deps += "'" + p + "'";
122 var depstr = deps.length < 1 ? "" : ( "[" + string.joinv(",", deps) + "]");
125 var version = this.project.version;
128 $(cgname)_lib = shared_library('$cgname',
129 sources : [ $(cgname)_src $resources ],
130 vala_vapi: '$(cgname)-$(version).vapi',
133 install_dir: [true, true, true]
135 pkg = import('pkgconfig')
136 pkg.generate( $(cgname)_lib,
137 filebase: '$(cgname)-$(version)',