From c10fbab8aaa6330879d02287e524a2672f222b07 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Tue, 5 Dec 2017 21:12:50 +0300 Subject: [PATCH] module: gnumake support; code cleanup --- pygnulib/config.py | 1 + pygnulib/module.py | 15 +++++++++------ pygnulib/parser.py | 8 ++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pygnulib/config.py b/pygnulib/config.py index 5787eb73a3..ecaadbf183 100644 --- a/pygnulib/config.py +++ b/pygnulib/config.py @@ -65,6 +65,7 @@ class Base: "files" : set(), "copymode" : None, "local_copymode" : None, + "gnumake" : False, } _OPTIONS = frozenset({ "tests", diff --git a/pygnulib/module.py b/pygnulib/module.py index 7bc1b18469..4f8caa9b37 100644 --- a/pygnulib/module.py +++ b/pygnulib/module.py @@ -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 diff --git a/pygnulib/parser.py b/pygnulib/parser.py index 48581ce70e..325231e82c 100644 --- a/pygnulib/parser.py +++ b/pygnulib/parser.py @@ -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;", -- 2.39.5