]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool: Add undocumented option --gnulib-dir.
authorBruno Haible <bruno@clisp.org>
Sun, 17 Mar 2024 12:46:04 +0000 (13:46 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 17 Mar 2024 12:46:04 +0000 (13:46 +0100)
* 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'].

ChangeLog
gnulib-tool.sh
pygnulib/GLImport.py
pygnulib/constants.py
pygnulib/main.py

index 6ab70181bbd28d998a2d069c48dc3625d8f63054..e64d11c1781db5a2d5acc41dea4187791d3e8148 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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'].
+
 2024-03-17  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Follow gnulib-tool changes, part 61.
index 62039fb03bbce7a4db2cfe8bf982582b035cb8fc..96869f80d65b6772c85f0d492797175a175b41af 100755 (executable)
@@ -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
index c65ba7d3f7978ddfc37f9755ed42256affea2399..c06f0f9f6b19e50f97e7c82af3d19f8f7d5d54d6 100644 (file)
@@ -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:
index dc2e68069d6cfaca6b3a2629ebac0c8556084e91..975b0e7da2378ca3f4baaf66e51a7166e4484dd5 100644 (file)
@@ -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 = \
index 5d88d0115ae10679fa66d9d7b3b2b7daa3578853..7142414fb2decc22bfda66dbec727b8c5593a8f8 100644 (file)
@@ -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