[damned-lies] Support $(top_srcdir) replacement in makefile variables



commit 064395a159dafcee5a4180aed1a74454442cbbda
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Jun 19 21:05:49 2020 +0200

    Support $(top_srcdir) replacement in makefile variables

 stats/tests/git/testmodule/help_docbook/Makefile.am | 2 ++
 stats/tests/tests.py                                | 4 ++++
 stats/utils.py                                      | 2 ++
 3 files changed, 8 insertions(+)
---
diff --git a/stats/tests/git/testmodule/help_docbook/Makefile.am 
b/stats/tests/git/testmodule/help_docbook/Makefile.am
index 99507ec5..e228ae5d 100644
--- a/stats/tests/git/testmodule/help_docbook/Makefile.am
+++ b/stats/tests/git/testmodule/help_docbook/Makefile.am
@@ -20,3 +20,5 @@ help_files_2 = \
        rnlookingforward.xml
 
 HELP_FILES = $(help_files_1) $(help_files_2)
+
+SOME_VAR = $(top_srcdir)/some_path.po
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 86be07c9..88202629 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -824,6 +824,10 @@ class UtilsTests(TestModuleBase):
         var_content = makefile.read_variable("HELP_FILES")
         self.assertEqual(var_content.split(), ['rnusers.xml', 'rnlookingforward.xml'])
 
+        # Test $(top_srcdir) replacement
+        var_content = makefile.read_variable("SOME_VAR")
+        self.assertEqual(var_content, str(self.branch.co_path) + '/some_path.po')
+
     def test_read_meson_variables(self):
         domain = Domain.objects.create(
             module=self.mod, name='help', dtype='doc',
diff --git a/stats/utils.py b/stats/utils.py
index 4919a1e1..ec7de78d 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -226,6 +226,8 @@ class MakefileWrapper:
                     result = self.read_variable(element[2:-1])
                     if result:
                         found = found.replace(element, result)
+            if '$(top_srcdir)' in found:
+                found = found.replace('$(top_srcdir)', str(self.branch.co_path))
         return found
 
 


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