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 638DCC0015E for ; Thu, 20 Jul 2023 00:02:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D0047868FC; Thu, 20 Jul 2023 01:52:56 +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="FcVyIaws"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C564086675; Thu, 20 Jul 2023 01:50:59 +0200 (CEST) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 B7A13867B9 for ; Thu, 20 Jul 2023 01:50:53 +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-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7836164a08aso8441439f.1 for ; Wed, 19 Jul 2023 16:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810652; x=1690415452; 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=3bR5FAc319UmZYex5Z/iQjjYz1K15dORgsYzNenCrCg=; b=FcVyIawsCE4SEjRBEejM7lXF8ojptqcxlbtd3QwQXR00VGvhp6x/+ABncnAFENu9ck pP2OqZQfnDQokiWc5d7aaAyd4Dn42FAoP9gHDBXP3/DbghhEEk7vaaMT2oGSj+9r44Y2 CDbaj3lnFbS0sKSf9qyugP9sZBELfA2IDwUZY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810652; x=1690415452; 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=3bR5FAc319UmZYex5Z/iQjjYz1K15dORgsYzNenCrCg=; b=M4QkEEYE0LznkDwlgRJFSDsyiKlL/zAtFp+qybhql7UJm9uOCG8jtmsEKkFVfhbzYo CAAavUaWcpI8WPt4DYjz1yj5bkpwjVZ6lemAXO4y3BDAklcz/Fve/ol77MbUMKK/CBkV kcQKprik5uFiFwI7+U00IhE+X2mwtcDErH8hifRfAifLgPNKHQWeHh4vewB9WbiX4bIF Dhusj4SJJYD6Entf7T13LMCWmVlamVpThL+tZLtwbYGBNb8eRDS7sRbnnJOLgWOchAFV 7rlw2iST9PxDZ4bNGZyfvaeqP4vJLH/0pf/9OkD32JinNhbtbL00ZalUbSsuSvZZZTyh tTRQ== X-Gm-Message-State: ABy/qLYdVTk2Rq1NTBuKTh+Qo2wtAp9tSPdnBccrjmcfBKyuOausGn1J 3KW2dxySaBVdhbeZ3/wJWN8oOANSmlLjbeJ8Ko8= X-Google-Smtp-Source: APBJJlE1yGEwWMg01HHP7BKSqQW85sSaaKrle595C+kpEZjZAiDhM6cx1gH/Lq0XARTOUEAHfu2wHQ== X-Received: by 2002:a05:6602:3294:b0:786:e669:3059 with SMTP id d20-20020a056602329400b00786e6693059mr918390ioz.6.1689810652304; Wed, 19 Jul 2023 16:50:52 -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 ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:52 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 71/83] buildman: Move reading of the done file into a function Date: Wed, 19 Jul 2023 17:49:19 -0600 Message-ID: <20230719234953.796101-72-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-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.487.g6d72f3e995-goog