From: Collin Funk Date: Mon, 11 Mar 2024 07:06:18 +0000 (-0700) Subject: gnulib-tool.py: Follow gnulib-tool changes, part 53. X-Git-Tag: v1.0~300 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=81fa24dab16100eecde8c7b52dc2ed6e11754d8a;p=gnulib.git gnulib-tool.py: Follow gnulib-tool changes, part 53. Follow gnulib-tool change 2021-12-21 Bruno Haible 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. --- diff --git a/ChangeLog b/ChangeLog index 308f75a4ad..cf09ef2da4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2024-03-11 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 53. + Follow gnulib-tool change + 2021-12-21 Bruno Haible + 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 gnulib-tool.py: Make some code more straightforward. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index e6c94c8bb8..c3d5d65f5c 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -207,87 +207,6 @@ Date: Fri Dec 24 17:22:00 2021 -0800 -------------------------------------------------------------------------------- -commit 83a0d5891db50c00e283e70df694b6003b1f485d -Author: Bruno Haible -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 Date: Sun Dec 19 12:49:16 2021 +0100 diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index a904aee8ad..f0ae4627e6 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +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_')