[gnome-code-assistance] [backends/c] More advanced Makefile detection



commit e1844217d48e30481d61787fdefbada39cc967ac
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Thu Nov 7 20:28:44 2013 +0100

    [backends/c] More advanced Makefile detection
    
    Makefiles are now also searched in subdirectories relative
    to configure.ac, if no other Makefile has been found. It takes
    into account the relative path to the source from the configure.ac
    location. This allows proper makefile detection when using a separate
    build directory.

 backends/c/makefileintegration.py |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/backends/c/makefileintegration.py b/backends/c/makefileintegration.py
index 19a968c..437d71e 100644
--- a/backends/c/makefileintegration.py
+++ b/backends/c/makefileintegration.py
@@ -90,7 +90,29 @@ class MakefileIntegration:
         m.add(path, flags)
         return flags
 
-    def _makefile_for(self, path):
+    def _find_subdir_with_path(self, parent, path):
+        dname = os.path.dirname(path)
+        bname = os.path.basename(path)
+
+        for dirname, dirnames, filenames in os.walk(parent):
+            for s in dirnames:
+                tpath = os.path.join(dirname, s, dname)
+
+                if os.path.isdir(tpath):
+                    mf = self._makefile_for(os.path.join(tpath, bname))
+
+                    if not mf is None:
+                        return mf
+
+        return None
+
+    def _subdir_makefile_for(self, path, parent):
+        relpath = os.path.relpath(path, parent)
+
+        # Find subdirectory of parent which contains relpath
+        return self._find_subdir_with_path(parent, relpath)
+
+    def _makefile_for(self, path, tryac=True):
         parent = os.path.dirname(path)
 
         while True:
@@ -99,6 +121,15 @@ class MakefileIntegration:
             if os.path.isfile(makefile):
                 return makefile
 
+            if tryac:
+                configureac = os.path.join(parent, 'configure.ac')
+
+                if os.path.isfile(configureac):
+                    ret = self._subdir_makefile_for(path, parent)
+
+                    if not ret is None:
+                        return ret
+
             parent = os.path.dirname(parent)
 
             if parent == '/':


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