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 64A18C001DC for ; Wed, 19 Jul 2023 23:57:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ADF7D8687A; Thu, 20 Jul 2023 01:51:44 +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="Lt1PU3Hq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A8F3E867DF; Thu, 20 Jul 2023 01:50:37 +0200 (CEST) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 5CC1484701 for ; Thu, 20 Jul 2023 01:50:31 +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-xd35.google.com with SMTP id ca18e2360f4ac-77ac14ff51bso7366639f.3 for ; Wed, 19 Jul 2023 16:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810630; x=1690415430; 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=2TmGOaxZB4fJzi+GqYl/rrDBEcvBGft1G74YcVBkWbQ=; b=Lt1PU3HqLjtL4irDOfSLqzyJ/U4v6cZSn6YmvZJzC1rJNaw0tKTx+TctR1XFNJ7EVU ZeRit1bdhVHzs24VJdBmDrLMmBepB3PZmttGr8qMX7KlJ5EGIqf1U1Ru+cCFggIErjs4 ZuVqwGTKFE/0fBgPkSMLwtNGYsIOk5zzw/N5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810630; x=1690415430; 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=2TmGOaxZB4fJzi+GqYl/rrDBEcvBGft1G74YcVBkWbQ=; b=gOrHl9MoW6Mh8PEurVW4P3eRZFdnNcgMGLx3JST2O0zJqPsGPi4qSPJgARp5Z7UU6p 64HQRGAWynG2y54u8+ik5Q2WqPXNWJNeq/BJxvC2LdTXzS1uk2qaD1DXlbEEBdOZqFdD TmNWGdP/0dzrajGETn+I0Vxd03JVkPJmFh/vQJvZWtBPefh9GrLX26ehVJsbpYsPNH2v 2NKc0xMukwGndqCuYTZiOC59SFPHODuD9z5cjQP1yI5+RZorviy3h/+J69qKKE6ocLh1 bagnJwkiQbbMQrOusdOvo/D/fNJNaeQ3oifsEBLaH4zkJb00NV65WcCztUHtHFS+2XzF S3/A== X-Gm-Message-State: ABy/qLY3gU50a0ph5IGMz80kLPIoKhbGHKBrE6SwUa5I93fEfB8mQvSF bMDTaBQJXPAjyCVffr4tokrIXwbHecqWOD0/kKk= X-Google-Smtp-Source: APBJJlG/Yuf/hGSALpsu9JT3EXdbR9YKu4+tBKTMDA7lNYiTns53CHC/Qn+jHaYDDMXUTCt+ZA3PBQ== X-Received: by 2002:a6b:7944:0:b0:787:8cf:7426 with SMTP id j4-20020a6b7944000000b0078708cf7426mr879968iop.6.1689810629984; Wed, 19 Jul 2023 16:50:29 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 41/83] buildman: Move setting up the output dir into a function Date: Wed, 19 Jul 2023 17:48:49 -0600 Message-ID: <20230719234953.796101-42-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 code into a separate function to reduce the size of the main do_buildman() directory. Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/control.py | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 3e6933cc05e7..26f0db47684c 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -434,6 +434,36 @@ def adjust_options(options, series, selected): if not options.step: options.step = len(series.commits) - 1 + +def setup_output_dir(output_dir, work_in_output, branch, no_subdirs, col, + clean_dir): + """Set up the output directory + + Args: + output_dir (str): Output directory provided by the user, or None if none + work_in_output (bool): True to work in the output directory + branch (str): Name of branch to build, or None if none + no_subdirs (bool): True to put the output in the top-level output dir + clean_dir: Used for tests only, indicates that the existing output_dir + should be removed before starting the build + + Returns: + str: Updated output directory pathname + """ + if not output_dir: + if work_in_output: + sys.exit(col.build(col.RED, '-w requires that you specify -o')) + output_dir = '..' + if branch and not no_subdirs: + # As a special case allow the board directory to be placed in the + # output directory itself rather than any subdirectory. + dirname = branch.replace('/', '_') + output_dir = os.path.join(output_dir, dirname) + if clean_dir and os.path.exists(output_dir): + shutil.rmtree(output_dir) + return output_dir + + def do_buildman(options, args, toolchains=None, make_func=None, brds=None, clean_dir=False, test_thread_exceptions=False): """The main control code for buildman @@ -466,18 +496,9 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, toolchains = get_toolchains(toolchains, col, options.override_toolchain, options.fetch_arch, options.list_tool_chains, options.verbose) - output_dir = options.output_dir - if not output_dir: - if options.work_in_output: - sys.exit(col.build(col.RED, '-w requires that you specify -o')) - output_dir = '..' - if options.branch and not options.no_subdirs: - # As a special case allow the board directory to be placed in the - # output directory itself rather than any subdirectory. - dirname = options.branch.replace('/', '_') - output_dir = os.path.join(output_dir, dirname) - if clean_dir and os.path.exists(output_dir): - shutil.rmtree(output_dir) + output_dir = setup_output_dir( + options.output_dir, options.work_in_output, options.branch, + options.no_subdirs, col, clean_dir) # Work out what subset of the boards we are building if not brds: -- 2.41.0.487.g6d72f3e995-goog