From d32ed194e85d567d298c994e90cc5a17516cb487 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Fri, 13 Aug 2021 18:52:00 +0200
Subject: [PATCH] python/build/autotools.py: dump config.log on configure error

For better error logs on CI.
---
 python/build/autotools.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/python/build/autotools.py b/python/build/autotools.py
index b6421dbaf..6cd484f3a 100644
--- a/python/build/autotools.py
+++ b/python/build/autotools.py
@@ -52,7 +52,18 @@ class AutotoolsProject(MakeProject):
             '--enable-silent-rules',
         ] + self.configure_args
 
-        subprocess.check_call(configure, cwd=build, env=toolchain.env)
+        try:
+            subprocess.check_call(configure, cwd=build, env=toolchain.env)
+        except subprocess.CalledProcessError:
+            # dump config.log after a failed configure run
+            try:
+                with open(os.path.join(build, 'config.log')) as f:
+                    sys.stdout.write(f.read())
+            except:
+                pass
+            # re-raise the exception
+            raise
+
         return build
 
     def _build(self, toolchain):