From 21f0eb332faddeb88a0f3e9788f83b6f9c22071c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:31 -0600 Subject: buildman: Tidy up the 'cloning' message On a machine with a lot of CPUs this prints a lot of useless lines of the form: Cloning repo for thread Adjust the output so that these all appear on one line, and disappear when the cloning is complete. Note: This cloning is actually unnecessary and very wasteful on disk space (about 3.5GB each time). It would be better to create symlinks. Signed-off-by: Simon Glass --- tools/buildman/builder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/buildman/builder.py') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 8ec35517290..4a24f744fe2 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1366,8 +1366,10 @@ class Builder: if os.path.exists(git_dir): gitutil.Fetch(git_dir, thread_dir) else: - Print('Cloning repo for thread %d' % thread_num) + Print('\rCloning repo for thread %d' % thread_num, + newline=False) gitutil.Clone(src_dir, thread_dir) + Print('\r%s\r' % (' ' * 30), newline=False) def _PrepareWorkingSpace(self, max_threads, setup_git): """Prepare the working directory for use. -- cgit v1.2.3 From b222abe736e4ea61e7c61dee412fb80d840b5111 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:32 -0600 Subject: buildman: Print a message when removing old directories When buildman starts, it prepares its output directory by removing any old build directories which will not be used this time. This can happen if a previous build left directories around for commit hashes which are no-longer part of the branch. This can take quite a while, so print a message to indicate what is going on. Signed-off-by: Simon Glass --- tools/buildman/builder.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/buildman/builder.py') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 4a24f744fe2..da2a0a12813 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1397,8 +1397,14 @@ class Builder: for commit_upto in range(self.commit_count): dir_list.append(self._GetOutputDir(commit_upto)) + to_remove = [] for dirname in glob.glob(os.path.join(self.base_dir, '*')): if dirname not in dir_list: + to_remove.append(dirname) + if to_remove: + Print('Removing %d old build directories' % len(to_remove), + newline=False) + for dirname in to_remove: shutil.rmtree(dirname) def BuildBoards(self, commits, board_selected, keep_outputs, verbose): -- cgit v1.2.3 From 745b395aefcd7e4718f6f51167c0e462931842b6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:33 -0600 Subject: buildman: Print a message indicating the build is starting Make it clear when buildman actually starts building. This happens when it has prepared the threads, working directory and output directories. Signed-off-by: Simon Glass --- tools/buildman/builder.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/buildman/builder.py') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index da2a0a12813..384f053015e 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -1430,6 +1430,7 @@ class Builder: self._PrepareWorkingSpace(min(self.num_threads, len(board_selected)), commits is not None) self._PrepareOutputSpace() + Print('\rStarting build...', newline=False) self.SetupBuild(board_selected, commits) self.ProcessResult(None) -- cgit v1.2.3 From d436e38189a26227274a3014d3d838eb3f183488 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:35 -0600 Subject: buildman: Allow builds to terminate cleanly It is annoying that buildman does not respond cleanly to Ctrl-C or SIGINT, particularly on machines with lots of CPUS. Unfortunately queue.join() blocks the main thread and does not allow it to see the signal. Use a separate thread instead, Signed-off-by: Simon Glass --- tools/buildman/builder.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tools/buildman/builder.py') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 384f053015e..44d1cfa5175 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -14,6 +14,7 @@ import Queue import shutil import string import sys +import threading import time import builderthread @@ -1443,8 +1444,11 @@ class Builder: job.step = self._step self.queue.put(job) - # Wait until all jobs are started - self.queue.join() + term = threading.Thread(target=self.queue.join) + term.setDaemon(True) + term.start() + while term.isAlive(): + term.join(100) # Wait until we have processed all output self.out_queue.join() -- cgit v1.2.3 From 63781bd65e70719dbab9f2f5bbe8aac7b8e0f13e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:36 -0600 Subject: buildman: Drop the 'active' flag in the builder This serves no real purpose, since when we are not active, we exit. Drop it. Signed-off-by: Simon Glass --- tools/buildman/builder.py | 7 ------- 1 file changed, 7 deletions(-) (limited to 'tools/buildman/builder.py') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 44d1cfa5175..5addbca44e9 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -127,7 +127,6 @@ class Builder: """Class for building U-Boot for a particular commit. Public members: (many should ->private) - active: True if the builder is active and has not been stopped already_done: Number of builds already completed base_dir: Base directory to use for builder checkout: True to check out source, False to skip that step. @@ -235,7 +234,6 @@ class Builder: self.base_dir = base_dir self._working_dir = os.path.join(base_dir, '.bm-work') self.threads = [] - self.active = True self.do_make = self.Make self.gnu_make = gnu_make self.checkout = checkout @@ -390,11 +388,6 @@ class Builder: if result: target = result.brd.target - if result.return_code < 0: - self.active = False - command.StopAll() - return - self.upto += 1 if result.return_code != 0: self.fail += 1 -- cgit v1.2.3 From 2f2566482fc5c24557126043394ce82088f60262 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Sep 2016 16:48:37 -0600 Subject: buildman: Don't show a stacktrace on Ctrl-C When Ctrl-C is pressed, just exited quietly. There is no sense in displaying a stack trace since buildman will always be in the same place: waiting for threads to complete building all the jobs on the queue. Signed-off-by: Simon Glass --- tools/buildman/builder.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools/buildman/builder.py') diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 5addbca44e9..e27a28577c2 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -12,6 +12,7 @@ import os import re import Queue import shutil +import signal import string import sys import threading @@ -282,11 +283,17 @@ class Builder: ignore_lines = ['(make.*Waiting for unfinished)', '(Segmentation fault)'] self.re_make_err = re.compile('|'.join(ignore_lines)) + # Handle existing graceful with SIGINT / Ctrl-C + signal.signal(signal.SIGINT, self.signal_handler) + def __del__(self): """Get rid of all threads created by the builder""" for t in self.threads: del t + def signal_handler(self, signal, frame): + sys.exit(1) + def SetDisplayOptions(self, show_errors=False, show_sizes=False, show_detail=False, show_bloat=False, list_error_boards=False, show_config=False): -- cgit v1.2.3