]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 47.
authorCollin Funk <collin.funk1@gmail.com>
Fri, 8 Mar 2024 09:43:26 +0000 (01:43 -0800)
committerBruno Haible <bruno@clisp.org>
Fri, 8 Mar 2024 11:54:54 +0000 (12:54 +0100)
Follow gnulib-tool changes
2021-12-15  Bruno Haible  <bruno@clisp.org>
Fix creation of build directories with non-recursive-gnulib-prefix-hack.
2021-12-18  Bruno Haible  <bruno@clisp.org>
Fix support for --gnu-make in tests (regression 2021-12-15).

* pygnulib/GLEmiter.py (_CONVERT_TO_GNU_MAKE): New variable which is a
list of tuples which are used with re.sub.
(_convert_to_gnu_make): New function which converts an input snippet
from Automake to GNU Make syntax using the regular expressions stored in
_CONVERT_TO_GNU_MAKE.
(GLEmiter.lib_Makefile_am): Use _convert_to_gnu_make. Replace '%reldir%'
tokens.
(GLEmiter.tests_Makefile_am): Likewise.

ChangeLog
gnulib-tool.py.TODO
pygnulib/GLEmiter.py

index f85da3af66dbdf3eea467ea2c7630a20e2055b13..de0cd2ad639ac2ba202bed1468d3524eb6e55a91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2024-03-08  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 47.
+       Follow gnulib-tool changes
+       2021-12-15  Bruno Haible  <bruno@clisp.org>
+       Fix creation of build directories with non-recursive-gnulib-prefix-hack.
+       2021-12-18  Bruno Haible  <bruno@clisp.org>
+       Fix support for --gnu-make in tests (regression 2021-12-15).
+       * pygnulib/GLEmiter.py (_CONVERT_TO_GNU_MAKE): New variable which is a
+       list of tuples which are used with re.sub.
+       (_convert_to_gnu_make): New function which converts an input snippet
+       from Automake to GNU Make syntax using the regular expressions stored in
+       _CONVERT_TO_GNU_MAKE.
+       (GLEmiter.lib_Makefile_am): Use _convert_to_gnu_make. Replace '%reldir%'
+       tokens.
+       (GLEmiter.tests_Makefile_am): Likewise.
+
 2024-03-07  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Fix errors when executing --create-megatestdir.
index a2414115aa38392ce25a1cd7e900c75dc78fcc13..8918d58a8800a1969e99a45de63fb6241d38fdd3 100644 (file)
@@ -344,119 +344,6 @@ Date:   Wed Dec 15 19:18:31 2021 +0100
 
 --------------------------------------------------------------------------------
 
-commit eafd9cd7bf13be7e99a30188b3675aa4047b9307
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Sat Dec 18 14:10:19 2021 +0100
-
-    Fix support for --gnu-make in tests (regression 2021-12-15).
-
-    * gnulib-tool (func_emit_tests_Makefile_am): When producing output for
-    GNU make, eliminate %reldir% tokens.
-
-commit 766ec17a90f67e8cda78394e58a7fffb00f5a4b7
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Wed Dec 15 19:18:20 2021 +0100
-
-    Fix creation of build directories with non-recursive-gnulib-prefix-hack.
-
-    This is necessary for executing "make" in a VPATH build of a package
-    that uses prefix-gnulib-mk and a module such as alloca-opt.
-
-    * modules/alloca-opt (Makefile.am): Before generating the .h-t file,
-    ensure that the directory in which we want to create it exists.
-    (configure.ac): Invoke AC_PROG_MKDIR_P.
-    * modules/argz: Likewise.
-    * modules/arpa_inet: Likewise.
-    * modules/assert-h: Likewise.
-    * modules/byteswap: Likewise.
-    * modules/configmake: Likewise.
-    * modules/ctype: Likewise.
-    * modules/dirent: Likewise.
-    * modules/dynarray: Likewise.
-    * modules/errno: Likewise.
-    * modules/execinfo: Likewise.
-    * modules/fcntl-h: Likewise.
-    * modules/float: Likewise.
-    * modules/fnmatch-h: Likewise.
-    * modules/getopt-posix: Likewise.
-    * modules/glob-h: Likewise.
-    * modules/iconv-h: Likewise.
-    * modules/ieee754-h: Likewise.
-    * modules/inttypes-incomplete: Likewise.
-    * modules/langinfo: Likewise.
-    * modules/libgmp: Likewise.
-    * modules/libtextstyle-optional: Likewise.
-    * modules/limits-h: Likewise.
-    * modules/locale: Likewise.
-    * modules/malloc-h: Likewise.
-    * modules/math: Likewise.
-    * modules/monetary: Likewise.
-    * modules/net_if: Likewise.
-    * modules/netdb: Likewise.
-    * modules/netinet_in: Likewise.
-    * modules/openmp-init: Likewise.
-    * modules/poll-h: Likewise.
-    * modules/posix-shell: Likewise.
-    * modules/pthread-h: Likewise.
-    * modules/pty: Likewise.
-    * modules/sched: Likewise.
-    * modules/scratch_buffer: Likewise.
-    * modules/search: Likewise.
-    * modules/selinux-h: Likewise.
-    * modules/signal-h: Likewise.
-    * modules/sigsegv: Likewise.
-    * modules/snippet/link-warning: Likewise.
-    * modules/spawn: Likewise.
-    * modules/stdalign: Likewise.
-    * modules/stdarg: Likewise.
-    * modules/stdbool: Likewise.
-    * modules/stddef: Likewise.
-    * modules/stdint: Likewise.
-    * modules/stdio: Likewise.
-    * modules/stdlib: Likewise.
-    * modules/stdnoreturn: Likewise.
-    * modules/string: Likewise.
-    * modules/strings: Likewise.
-    * modules/sys_file: Likewise.
-    * modules/sys_ioctl: Likewise.
-    * modules/sys_random: Likewise.
-    * modules/sys_resource: Likewise.
-    * modules/sys_select: Likewise.
-    * modules/sys_socket: Likewise.
-    * modules/sys_stat: Likewise.
-    * modules/sys_time: Likewise.
-    * modules/sys_times: Likewise.
-    * modules/sys_types: Likewise.
-    * modules/sys_uio: Likewise.
-    * modules/sys_utsname: Likewise.
-    * modules/sys_wait: Likewise.
-    * modules/sysexits: Likewise.
-    * modules/termios: Likewise.
-    * modules/threads-h: Likewise.
-    * modules/time: Likewise.
-    * modules/uchar: Likewise.
-    * modules/unicase/base: Likewise.
-    * modules/unicase/special-casing: Likewise.
-    * modules/uniconv/base: Likewise.
-    * modules/unictype/base: Likewise.
-    * modules/unigbrk/base: Likewise.
-    * modules/unilbrk/base: Likewise.
-    * modules/uniname/base: Likewise.
-    * modules/uninorm/base: Likewise.
-    * modules/unistd: Likewise.
-    * modules/unistdio/base: Likewise.
-    * modules/unistr/base: Likewise.
-    * modules/unitypes: Likewise.
-    * modules/uniwbrk/base: Likewise.
-    * modules/uniwidth/base: Likewise.
-    * modules/utime-h: Likewise.
-    * modules/wchar: Likewise.
-    * modules/wctype-h: Likewise.
-    * gnulib-tool (func_emit_lib_Makefile_am): When producing output for
-    GNU make, eliminate %reldir% tokens.
-
---------------------------------------------------------------------------------
-
 commit dc08febea1fc0a8c902dfa89d0abc2952873529b
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Mon Dec 13 03:03:13 2021 +0100
index 3545d9801845965bf00d07d2b8cfbd098d45698e..d4499df2583e33c991bfe11343cd322b7474148e 100644 (file)
@@ -47,6 +47,23 @@ relinverse = constants.relinverse
 isfile = os.path.isfile
 normpath = os.path.normpath
 
+# Regular expressions used to convert Automake conditionals to GNU Make syntax.
+# Each tuple is the arguments given to re.sub in the correct order.
+_CONVERT_TO_GNU_MAKE = [
+    (re.compile(r'^if (.*)', re.MULTILINE), r'ifneq (,$(\1_CONDITION))'),
+    (re.compile(r'%reldir%/'), r''),
+    (re.compile(r'%reldir%'), r'.')
+]
+
+
+def _convert_to_gnu_make(snippet: str) -> str:
+    '''Convert a Automake snippet to GNU Make syntax.'''
+    if type(snippet) is not str:
+        raise TypeError(f'snippet must be a str, not {type(snippet).__name__}')
+    for regexp in _CONVERT_TO_GNU_MAKE:
+        snippet = re.sub(regexp[0], regexp[1], snippet)
+    return snippet
+
 
 #===============================================================================
 # Define GLEmiter class
@@ -651,7 +668,6 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
         ac_version = self.config['ac_version']
         destfile = os.path.normpath(destfile)
-        convert_to_gnu_make_1 = (re.compile(r'^if (.*)', re.MULTILINE), r'ifneq (,$(\1_CONDITION))')
         emit = ''
 
         # When using GNU make, or when creating an includable Makefile.am snippet,
@@ -733,14 +749,14 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                             else:
                                 allsnippets += 'if %s\n' % name
                     if gnu_make:
-                        allsnippets += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet1)
+                        allsnippets += _convert_to_gnu_make(amsnippet1)
                     else:
                         allsnippets += amsnippet1
                     if conddeps:
                         if moduletable.isConditional(module):
                             allsnippets += 'endif\n'
                     if gnu_make:
-                        allsnippets += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet2)
+                        allsnippets += _convert_to_gnu_make(amsnippet2)
                     else:
                         allsnippets += amsnippet2
                     if gnu_make:
@@ -954,7 +970,6 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         ac_version = self.config['ac_version']
         libtests = self.config['libtests']
         single_configure = self.config['single_configure']
-        convert_to_gnu_make_1 = (re.compile(r'^if (.*)', re.MULTILINE), r'ifneq (,$(\1_CONDITION))')
         emit = ''
 
         if libtool:
@@ -1034,14 +1049,14 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                             else:
                                 snippet += 'if %s\n' % name
                     if gnu_make:
-                        snippet += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet1)
+                        snippet += _convert_to_gnu_make(amsnippet1)
                     else:
                         snippet += amsnippet1
                     if conddeps:
                         if moduletable.isConditional(module):
                             snippet += 'endif\n'
                     if gnu_make:
-                        snippet += re.sub(convert_to_gnu_make_1[0], convert_to_gnu_make_1[1], amsnippet2)
+                        snippet += _convert_to_gnu_make(amsnippet2)
                     else:
                         snippet += amsnippet2
                     if gnu_make: