[anjuta] language-support-vala: get packages and vapidirs from the VALAFLAGS variable
- From: Abderrahim Kitouni <akitouni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] language-support-vala: get packages and vapidirs from the VALAFLAGS variable
- Date: Mon, 29 Aug 2011 15:58:09 +0000 (UTC)
commit 8d7a1ab3c30b128209ebd1314eb9f628373aa735
Author: Abderrahim Kitouni <akitouni src gnome org>
Date: Fri Aug 19 11:12:02 2011 +0100
language-support-vala: get packages and vapidirs from the VALAFLAGS variable
plugins/language-support-vala/Makefile.am | 4 +--
plugins/language-support-vala/plugin.vala | 50 +++++++++++++++++++++++++++-
2 files changed, 49 insertions(+), 5 deletions(-)
---
diff --git a/plugins/language-support-vala/Makefile.am b/plugins/language-support-vala/Makefile.am
index 363cd4a..99bc02d 100644
--- a/plugins/language-support-vala/Makefile.am
+++ b/plugins/language-support-vala/Makefile.am
@@ -31,15 +31,13 @@ AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"language-support-vala\" \
--no-warn
-VALAFLAGS = --vapidir $(srcdir)
-
# The plugin
plugindir = $(anjuta_plugin_dir)
plugin_LTLIBRARIES = libanjuta-language-vala.la
# Plugin sources
libanjuta_language_vala_la_SOURCES = locator.vala plugin.vala provider.vala report.vala
-libanjuta_language_vala_la_VALAFLAGS = --pkg $(LIBVALA) --pkg libanjuta-3.0
+libanjuta_language_vala_la_VALAFLAGS = --vapidir $(srcdir) --pkg $(LIBVALA) --pkg libanjuta-3.0
libanjuta_language_vala_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/language-support-vala/plugin.vala b/plugins/language-support-vala/plugin.vala
index d57a9c3..bcece37 100644
--- a/plugins/language-support-vala/plugin.vala
+++ b/plugins/language-support-vala/plugin.vala
@@ -137,6 +137,9 @@ public class ValaPlugin : Plugin {
if (!(Anjuta.ProjectNodeType.SOURCE in node.get_node_type ()))
return;
+ if (node.get_file () == null)
+ return;
+
var path = node.get_file ().get_path ();
if (path == null)
return;
@@ -162,14 +165,57 @@ public class ValaPlugin : Plugin {
debug ("standard packages already added");
}
- var packages = pm.get_packages();
+ string[] flags = {};
+ bool found = false;
+ foreach (unowned Anjuta.ProjectProperty prop in current_target.get_custom_properties ()) {
+ if (prop.native.id == "VALAFLAGS") {
+ GLib.Shell.parse_argv (prop.value, out flags);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ /* Fall back to AM_VALAFLAGS */
+ var current_group = current_target.parent_type (Anjuta.ProjectNodeType.GROUP);
+ foreach (unowned Anjuta.ProjectProperty prop in current_group.get_custom_properties ()) {
+ if (prop.native.id == "VALAFLAGS") {
+ GLib.Shell.parse_argv (prop.value, out flags);
+ break;
+ }
+ }
+ }
+
+ string[] packages = {};
+ string[] vapidirs = {};
+
+ for (int i = 0; i < flags.length; i++) {
+ if (flags[i] == "--vapidir")
+ vapidirs += flags[++i];
+ else if (flags[i].has_prefix ("--vapidir="))
+ vapidirs += flags[i].substring ("--vapidir=".length);
+ else if (flags[i] == "--pkg")
+ packages += flags[++i];
+ else if (flags[i].has_prefix ("--pkg="))
+ packages += flags[i].substring ("--pkg=".length);
+ else
+ debug ("Unknown valac flag %s", flags[i]);
+ }
+
+ var srcdir = current_target.parent_type (Anjuta.ProjectNodeType.GROUP).get_file ().get_path ();
+ var top_srcdir = project.get_root ().get_file ().get_path ();
+ for (int i = 0; i < vapidirs.length; i++) {
+ vapidirs[i] = vapidirs[i].replace ("$(srcdir)", srcdir)
+ .replace ("$(top_srcdir)", top_srcdir);
+ }
+
+ context.vapi_directories = vapidirs;
foreach (var pkg in packages) {
if (context.has_package (pkg)) {
debug ("package %s skipped", pkg);
} else if (context.add_external_package(pkg)) {
debug ("package %s added", pkg);
} else {
- /* TODO: try to look at VALAFLAGS */
debug ("package %s not found", pkg);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]