2 write meson build so that the language server works..
7 public class Meson : Object {
10 public Meson(Gtk project)
12 this.project = project;
17 this.has_resources = false;
18 var project_name = this.project.name;
19 var project_version = "1.0"; //this.project.version;
20 var project_licence = "LGPL"; // this.project.licence
23 foreach(var p in this.project.packages) {
25 deps += " valac.find_library('" + p + "'),\n";
27 deps += " dependency('" + p + "'),\n";
31 dependency('glib-2.0'),
32 dependency('gobject-2.0'), << for others.. ut will this wrok using find_lib for all?
33 valac.find_library('posix'), << for posix
36 // ?? why use subdir ?? seems pointless?
41 foreach(var p in this.project.vapidirs()) {
42 addvapidir += "add_project_arguments(['--vapidir', meson.current_source_dir() / '" + p + "'], language: 'vala')\n";
44 //vapi_dir = meson.current_source_dir() / 'vapi'
45 //add_project_arguments(['--vapidir', vapi_dir], language: 'vala')
51 var resources = this.addResources();
53 foreach(var cg in this.project.compilegroups.values) {
54 targets += this.addTarget(cg);
55 icons += this.addIcons(cg);
56 desktops += this.addDesktop(cg);
63 @"project('$project_name', 'vala', 'c',
64 version: '$project_version',
65 license: '$project_licence',
67 'default_library=static',
68 'c_std=gnu11' # for C subprojects
71 gnome = import('gnome')
73 valac = meson.get_compiler('vala')
75 extra_vala_sources = []
83 # let Vala add the appropriate defines for GLIB_X_X
84 add_project_arguments(['--target-glib=auto'], language: 'vala')
88 conf = configuration_data()
89 conf.set('PROJECT_NAME', meson.project_name())
102 GLib.debug("write meson : %s" , data);
103 // removed.. add_project_arguments(['--enable-gobject-tracing', '--fatal-warnings'], language: 'vala')
106 FileUtils.set_contents(this.project.path + "/meson.build", data, data.length);
107 } catch (GLib.Error e) {
108 GLib.error("failed to save file %s", e.message);
113 string addTarget(GtkValaSettings cg)
116 var str = cg.name + "_src = files([\n";
117 foreach(var s in cg.sources) {
118 var f= this.project.getByPath(this.project.path + "/" + s);
122 var add = f.relTargetName();
123 if (add.length > 0) {
124 str += " '" + add + "',\n";
129 var resources = this.has_resources ? (", " + this.project.name + "_resources") : "";
130 var cgname = cg.name;
133 $cgname = executable('$cgname',
135 sources: [ " + cgname + @"_src $resources ],
143 string addIcons(GtkValaSettings cg)
147 string[] sizes = { "16x16", "22x22","24x24","32x32", "48x48" } ;
148 foreach(var size in sizes) {
149 GLib.debug("looking for on : %s" , "pixmaps/" + size + "/apps/" + cg.name + ".png");
150 var img = this.project.getByRelPath( "pixmaps/" + size + "/apps/" + cg.name + ".png");
154 var path = img.relpath;
158 install_dir: get_option('datadir') + '/icons/hicolor/$size/apps/'
167 gnome.post_install(gtk_update_icon_cache : true)
172 string addDesktop(GtkValaSettings cg)
174 // we could actually generate this!?!
175 var d = this.project.getByRelPath( cg.name + ".desktop");
179 var path = d.relpath;
183 install_dir : get_option('datadir') + '/applications/'
187 bool has_resources = false;
189 string addResources()
192 if (this.project.findDir(this.project.path + "/resources") == null) {
193 GLib.debug("no resources folder");
196 var ar = this.project.pathsUnder("resources");
198 GLib.debug("no paths under resources");
201 // should probably use DOM (but this is a quick dirty fix
202 var gr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gresources>";
204 foreach(var dir in ar) {
205 if (dir.childfiles.get_n_items() < 1) {
208 var sp = dir.relpath.substring(10);
209 gr += @" <gresource prefix=\"/$sp\">\n";
210 for (var i = 0; i < dir.childfiles.get_n_items(); i++) {
211 var f = (dir.childfiles.get_item(i) as JsRender.JsRender);
212 if (f.xtype != "PlainFile") {
216 gr += @" <file>$fn</file>\n";
218 paths += ("'" + dir.relpath +"'");
219 gr += " </gresource>\n";
223 gr += "</gresources>\n";
225 FileUtils.set_contents(this.project.path + "/resources/gresources.xml", gr, gr.length);
226 } catch (GLib.Error e) {
232 this.has_resources = true;
235 " + this.project.name + "_resources = gnome.compile_resources(
236 '" + this.project.name + "-resources', 'resources/gresources.xml',
237 source_dir: [ " + string.joinv(", ", paths) + " ],
238 c_name: '" + this.project.name + "_resources'