summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2020-03-05 11:57:51 -0800
committerDan Albert <danalbert@google.com>2020-03-05 11:59:42 -0800
commit429959397e24bdf23aad6a51abada533986a7372 (patch)
treecb90db4ba9ecfe51dbc1b56b5676df945366ad35
parent4f6a469cc70099ae394111251c4fb4b3bc44ddf4 (diff)
downloadbinutils-429959397e24bdf23aad6a51abada533986a7372.tar.gz
Preserve any config logs on failure.
Test: replaced cc with ar, saw logs in dist dir Bug: None Change-Id: I5a20387d738290975188cb9cfbc14c74e2e07420
-rw-r--r--OWNERS2
-rwxr-xr-xdo_build.py18
2 files changed, 20 insertions, 0 deletions
diff --git a/OWNERS b/OWNERS
index 88b3a39e..8fbd6c9b 100644
--- a/OWNERS
+++ b/OWNERS
@@ -4,3 +4,5 @@ llozano@google.com
manojgupta@google.com
rahulchaudhry@google.com
yunlian@google.com
+
+per-file *.py = danalbert@google.com
diff --git a/do_build.py b/do_build.py
index a23fa4f2..1067c99c 100755
--- a/do_build.py
+++ b/do_build.py
@@ -19,6 +19,7 @@ import argparse
import logging
import multiprocessing
import os
+from pathlib import Path
import shutil
import site
import subprocess
@@ -187,6 +188,20 @@ def dist(dist_dir, base_dir, package_name):
subprocess.check_call(cmd)
+def copy_logs_to_dist_dir(build_dir: Path, base_log_dir: Path) -> None:
+ """Preserves any relevant log files from the build directory."""
+ log_file = 'config.log'
+ log_dir = base_log_dir / 'autoconf'
+ for root, _, files in os.walk(build_dir):
+ root_path = Path(root)
+ if log_file not in files:
+ continue
+ rel_path = Path(root).relative_to(build_dir)
+ dest_dir = log_dir / rel_path
+ dest_dir.mkdir(parents=True, exist_ok=True)
+ shutil.copyfile(str(root_path / log_file), str(dest_dir / log_file))
+
+
def parse_args():
"""Parse command line arguments."""
parser = argparse.ArgumentParser()
@@ -259,6 +274,9 @@ def main():
install_timer = ndk.timer.Timer()
with install_timer:
install(args.jobs, args.arch, args.host, install_dir)
+ except subprocess.CalledProcessError:
+ copy_logs_to_dist_dir(Path(build_dir), Path(dist_dir) / 'logs')
+ raise
finally:
chdir(orig_dir)