[Vala] [PATCH] [valac] Consider install prefix when searching for packages



From: Mathias Hasselmann <mathias hasselmann gmx de>

Passing PACKAGE_DATADIR per -D switch as this is preferred over throwing
installation prefix dependent information into config.h. Accordingly to
the documentation of autoconf users of make expect being able to change
the installation prefix when running make.
---
 trunk/vala/compiler/Makefile.am       |    4 +++-
 trunk/vala/compiler/valacompiler.vala |   10 ++++++++--
 trunk/vala/vapi/config.vala           |    1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/trunk/vala/compiler/Makefile.am b/trunk/vala/compiler/Makefile.am
index 904ee23..ed78287 100644
--- a/trunk/vala/compiler/Makefile.am
+++ b/trunk/vala/compiler/Makefile.am
@@ -21,7 +21,9 @@ valac.vala.stamp: $(filter %.vala,$(valac_SOURCES))
        $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala 
--pkg config $^
        touch $@
 
-valac_CPPFLAGS = -include config.h
+valac_CPPFLAGS = \
+       -include config.h \
+       -DPACKAGE_DATADIR=\"$(datadir)\"
 
 valac_LDADD = \
        $(GLIB_LIBS) \
diff --git a/trunk/vala/compiler/valacompiler.vala b/trunk/vala/compiler/valacompiler.vala
index b36090c..0f42314 100644
--- a/trunk/vala/compiler/valacompiler.vala
+++ b/trunk/vala/compiler/valacompiler.vala
@@ -59,7 +59,8 @@ class Vala.Compiler {
        }
        
        private ref string get_package_path (string! pkg) {
-               var basename = "%s.vala".printf (pkg);
+               string basename = "%s.vala".printf (pkg);
+               string filename;
        
                if (vapi_directories != null) {
                        foreach (string vapidir in vapi_directories) {
@@ -70,7 +71,12 @@ class Vala.Compiler {
                        }
                }
                
-               var filename = Path.build_filename ("/usr/local/share/vala/vapi", basename);
+               filename = Path.build_filename (Config.PACKAGE_DATADIR, "vala/vapi", basename);
+               if (File.test (filename, FileTest.EXISTS)) {
+                       return filename;
+               }
+               
+               filename = Path.build_filename ("/usr/local/share/vala/vapi", basename);
                if (File.test (filename, FileTest.EXISTS)) {
                        return filename;
                }
diff --git a/trunk/vala/vapi/config.vala b/trunk/vala/vapi/config.vala
index b517368..77ab0d0 100644
--- a/trunk/vala/vapi/config.vala
+++ b/trunk/vala/vapi/config.vala
@@ -23,4 +23,5 @@
 [CCode (cprefix = "", cheader_filename = "config.h")]
 namespace Config {
         public const string PACKAGE_VERSION;
+       public const string PACKAGE_DATADIR;
 }
-- 
1.4.4.2




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