]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 53.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 11 Mar 2024 07:06:18 +0000 (00:06 -0700)
committerBruno Haible <bruno@clisp.org>
Mon, 11 Mar 2024 12:05:09 +0000 (13:05 +0100)
Follow gnulib-tool change
2021-12-21  Bruno Haible  <bruno@clisp.org>
Optimize redundant 'mkdir -p .' invocations.

* pygnulib/GLEmiter.py (_eliminate_NMD_from_line): New private function
to remove @NMD@ occurrences from the line of an Automake snippet.
(_eliminate_NMD): New private function which uses
_eliminate_NMD_from_line on each line of the Automake snippet.
(GLEmiter.lib_Makefile_am, GLEmiter.tests_Makefile_am): Use
_eliminate_NMD on the Automake snippet.

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

index 308f75a4adc83f92a459e00107321810632556fe..cf09ef2da41f5f12ea7c54d1fabfd94719ba2420 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-03-11  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 53.
+       Follow gnulib-tool change
+       2021-12-21  Bruno Haible  <bruno@clisp.org>
+       Optimize redundant 'mkdir -p .' invocations.
+       * pygnulib/GLEmiter.py (_eliminate_NMD_from_line): New private function
+       to remove @NMD@ occurrences from the line of an Automake snippet.
+       (_eliminate_NMD): New private function which uses
+       _eliminate_NMD_from_line on each line of the Automake snippet.
+       (GLEmiter.lib_Makefile_am, GLEmiter.tests_Makefile_am): Use
+       _eliminate_NMD on the Automake snippet.
+
 2024-03-11  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Make some code more straightforward.
index e6c94c8bb842e5c17722418ed0d42da36e7e5403..c3d5d65f5ce925a4dac7cad52e1b2938485456d3 100644 (file)
@@ -207,87 +207,6 @@ Date:   Fri Dec 24 17:22:00 2021 -0800
 
 --------------------------------------------------------------------------------
 
-commit 83a0d5891db50c00e283e70df694b6003b1f485d
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Tue Dec 21 09:59:17 2021 +0100
-
-    Optimize redundant 'mkdir -p .' invocations.
-
-    Reported by Paul Eggert.
-
-    * gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am):
-    Eliminate @NMD@ tokens.
-    * modules/alloca-opt (Makefile.am): Prefix the "$(MKDIR_P) '%reldir%'"
-    line with @NMD@.
-    * modules/argz (Makefile.am): Likewise.
-    * modules/assert-h (Makefile.am): Likewise.
-    * modules/byteswap (Makefile.am): Likewise.
-    * modules/configmake (Makefile.am): Likewise.
-    * modules/ctype (Makefile.am): Likewise.
-    * modules/dirent (Makefile.am): Likewise.
-    * modules/errno (Makefile.am): Likewise.
-    * modules/execinfo (Makefile.am): Likewise.
-    * modules/fcntl-h (Makefile.am): Likewise.
-    * modules/float (Makefile.am): Likewise.
-    * modules/fnmatch-h (Makefile.am): Likewise.
-    * modules/getopt-posix (Makefile.am): Likewise.
-    * modules/glob-h (Makefile.am): Likewise.
-    * modules/iconv-h (Makefile.am): Likewise.
-    * modules/ieee754-h (Makefile.am): Likewise.
-    * modules/inttypes-incomplete (Makefile.am): Likewise.
-    * modules/langinfo (Makefile.am): Likewise.
-    * modules/libtextstyle-optional (Makefile.am): Likewise.
-    * modules/limits-h (Makefile.am): Likewise.
-    * modules/locale (Makefile.am): Likewise.
-    * modules/malloc-h (Makefile.am): Likewise.
-    * modules/math (Makefile.am): Likewise.
-    * modules/monetary (Makefile.am): Likewise.
-    * modules/netdb (Makefile.am): Likewise.
-    * modules/openmp-init (Makefile.am): Likewise.
-    * modules/poll-h (Makefile.am): Likewise.
-    * modules/posix-shell (Makefile.am): Likewise.
-    * modules/pthread-h (Makefile.am): Likewise.
-    * modules/pty (Makefile.am): Likewise.
-    * modules/sched (Makefile.am): Likewise.
-    * modules/search (Makefile.am): Likewise.
-    * modules/signal-h (Makefile.am): Likewise.
-    * modules/sigsegv (Makefile.am): Likewise.
-    * modules/snippet/link-warning (Makefile.am): Likewise.
-    * modules/spawn (Makefile.am): Likewise.
-    * modules/stdalign (Makefile.am): Likewise.
-    * modules/stdarg (Makefile.am): Likewise.
-    * modules/stdbool (Makefile.am): Likewise.
-    * modules/stddef (Makefile.am): Likewise.
-    * modules/stdint (Makefile.am): Likewise.
-    * modules/stdio (Makefile.am): Likewise.
-    * modules/stdlib (Makefile.am): Likewise.
-    * modules/stdnoreturn (Makefile.am): Likewise.
-    * modules/string (Makefile.am): Likewise.
-    * modules/strings (Makefile.am): Likewise.
-    * modules/sysexits (Makefile.am): Likewise.
-    * modules/termios (Makefile.am): Likewise.
-    * modules/threads-h (Makefile.am): Likewise.
-    * modules/time (Makefile.am): Likewise.
-    * modules/uchar (Makefile.am): Likewise.
-    * modules/unicase/base (Makefile.am): Likewise.
-    * modules/uniconv/base (Makefile.am): Likewise.
-    * modules/unictype/base (Makefile.am): Likewise.
-    * modules/unigbrk/base (Makefile.am): Likewise.
-    * modules/unilbrk/base (Makefile.am): Likewise.
-    * modules/uniname/base (Makefile.am): Likewise.
-    * modules/uninorm/base (Makefile.am): Likewise.
-    * modules/unistd (Makefile.am): Likewise.
-    * modules/unistdio/base (Makefile.am): Likewise.
-    * modules/unistr/base (Makefile.am): Likewise.
-    * modules/unitypes (Makefile.am): Likewise.
-    * modules/uniwbrk/base (Makefile.am): Likewise.
-    * modules/uniwidth/base (Makefile.am): Likewise.
-    * modules/utime-h (Makefile.am): Likewise.
-    * modules/wchar (Makefile.am): Likewise.
-    * modules/wctype-h (Makefile.am): Likewise.
-
---------------------------------------------------------------------------------
-
 commit 4bdc327dbda59dcdbfa0f983a4f35c4a4ec3578c
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Sun Dec 19 12:49:16 2021 +0100
index a904aee8ad0fc07e0dfb4adda81c472a2f83ec12..f0ae4627e6474846faf0cd22a7f3c8b6868ae3ee 100644 (file)
@@ -13,6 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+from __future__ import annotations
 #===============================================================================
 # Define global imports
 #===============================================================================
@@ -65,6 +66,27 @@ def _convert_to_gnu_make(snippet: str) -> str:
     return snippet
 
 
+def _eliminate_NMD_from_line(line: str, automake_subdir: bool) -> str | None:
+    '''Eliminate occurrences of @NMD@ from the given line. The modified
+    line is returned or None if the line should be removed.'''
+    if line.startswith('@NMD@'):
+        if automake_subdir:
+            line = line.replace('@NMD@', '')
+        else:
+            line = None
+    return line
+
+
+def _eliminate_NMD(snippet: str, automake_subdir: bool) -> str:
+    '''Return the Automake snippet with occurrences of @NMD@ removed.'''
+    result = []
+    for line in snippet.splitlines():
+        line = _eliminate_NMD_from_line(line, automake_subdir)
+        if line != None:
+            result.append(line)
+    return '\n'.join(result) + '\n'
+
+
 #===============================================================================
 # Define GLEmiter class
 #===============================================================================
@@ -694,6 +716,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         auxdir = self.config['auxdir']
         gnu_make = self.config['gnu_make']
         makefile_name = self.config['makefile_name']
+        automake_subdir = self.config['automake_subdir']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
         podomain = self.config['podomain']
@@ -747,6 +770,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 if eliminate_LDFLAGS:
                     pattern = re.compile('^(lib_LDFLAGS[\t ]*\\+=.*$\n)', re.M)
                     amsnippet1 = pattern.sub('', amsnippet1)
+                # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
+                # The logic is similar to how we define gl_source_base_prefix.
+                amsnippet1 = _eliminate_NMD(amsnippet1, automake_subdir)
                 pattern = re.compile('lib_([A-Z][A-Z]*)', re.M)
                 amsnippet1 = pattern.sub('%s_%s_\\1' % (libname, libext),
                                          amsnippet1)
@@ -1047,6 +1073,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                 if eliminate_LDFLAGS:
                     pattern = re.compile('^(lib_LDFLAGS[\t ]*\\+=.*$\n)', re.M)
                     amsnippet1 = pattern.sub('', amsnippet1)
+                # Replace NMD, so as to remove redundant "$(MKDIR_P) '.'" invocations.
+                # The logic is similar to how we define gl_source_base_prefix.
+                amsnippet1 = _eliminate_NMD(amsnippet1, False)
                 pattern = re.compile('lib_([A-Z][A-Z]*)', re.M)
                 amsnippet1 = pattern.sub('libtests_a_\\1', amsnippet1)
                 amsnippet1 = amsnippet1.replace('$(GNULIB_', '$(' + module_indicator_prefix + '_GNULIB_')