Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF36DC0015E for ; Sun, 16 Jul 2023 00:49:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5D2918671C; Sun, 16 Jul 2023 02:40:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="N/KaLV52"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C5558664A; Sun, 16 Jul 2023 02:38:38 +0200 (CEST) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2939F863E5 for ; Sun, 16 Jul 2023 02:38:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-3465bd756afso19179825ab.3 for ; Sat, 15 Jul 2023 17:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467892; x=1692059892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i7XlkJIJ9GsO5AxwHrpWo908gKWnlBTsYQA3XGgstzk=; b=N/KaLV52Irev0dB6ivBD8JSss5s3mFGyA41QXb7QAQNIst3zZihjvp1xoYYtZ7MpSR gGLYwN9Tr0hwTGnY0gQr9cVq/TvOamWqXqJqfSUuf2kbQP6svkTQTwkKPaVay/dN/igI uv1OcNpYm2ecWfIgroEOp+u4LcKXvfYRt3CF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467892; x=1692059892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i7XlkJIJ9GsO5AxwHrpWo908gKWnlBTsYQA3XGgstzk=; b=VtyxzLBG0KKzgZyMKRN98+VFdFBEbSFih/rUY3rRhtWOcPCpT746wub0r7vJkKlBAf 3g5sHnozwWyQ17rib3fj90IwTuQ9Qp+IRRIY7gj174iMZ4lZyPA76p3IcKGfhUy3QQU6 6ktdR4OMXq2KkizJxJqcXNEksl8oYep8HJKzaB1Z3ywamDHpFQ8ImUExB7CSN0c67mpB 1bWhHR8N7UyqtfO9Vvokpw+I/fQCI709OJfyAMLVHzDIh4qEln4isAAQd0QEpr5PfbYJ ITRPElAr6HOUBQYAGVyeMJt2v3BD4dFPH6Dy/v5NOuOBF+qk1wnaJ6/P9xv4YeiAmNRi mBiw== X-Gm-Message-State: ABy/qLbf43/FNovEFvv+Kw6kM2+YM4ushY+QPBxQlVjz8LWmlCGnzk8U o6z+xNzbwDjaxgcAKih05suBID0ct7MwwBEJ30I= X-Google-Smtp-Source: APBJJlFK02T0etO80InJH80W1eU+ILDUL/DtdaHYa74bAzjnTrEW/QqnnFz9M0jJGzp9Ti4RvpwUmw== X-Received: by 2002:a92:c94b:0:b0:346:d51:9922 with SMTP id i11-20020a92c94b000000b003460d519922mr7937283ilq.13.1689467891812; Sat, 15 Jul 2023 17:38:11 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:38:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 69/81] buildman: Move reading of the done file into a function Date: Sat, 15 Jul 2023 18:36:37 -0600 Message-ID: <20230716003718.231903-70-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Move this logic into its own function to reduce the size of the run_commt() function. Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/builderthread.py | 66 +++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 2d54e6283023..b4891059b6db 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -244,6 +244,46 @@ class BuilderThread(threading.Thread): result.return_code = 0 return result + def _read_done_file(self, commit_upto, brd, result, force_build, + force_build_failures): + """Check the 'done' file and see if this commit should be built + + Args: + commit (Commit): Commit only being built + brd (Board): Board being built + result (CommandResult): result object to update + force_build (bool): Force a build even if one was previously done + force_build_failures (bool): Force a bulid if the previous result + showed failure + + Returns: + bool: True if build should be built + """ + done_file = self.builder.get_done_file(commit_upto, brd.target) + result.already_done = os.path.exists(done_file) + will_build = (force_build or force_build_failures or + not result.already_done) + if result.already_done: + with open(done_file, 'r', encoding='utf-8') as outf: + try: + result.return_code = int(outf.readline()) + except ValueError: + # The file may be empty due to running out of disk space. + # Try a rebuild + result.return_code = RETURN_CODE_RETRY + + # Check the signal that the build needs to be retried + if result.return_code == RETURN_CODE_RETRY: + will_build = True + elif will_build: + err_file = self.builder.get_err_file(commit_upto, brd.target) + if os.path.exists(err_file) and os.stat(err_file).st_size: + result.stderr = 'bad' + elif not force_build: + # The build passed, so no need to build it again + will_build = False + return will_build + def run_commit(self, commit_upto, brd, work_dir, do_config, config_only, force_build, force_build_failures, work_in_output, adjust_cfg): @@ -291,30 +331,8 @@ class BuilderThread(threading.Thread): out_dir = os.path.join(work_dir, out_rel_dir) # Check if the job was already completed last time - done_file = self.builder.get_done_file(commit_upto, brd.target) - result.already_done = os.path.exists(done_file) - will_build = (force_build or force_build_failures or - not result.already_done) - if result.already_done: - # Get the return code from that build and use it - with open(done_file, 'r', encoding='utf-8') as outf: - try: - result.return_code = int(outf.readline()) - except ValueError: - # The file may be empty due to running out of disk space. - # Try a rebuild - result.return_code = RETURN_CODE_RETRY - - # Check the signal that the build needs to be retried - if result.return_code == RETURN_CODE_RETRY: - will_build = True - elif will_build: - err_file = self.builder.get_err_file(commit_upto, brd.target) - if os.path.exists(err_file) and os.stat(err_file).st_size: - result.stderr = 'bad' - elif not force_build: - # The build passed, so no need to build it again - will_build = False + will_build = self._read_done_file(commit_upto, brd, result, force_build, + force_build_failures) if will_build: # We are going to have to build it. First, get a toolchain -- 2.41.0.455.g037347b96a-goog