public void save()
{
-
+ this.has_resources = false;
var project_name = this.project.name;
var project_version = "1.0"; //this.project.version;
var project_licence = "LGPL"; // this.project.licence
var targets = "";
var icons = "";
var desktops = "";
+
+ var resources = this.addResources();
+
foreach(var cg in this.project.compilegroups.values) {
targets += this.addTarget(cg);
icons += this.addIcons(cg);
desktops += this.addDesktop(cg);
}
+
+
+
var data =
@"project('$project_name', 'vala', 'c',
'c_std=gnu11' # for C subprojects
]
)
+gnome = import('gnome')
valac = meson.get_compiler('vala')
$icons
+$resources
+
$desktops
$targets
}
str += "])\n\n";
- str += cg.name +" = executable('" + cg.name + "',\n"+
- " dependencies: deps,\n"+
- " sources: [ " + cg.name + "_src ],\n"+
- " install: true\n" +
- ")\n\n";
+ var resources = this.has_resources ? (", " + this.project.name + "_resources") : "";
+ var cgname = cg.name;
+
+ str += @"
+$cgname = executable('$cgname',
+ dependencies: deps,
+ sources: [ " + cgname + @"_src $resources ],
+ install: true
+)
+";
return str;
}
return "";
}
ret += "
-gnome = import('gnome')
+
gnome.post_install(gtk_update_icon_cache : true)
";
return ret;
return @"
install_data(
'$path',
- install_dir : get_option('datadir') + '/applications/''
+ install_dir : get_option('datadir') + '/applications/'
)
";
}
+ bool has_resources = false;
+
+ string addResources()
+ {
+
+ if (this.project.findDir(this.project.path + "/resources") == null) {
+ GLib.debug("no resources folder");
+ return "";
+ }
+ var ar = this.project.pathsUnder("resources");
+ if (ar.size < 1) {
+ GLib.debug("no paths under resources");
+ return "";
+ }
+ // should probably use DOM (but this is a quick dirty fix
+ var gr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gresources>";
+ string[] paths = {};
+ foreach(var dir in ar) {
+ if (dir.childfiles.get_n_items() < 1) {
+ continue;
+ }
+ var sp = dir.relpath.substring(10);
+ gr += @" <gresource prefix=\"/$sp\">\n";
+ for (var i = 0; i < dir.childfiles.get_n_items(); i++) {
+ var f = (dir.childfiles.get_item(i) as JsRender.JsRender);
+ if (f.xtype != "PlainFile") {
+ continue;
+ }
+ var fn = f.name;
+ gr += @" <file>$fn</file>\n";
+ }
+ paths += ("'" + dir.relpath +"'");
+ gr += " </gresource>\n";
+
+
+ }
+ gr += "</gresources>\n";
+ FileUtils.set_contents(this.project.path + "/resources/gresources.xml", gr, gr.length);
+
+ this.has_resources = true;
+
+ return "
+" + this.project.name + "_resources = gnome.compile_resources(
+ '" + this.project.name + "-resources', 'resources/gresources.xml',
+ source_dir: [ " + string.joinv(", ", paths) + " ],
+ c_name: '" + this.project.name + "_resources'
+)";
+
+
+ return "";
+
+ }
+
+
+
}
}
\ No newline at end of file