[tracker/introspection] libtracker-sparql: (introspection) Dirty 'sed' only when really needed



commit 698b2101f794a84e7ca3f2ea982545d45a95d1ec
Author: Ivan Frade <ivan frade nokia com>
Date:   Fri Mar 25 10:55:35 2011 +0200

    libtracker-sparql: (introspection) Dirty 'sed' only when really needed
    
    If vala is recent enough, the "sed" operation is not needed.
    Also, run the sed trick only once on the file.
    
    Vala version is checked via new m4 function.
    
    Removed the .gir from the CLEANFILES. It must be cleaned only when
    the library it comes from is cleaned.

 configure.ac                      |    3 +++
 m4/vala-extra.m4                  |   26 ++++++++++++++++++++++++++
 src/libtracker-sparql/Makefile.am |   13 ++++++++++---
 3 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9600b3f..9c411e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -466,6 +466,9 @@ fi
 
 AC_SUBST(VALAC)
 
+AX_VALA_CHECK_VERSION([0.11.8], vala_good_gir=true, vala_good_gir=false)
+AM_CONDITIONAL(VALA_GOOD_GIR, test "x$vala_good_gir" == "xtrue")
+
 ####################################################################
 # Check gettext/intltool support
 ####################################################################
diff --git a/m4/vala-extra.m4 b/m4/vala-extra.m4
new file mode 100644
index 0000000..0851ebc
--- /dev/null
+++ b/m4/vala-extra.m4
@@ -0,0 +1,26 @@
+dnl Copyright (C) 2011 Nokia <ivan frade nokia com>
+dnl This file is free software; unlimited permission to copy and/or distribute
+dnl  it is given, with or without modifications, as long as this notice is
+dnl  preserved.
+
+dnl AX_VALA_CHECK_VERSION([MIN_VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl ---------------------------------------------------------------------------
+dnl Run ACTION-IF-TRUE if the vala compiler is installed AND has version >= VERSION.
+dnl Run ACTION-IF-FALSE otherwise.
+
+dnl This macro doesn't check if valac is installed (use AM_PROG_VALAC or your
+dnl own AC_PATH_PROG to check that)
+
+AC_DEFUN([AX_VALA_CHECK_VERSION],
+[
+  AC_MSG_CHECKING([valac generates proper GIR])
+  AS_IF([test "x$VALAC" != "x"], [], [AC_PATH_PROG([VALAC], [valac], [])])
+  am__vala_version=`$VALAC --version | sed 's/Vala  *//'`
+  AS_VERSION_COMPARE([$1], ["$am__vala_version"], 
+       [AC_MSG_RESULT([yes]) 
+        $2], 
+       [AC_MSG_RESULT([yes]) 
+        $2], 
+       [AC_MSG_RESULT([no]) 
+        $3])
+])
diff --git a/src/libtracker-sparql/Makefile.am b/src/libtracker-sparql/Makefile.am
index 52c8db6..037b082 100644
--- a/src/libtracker-sparql/Makefile.am
+++ b/src/libtracker-sparql/Makefile.am
@@ -70,9 +70,16 @@ EXTRA_DIST =                                           \
 -include $(INTROSPECTION_MAKEFILE)
 
 if HAVE_INTROSPECTION
-#  set introspectable=0 to the function that uses va_list. This is not needed with a modern vala ( > 23/03/2011)
+
+#  set introspectable=0 to the function that uses va_list. This is not needed with a modern vala ( >= 0.11.8)
+if VALA_GOOD_GIR
+Tracker- TRACKER_API_VERSION@.gir: $(lib_LTLIBRARIES) Makefile
+else
 Tracker- TRACKER_API_VERSION@.gir: $(lib_LTLIBRARIES) Makefile
-	sed -i $@ -e "s/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"\ introspectable=\"0\"/g"
+	if [[ -z `grep tracker_sparql_escape_uri_vprintf $@ |grep introspectable` ]] ; then \
+	  sed -i $@ -e "s/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"/c\:identifier\=\"tracker_sparql_escape_uri_vprintf\"\ introspectable=\"0\"/g" ; \
+        fi
+endif
 
 Tracker- TRACKER_API_VERSION@.typelib: Tracker-$(TRACKER_API_VERSION).gir
 	@INTROSPECTION_COMPILER@ --shared-library=libtracker-sparql- TRACKER_API_VERSION@.so -o $@ $^
@@ -83,5 +90,5 @@ dist_gir_DATA = Tracker-$(TRACKER_API_VERSION).gir
 typelibdir = $(libdir)/girepository-1.0
 typelib_DATA = Tracker-$(TRACKER_API_VERSION).typelib
 
-CLEANFILES = $(dist_gir_DATA) $(typelib_DATA)
+CLEANFILES = $(typelib_DATA)
 endif
\ No newline at end of file



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