From 5951d7c55eb31c7892349fc468d989d5fba8a422 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 26 Mar 2024 15:43:21 -0700 Subject: [PATCH] gnulib-tool.py: Allow the use of both configure.ac and configure.in. * pygnulib/GLImport.py (GLImport.__init__): Remove redundant checks for configure.ac and configure.in. * pygnulib/main.py (main): Check for configure.ac and configure.in before reading it. Pass it to GLImport using the GLConfig object. --- ChangeLog | 8 ++++++++ pygnulib/GLImport.py | 8 +------- pygnulib/main.py | 13 ++++++++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94fc26fb44..e70c0e9271 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-03-26 Collin Funk + + gnulib-tool.py: Allow the use of both configure.ac and configure.in. + * pygnulib/GLImport.py (GLImport.__init__): Remove redundant checks for + configure.ac and configure.in. + * pygnulib/main.py (main): Check for configure.ac and configure.in + before reading it. Pass it to GLImport using the GLConfig object. + 2024-03-26 Bruno Haible gettime-res: Fix test failure on Solaris 11.4/SPARC. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 1a45776f4f..d7d820f8d1 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -89,13 +89,7 @@ class GLImport(object): # Get cached auxdir and libtool from configure.ac/in. self.cache.setAuxDir('.') - path = joinpath(self.config['destdir'], 'configure.ac') - if not isfile(path): - path = joinpath(self.config['destdir'], 'configure.in') - if not isfile(path): - raise GLError(3, path) - self.config.setAutoconfFile(path) - with codecs.open(path, 'rb', 'UTF-8') as file: + with codecs.open(self.config.getAutoconfFile(), 'rb', 'UTF-8') as file: data = file.read() pattern = re.compile(r'^AC_CONFIG_AUX_DIR\((.*)\)$', re.M) match = pattern.findall(data) diff --git a/pygnulib/main.py b/pygnulib/main.py index c83612d91f..204050facb 100644 --- a/pygnulib/main.py +++ b/pygnulib/main.py @@ -886,8 +886,19 @@ def main(): destdir = '.' config.setDestDir(destdir) + # Prefer configure.ac but also look for configure.in. + if isfile(joinpath(destdir, 'configure.ac')): + configure_ac = joinpath(destdir, 'configure.ac') + elif isfile(joinpath(destdir, 'configure.in')): + configure_ac = joinpath(destdir, 'configure.in') + else: + raise classes.GLError(3, joinpath(destdir, 'configure.ac')) + + # Save the Autoconf file path for the rest of the import. + config.setAutoconfFile(configure_ac) + # Analyze configure.ac. - with open(joinpath(destdir, 'configure.ac'), 'r', encoding='utf-8') as file: + with open(configure_ac, 'r', encoding='utf-8') as file: configure_ac_data = file.read() guessed_m4dirs = [] -- 2.44.0