[gnome-builder] vala: get vala minor version from build information



commit 6fb39fdd19a75a3b2082e422ad1ca29014db0278
Author: Christian Hergert <christian hergert me>
Date:   Wed Jun 1 09:06:51 2016 -0700

    vala: get vala minor version from build information
    
    This lets us fallback to previous vala versions and still define the right
    values to the ValaCodeContext.

 plugins/vala-pack/Makefile.am         |    1 +
 plugins/vala-pack/config.vapi         |    1 +
 plugins/vala-pack/ide-vala-index.vala |   12 ++++++++----
 3 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/plugins/vala-pack/Makefile.am b/plugins/vala-pack/Makefile.am
index 65113af..ff22c0f 100644
--- a/plugins/vala-pack/Makefile.am
+++ b/plugins/vala-pack/Makefile.am
@@ -77,6 +77,7 @@ libvala_pack_plugin_la_VALAFLAGS += -D ENABLE_VALA_SYMBOL_GET_DEPRECATED
 endif
 
 libvala_pack_plugin_la_CFLAGS = \
+       -DVALA_VERSION=\""$(VALA_VERSION)"\" \
        -DPACKAGE_DATADIR=\""$(datadir)/gnome-builder"\" \
        -DG_LOG_DOMAIN=\"vala-pack-plugin\" \
        -DGETTEXT_PACKAGE=\"gnome-builder\" \
diff --git a/plugins/vala-pack/config.vapi b/plugins/vala-pack/config.vapi
index e8a85de..f46b186 100644
--- a/plugins/vala-pack/config.vapi
+++ b/plugins/vala-pack/config.vapi
@@ -1,5 +1,6 @@
 [CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "")]
 namespace Config {
        public const string PACKAGE_DATADIR;
+       public const string VALA_VERSION;
 }
 
diff --git a/plugins/vala-pack/ide-vala-index.vala b/plugins/vala-pack/ide-vala-index.vala
index b7124a8..a3412eb 100644
--- a/plugins/vala-pack/ide-vala-index.vala
+++ b/plugins/vala-pack/ide-vala-index.vala
@@ -33,8 +33,6 @@ namespace Ide
 {
        public class ValaIndex: GLib.Object
        {
-               static const int VALA_VERSION = 32;
-
                Ide.Context context;
                Vala.CodeContext code_context;
                Vala.Parser parser;
@@ -86,7 +84,13 @@ namespace Ide
 
                        this.code_context.run_output = false;
 
-                       for (var i = 2; i <= VALA_VERSION; i += 2) {
+                       int minor = 34;
+                       var tokens = Config.VALA_VERSION.split(".", 2);
+                       if (tokens[1] != null) {
+                               minor = int.parse(tokens[1]);
+                       }
+
+                       for (var i = 2; i <= minor; i += 2) {
                                this.code_context.add_define ("VALA_0_%d".printf (i));
                        }
 
@@ -515,7 +519,7 @@ namespace Ide
                string? get_versioned_vapidir ()
                {
                        try {
-                               var pkgname = "libvala-0.%d".printf (VALA_VERSION);
+                               var pkgname = "libvala-%s".printf (Config.VALA_VERSION);
                                string outstr = null;
                                var subprocess = new GLib.Subprocess (GLib.SubprocessFlags.STDOUT_PIPE,
                                                                          "pkg-config",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]