[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool.py: Don't default to 'build-aux' for --auxdir.
From: |
Collin Funk |
Subject: |
gnulib-tool.py: Don't default to 'build-aux' for --auxdir. |
Date: |
Mon, 1 Apr 2024 19:49:12 -0700 |
User-agent: |
Mozilla Thunderbird |
Hi Bruno,
On 4/1/24 3:11 PM, Bruno Haible wrote:
> The problem happens here:
>
> # Update configuration dictionary.
> self.config.update(self.cache) # HERE the value is set to
> 'autotools'
> for key in config.keys():
> value = config[key]
> if not config.isdefault(key, value): # HERE 'build-aux' is
> not considered to be the default
> self.config.update_key(config, key) # HERE 'autotools'
> gets overwritten with 'build-aux'
>
> Here I would revisit the entire 'auxdir' handling.
Let me know how this patch is. I am assuming that setting 'auxdir' to
default to 'build-aux' is incorrect. Basing this on your comment and
lines 7251-7274 in gnulib-tool.sh:
# Analyze configure.ac.
guessed_auxdir="."
guessed_libtool=false
...
/AC_CONFIG_AUX_DIR/ {
s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
}
...
if test -z "$auxdir"; then
auxdir="$guessed_auxdir"
fi
I think that this means if no --auxdir is passed to gnulib-tool, use
whatever is found in 'AC_CONFIG_AUX_DIR' of configure.ac. If not found
use the destination directory.
It seems that GLConfig.__getitem__(), used for indexing [1] would
always return 'build-aux' when given the 'auxdir' key.
I've also removed some unused code. The result variable was not used
and we only accept string keys.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 80719d35f2..ab967ec321 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -251,13 +251,6 @@ class GLConfig(object):
def __getitem__(self, y: str) -> str | float | int | bool | CopyAction |
list[str] | None:
'''x.__getitem__(y) <==> x[y]'''
if y in self.table:
- result = self.table[y]
- if type(y) is list:
- result = list(self.table[y])
- if y == "auxdir":
- if self.table['auxdir']:
- return self.table['auxdir']
- return "build-aux"
return self.table[y]
else: # if y not in self.table
raise KeyError('GLConfig does not contain key: %s' % repr(y))
This broke a few import tests. Changing this line solves the issue.
This is because keys not explicitly mentioned in GLImport.default()
return an empty string not None.
In this case we check if --auxdir is given (self.config). If not we
use what is read from configure.ac (self.cache).
This is initialized to '.' like in gnulib-tool.sh in GLImport.py
line 93:
# Get cached auxdir and libtool from configure.ac/in.
self.cache.setAuxDir('.')
though it shouldn't matter since joinpath(destdir, '.') and
joinpath(destdir, '') should be the same.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 0adfd8a73c..893494a70a 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -100,7 +100,7 @@ class GLImport(object):
self.cache.setAuxDir(joinpath(self.config['destdir'], result))
pattern = re.compile(r'A[CM]_PROG_LIBTOOL', re.M)
guessed_libtool = bool(pattern.findall(data))
- if self.config['auxdir'] == None:
+ if self.config['auxdir'] == '':
self.config.setAuxDir(self.cache['auxdir'])
# Guess autoconf version.
This seems correct to me since all tests still pass and in freedink:
env GNULIB_TOOL_IMPL=sh+py gnulib-tool ./bootstrap
works correctly.
[1] https://docs.python.org/3/reference/datamodel.html#slice-objects
Collin
0001-gnulib-tool.py-Don-t-default-to-build-aux-for-auxdir.patch
Description: Text Data