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 02E9CC001DF for ; Sun, 16 Jul 2023 00:43:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EBC2086664; Sun, 16 Jul 2023 02:39:26 +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="Bc8i3lLx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8EAD386387; Sun, 16 Jul 2023 02:38:06 +0200 (CEST) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 5E0D08623A for ; Sun, 16 Jul 2023 02:37:52 +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-xd31.google.com with SMTP id ca18e2360f4ac-7836272f36eso143176739f.1 for ; Sat, 15 Jul 2023 17:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467871; x=1692059871; 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=95cpVYmZEPJAYrEdGfn+sqck9G6mZ8P3maqsVV6c104=; b=Bc8i3lLx+f6avRdtj5b6gjEahG3Eap8TtRK249jOwmZ5dUjqXcYPHEkAGpoQxrqe8Y XlI29dDwJqhwX4uYq93rr5jwctbJIRKC322uVsiRPix/V7TunhtWUAEN/xsDcbbWcrpt UQ53Zr9Lk071WflTS44sob2t2x3DV+TzbaTaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467871; x=1692059871; 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=95cpVYmZEPJAYrEdGfn+sqck9G6mZ8P3maqsVV6c104=; b=abWzJbsRkMaU7981XA57CluykML82A7H3SrgYn/y5rTpPYJAPEQrvzdkaSoTpV928A oibDQCigeI0oFteDylcrAJAB8g0sM8zyTdlccb/tlRZMRZhmYWYooHRQvaxj1W0nGR0p +cIqMvnuGdoJkX7d1jEoUWRDFOJ46AxItxRUqmerVIhbnmpJTGekS400iw66iFVACDx7 Oy33BJ5XqwKOlcUIeyg9cQJsOvFP31CNwPHOnIPRR6pZuHH3ZCUyylOLUwa4kCUAL4Xr Pg1VURYITmRaZmexYBg/NH6pj2d9I8kpPylTHNigwLyYaouR9mbj2WaFibGMhrQozUAn 3sjA== X-Gm-Message-State: ABy/qLZe4yK1xzJ1dOx9vHW4fpfc1upnF4wxWecFjxSmE0fXZHzS7Yq+ xFg7HYMmQLzoLfUX4O86yL1pHbYOTSLNaSNRpG0= X-Google-Smtp-Source: APBJJlGXJtYNY0kFGloMXUJI0cgIrJs0pbeu7y8qpR2LWtUBozbRUQ44mnge7JcOieLBLb3rsNYf1w== X-Received: by 2002:a5e:da4c:0:b0:783:5e4e:b785 with SMTP id o12-20020a5eda4c000000b007835e4eb785mr9218330iop.19.1689467870898; Sat, 15 Jul 2023 17:37:50 -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.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 39/81] buildman: Move setting up the output dir into a function Date: Sat, 15 Jul 2023 18:36:07 -0600 Message-ID: <20230716003718.231903-40-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 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.455.g037347b96a-goog