module: gnumake support; code cleanup
authorDmitry Selyutin <ghostmansd@gmail.com>
Tue, 5 Dec 2017 18:12:50 +0000 (21:12 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Mon, 11 Dec 2017 21:58:08 +0000 (00:58 +0300)
pygnulib/config.py
pygnulib/module.py
pygnulib/parser.py

index 5787eb73a3202e43cef62fea33e37be54ef64293..ecaadbf18311b04e3543ed8612e9f5e92ee51238 100644 (file)
@@ -65,6 +65,7 @@ class Base:
         "files"             : set(),
         "copymode"          : None,
         "local_copymode"    : None,
+        "gnumake"           : False,
     }
     _OPTIONS = frozenset({
         "tests",
index 7bc1b184698ecb0b6b66cd0c3035c59965762e27..4f8caa9b3784c1c2a244f70eadd79b1df6650b2a 100644 (file)
@@ -281,21 +281,22 @@ class Base:
         if "unconditional_automake_snippet" in self.__table:
             return self.__table["unconditional_automake_snippet"]
         result = ""
+        files = self.files
         if self.name.endswith("-tests"):
             # *-tests module live in tests/, not lib/.
             # Synthesize an EXTRA_DIST augmentation.
             test_files = {file for file in files if file.startswith("tests/")}
             if test_files:
-                result += ("EXTRA_DIST +=".format("".join(sorted(test_files))) + "\n")
+                result += ("EXTRA_DIST +={}".format("".join(sorted(test_files))) + "\n")
             return result
         snippet = self.conditional_automake_snippet
-        (all_files, mentioned_files) = (self.files(), set())
-        for match in Module._LIB_SOURCES.findall(snippet):
+        (all_files, mentioned_files) = (files, set())
+        for match in Base._LIB_SOURCES.findall(snippet):
             mentioned_files |= {file.strip() for file in match.split("#", 1)[0].split(" ") if file.strip()}
         lib_files = {file for file in all_files if file.startswith("lib/")}
         extra_files = {file for file in lib_files if file not in mentioned_files}
         if extra_files:
-            result += ("EXTRA_DIST +=".format("".join(sorted(extra_files))) + "\n")
+            result += ("EXTRA_DIST +={}".format("".join(sorted(extra_files))) + "\n")
 
         # Synthesize also an EXTRA_lib_SOURCES augmentation.
         # This is necessary so that automake can generate the right list of
@@ -311,7 +312,7 @@ class Base:
         if self.name not in {"relocatable-prog-wrapper", "pt_chown"}:
             extra_files = {file for file in extra_files if file.endswith(".c")}
             if extra_files:
-                result += ("EXTRA_lib_SOURCES +=".format("".join(sorted(extra_files))) + "\n")
+                result += ("EXTRA_lib_SOURCES +={}".format("".join(sorted(extra_files))) + "\n")
 
         # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
         buildaux_files = {file for file in all_files if file.startswith("build-aux/")}
@@ -323,6 +324,7 @@ class Base:
 
     @property
     def automake_snippet(self):
+        """full automake snippet (conditional + unconditional parts)"""
         return (self.conditional_automake_snippet + self.unconditional_automake_snippet)
 
 
@@ -523,6 +525,7 @@ def transitive_closure(lookup, modules, **options):
     options may be any combination of gnulib configuration options.
     """
     keywords = frozenset({
+        "gnumake",
         "tests",
         "obsolete",
         "cxx_tests",
@@ -567,7 +570,7 @@ def transitive_closure(lookup, modules, **options):
                         pass # ignore non-existent tests
                 for (dependency, condition) in demander.dependencies:
                     module = lookup(dependency)
-                    if gnumake and condition.startswith("if "):
+                    if options["gnumake"] and condition.startswith("if "):
                         # A module whose Makefile.am snippet contains a reference to an
                         # automake conditional. If we were to use it conditionally, we
                         # would get an error
index 48581ce70e55056d70999f7945ec480aaecdf0db..325231e82c6d4bee7004f21b03c90f52ba5afc47 100644 (file)
@@ -706,6 +706,14 @@ class CommandLine:
                     "dest": "auxdir",
                     "metavar": "DIRECTORY",
                 }),
+                (["--gnu-make"], {
+                    "help": (
+                        "output for GNU Make instead of for the default",
+                        "Automake",
+                    ),
+                    "action": _TrueOption,
+                    "dest": "gnumake",
+                }),
                 (["--lgpl"], {
                     "help": (
                         "abort if modules aren't available under the LGPL;",