overrides = {BaseVFS(override) for override in config.overrides}
for (alias, key) in SUBSTITUTION.items():
path = config[key] if key else ""
- project[alias] = path
- for override in overrides:
- override[alias] = path
+ if path is not None:
+ project[alias] = path
+ for override in overrides:
+ override[alias] = path
gnulib["tests=lib"] = "lib"
# Determine all relevant file lists.
# Find the first parent directory of m4_base that contains or will contain a Makefile.am.
(dir1, dir2) = (config.m4_base, "")
- source_base_makefile = os.path.join(config.source_base, config.makefile_name)
- tests_base_makefile = os.path.join(config.tests_base, config.makefile_name)
+ makefile_name = config.makefile_name
+ makefile_name = "Makefile.am" if makefile_name is None else makefile_name
+ source_base_makefile = os.path.join(config.source_base, makefile_name)
+ tests_base_makefile = os.path.join(config.tests_base, makefile_name)
while dir1 != ".":
path = os.path.join(dir1, "Makefile.am")
if vfs_exists(project, os.path.join(config.root, dir1, "Makefile.am")) \
mkedits.append((dir1, "EXTRA_DIST", os.path.join(dir2, "gnulib-cache.m4")))
# Generate the contents of library makefile.
- path = os.path.join(config.source_base, config.makefile_name)
+ path = os.path.join(config.source_base, makefile_name)
with tempfile.NamedTemporaryFile("w", encoding="UTF-8", delete=False) as tmp:
arguments = {
"path": path,
for path in removed_files:
(directory, name) = os.path.split(path)
items[directory].append(["-", name])
+
+ # Treat gnulib-comp.m4 like an added file, even if it already existed.
+ items["m4"].append(["+", "gnulib-comp.m4"])
+
for directory in sorted(items):
gitignore = os.path.isdir(os.path.join(project.root, ".git"))
cvsignore = os.path.isdir(os.path.join(project.root, "CVS"))
from .error import M4BaseMismatchError as _M4BaseMismatchError
from .misc import Property as _Property
from .misc import PathProperty as _PathProperty
+from .misc import OptionalPathProperty as _OptionalPathProperty
from .misc import BitwiseProperty as _BitwiseProperty
from .misc import StringListProperty as _StringListProperty
from .misc import PathListProperty as _PathListProperty
"overrides" : tuple(),
"source_base" : "lib",
"m4_base" : "m4",
- "po_base" : "",
+ "po_base" : None,
"doc_base" : "doc",
"tests_base" : "tests",
"auxdir" : "build-aux",
"libname" : "libgnu",
- "makefile_name" : "Makefile.am",
+ "makefile_name" : None,
"macro_prefix" : "gl",
"po_domain" : "",
"witness_c_macro" : "",
fset=lambda self, path: self.__set_option("m4_base", path),
doc="directory relative to ROOT where *.m4 macros are placed; defaults to 'm4'",
)
- po_base = _Property(
+ po_base = _OptionalPathProperty(
fget=lambda self: self.__get_option("po_base"),
fset=lambda self, path: self.__set_option("po_base", path),
- check=lambda value: isinstance(value, str),
doc="directory relative to ROOT where *.po files are placed; defaults to 'po'",
)
doc_base = _PathProperty(
check=lambda value: isinstance(value, str) and value,
doc="library name; defaults to 'libgnu'",
)
- makefile_name = _Property(
+ makefile_name = _OptionalPathProperty(
fget=lambda self: self.__get_option("makefile_name"),
fset=lambda self, name: self.__set_option("makefile_name", name),
- check=lambda value: isinstance(value, str) and value,
doc="name of makefile in automake syntax in the source-base and tests-base directories",
)
macro_prefix = _Property(
return super().__set__(obj, val)
+class OptionalPathProperty(PathProperty):
+ def __init__(self, fget=None, fset=None, doc=None):
+ """
+ doc : any arbitrary string
+ fget : function to get the value
+ fset : function to set the value
+
+ def fget(self):
+ return self.path
+
+ def fset(self, path):
+ self.path = path
+ """
+ super().__init__(fget=fget, fset=fset, doc=doc)
+
+
+ def __set__(self, obj, val):
+ if not (val is None or isinstance(val, str)):
+ raise TypeError("value: str or None expected")
+ val = _os.path.normpath(val) if val else None
+ return super(PathProperty, self).__set__(obj, val)
+
+
class BitwiseProperty(Property):
"""bitwise flag property"""