[gnome-builder] makecache: be a bit more relaxed extracting vala flags



commit 4c71cc91207972bc4261e540eac1e49bca62c91b
Author: Christian Hergert <christian hergert me>
Date:   Wed Apr 20 17:33:15 2016 -0700

    makecache: be a bit more relaxed extracting vala flags
    
    When projects are not using automake for vala integration into _SOURCES,
    we can sometimes still extract something.

 plugins/autotools/ide-makecache.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/plugins/autotools/ide-makecache.c b/plugins/autotools/ide-makecache.c
index 7dbb2bb..1eb25a6 100644
--- a/plugins/autotools/ide-makecache.c
+++ b/plugins/autotools/ide-makecache.c
@@ -1160,6 +1160,7 @@ ide_makecache_get_file_targets_worker (GTask        *task,
                                        GCancellable *cancellable)
 {
   g_autofree gchar *translated = NULL;
+  g_autofree gchar *base = NULL;
   FileTargetsLookup *lookup = task_data;
   const gchar *path;
   GPtrArray *ret;
@@ -1178,6 +1179,8 @@ ide_makecache_get_file_targets_worker (GTask        *task,
   if (g_str_has_suffix (path, ".vala"))
     path = translated = replace_suffix (path, "c");
 
+  base = g_path_get_basename (path);
+
   /* we use an empty GPtrArray to get negative cache hits. a bit heavy handed? sure. */
   if (!(ret = ide_makecache_get_file_targets_searched (lookup->mapped, path)))
     ret = g_ptr_array_new ();
@@ -1201,6 +1204,21 @@ ide_makecache_get_file_targets_worker (GTask        *task,
           if (slash != NULL)
             name = slash + 1;
 
+          /*
+           * It we got a target that looks like "foo.lo" and the filename was
+           * "foo.vala", then they probably aren't using vala automake
+           * integration but we can likely still extract flags.
+           */
+          if ((NULL != (endptr = strrchr (name, '.'))) &&
+              (strcmp (endptr, ".lo") == 0) &&
+              (strncmp (name, base, endptr - name) == 0))
+            continue;
+
+          /*
+           * Follow the automake vala renaming rules the best I can decipher.
+           * Which seems to be that libraries get libfoo_la.stamp (ignoring
+           * the filename portion) but programs get program_foo.stamp.
+           */
           if (NULL != (endptr = strchr (name, '-')))
             {
               GString *str = g_string_new (NULL);


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