[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool: Add undocumented option --gnulib-dir
|
From: |
Bruno Haible |
|
Subject: |
gnulib-tool: Add undocumented option --gnulib-dir |
|
Date: |
Sun, 17 Mar 2024 17:48:35 +0100 |
The gnulib-tool test suite will need this option, in order to use the
newest gnulib-tool with a frozen-in-time set of gnulib modules.
2024-03-17 Bruno Haible <bruno@clisp.org>
gnulib-tool: Add undocumented option --gnulib-dir.
* gnulib-tool.sh: Accept --gnulib-dir=... option.
* pygnulib/constants.py (init_DIRS): New function.
* pygnulib/main.py (main): Accept --gnulib-dir=... option. Invoke
init_DIRS. Expect .git directory to be present in DIRS['root'], not
APP['root'].
* pygnulib/GLImport.py (GLImport.execute): Use DIRS['root'], not
APP['root'].
diff --git a/gnulib-tool.sh b/gnulib-tool.sh
index 62039fb03b..96869f80d6 100755
--- a/gnulib-tool.sh
+++ b/gnulib-tool.sh
@@ -1526,6 +1526,10 @@ func_determine_path_separator
--version | --versio | --versi | --vers )
func_version
func_exit $? ;;
+ # Undocumented option. Only used for the gnulib-tool test suite.
+ --gnulib-dir=* )
+ gnulib_dir=`echo "X$1" | sed -e 's/^X--gnulib-dir=//'`
+ shift ;;
-- )
# Stop option processing
shift
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index c65ba7d3f7..c06f0f9f6b 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1191,7 +1191,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
self.moduletable['main'], self.moduletable, self.makefiletable,
actioncmd, for_test)
if automake_subdir:
- emit = sp.run([joinpath(APP['root'],
'build-aux/prefix-gnulib-mk'), '--from-gnulib-tool',
+ emit = sp.run([joinpath(DIRS['root'],
'build-aux/prefix-gnulib-mk'), '--from-gnulib-tool',
f'--lib-name={libname}', f'--prefix={sourcebase}/'],
input=emit, text=True, capture_output=True).stdout
with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index dc2e68069d..975b0e7da2 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -77,17 +77,18 @@ APP['root'] = os.path.dirname(os.path.dirname(APP['path']))
# file name of <gnul
APP['name'] = os.path.join(APP['root'], 'gnulib-tool.py')
# Set DIRS directory
-DIRS['root'] = APP['root']
DIRS['cwd'] = os.getcwd()
-DIRS['build-aux'] = os.path.join(DIRS['root'], 'build-aux')
-DIRS['config'] = os.path.join(DIRS['root'], 'config')
-DIRS['doc'] = os.path.join(DIRS['root'], 'doc')
-DIRS['lib'] = os.path.join(DIRS['root'], 'lib')
-DIRS['m4'] = os.path.join(DIRS['root'], 'm4')
-DIRS['modules'] = os.path.join(DIRS['root'], 'modules')
-DIRS['tests'] = os.path.join(DIRS['root'], 'tests')
-DIRS['git'] = os.path.join(DIRS['root'], '.git')
-DIRS['cvs'] = os.path.join(DIRS['root'], 'CVS')
+def init_DIRS(gnulib_dir):
+ DIRS['root'] = gnulib_dir
+ DIRS['build-aux'] = os.path.join(gnulib_dir, 'build-aux')
+ DIRS['config'] = os.path.join(gnulib_dir, 'config')
+ DIRS['doc'] = os.path.join(gnulib_dir, 'doc')
+ DIRS['lib'] = os.path.join(gnulib_dir, 'lib')
+ DIRS['m4'] = os.path.join(gnulib_dir, 'm4')
+ DIRS['modules'] = os.path.join(gnulib_dir, 'modules')
+ DIRS['tests'] = os.path.join(gnulib_dir, 'tests')
+ DIRS['git'] = os.path.join(gnulib_dir, '.git')
+ DIRS['cvs'] = os.path.join(gnulib_dir, 'CVS')
# Set MODES dictionary
MODES = \
diff --git a/pygnulib/main.py b/pygnulib/main.py
index 5d88d0115a..7142414fb2 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -455,6 +455,11 @@ def main():
dest='lcopymode',
default=None,
action='store_const',
const=classes.CopyAction.Hardlink)
+ # Undocumented option. Only used for the gnulib-tool test suite.
+ parser.add_argument('--gnulib-dir',
+ dest='gnulib_dir',
+ default=None,
+ nargs=1)
# All other arguments are collected.
parser.add_argument("non_option_arguments",
nargs='*')
@@ -463,6 +468,14 @@ def main():
# occur between or after options.
cmdargs, unhandled = parser.parse_known_args()
+ # Handle --gnulib-dir and finalize DIRS.
+ gnulib_dir = cmdargs.gnulib_dir
+ if gnulib_dir != None:
+ gnulib_dir = gnulib_dir[0]
+ else:
+ gnulib_dir = APP['root']
+ constants.init_DIRS(gnulib_dir)
+
# Handle --help and --version, ignoring all other options.
if cmdargs.help != None:
print(info.usage())
@@ -1284,10 +1297,10 @@ def main():
# This disturbs the result of the next "gitk" invocation.
# Workaround: Let git scan the files. This can be done through
# "git update-index --refresh" or "git status" or "git diff".
- if isdir(joinpath(APP['root'], '.git')):
+ if isdir(joinpath(DIRS['root'], '.git')):
try:
sp.run(['git', 'update-index', '--refresh'],
- cwd=APP['root'], stdout=sp.DEVNULL)
+ cwd=DIRS['root'], stdout=sp.DEVNULL)
except FileNotFoundError:
# No 'git' program was found.
pass
- gnulib-tool: Add undocumented option --gnulib-dir,
Bruno Haible <=