From mboxrd@z Thu Jan 1 00:00:00 1970 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 5D991C433F5 for ; Tue, 15 Feb 2022 11:52:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 12216839E2; Tue, 15 Feb 2022 12:52:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NoPbZo33"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8490C838C7; Tue, 15 Feb 2022 12:52:49 +0100 (CET) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 8E3728388F for ; Tue, 15 Feb 2022 12:52:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ed1-x52e.google.com with SMTP id m17so6730463edc.13 for ; Tue, 15 Feb 2022 03:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=BUjqsI2E0ECP84qlEmYudwBzVNmrh2rdeUpOQxWWNnk=; b=NoPbZo33P9G5H1h9i9VioZqhx7ftOhFJiFK3b//XSowFFMhug2ILMXJB7WkSzYDpPo ns73iM7yAe4IXadAWUD2aa1BkqC3fG4tbc01BykTnvVnAzmLT1Fvt+tEnIXVm7seeEFB +TfU1OW9+RmKDCiGDjOH29ZrfLmiMoMcTqDEPv+ueABoIPCvPA9ftfvOZpLzOpSHcw4X b2SNcFMXUgnBHwhi9K2pHS8sTvjEAuhAd5mHuowUsyb6gW2A4YCCYrgC725WDfe2Dhob 1CKTrgwz2E408hokrwwwKG816//hqp1DYRgHWYXgDYU/iXovduD88gFBKQe30Sho8IHX 5dIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=BUjqsI2E0ECP84qlEmYudwBzVNmrh2rdeUpOQxWWNnk=; b=BoHWSIlnLJiGFOE+YCbYqaXLtgy21RYdgWTQtBRws7RhA6ywYC96BOsIGwRrcJILGb DHIt8RF/yd6BWddjO919NxsVhSXgVOX4XXlExZF6g0mTOsLQutcPoApXMRSeDD6fXHW7 QqJgk0Z9laMIoqmWiFi15KD1/PTaGwxGbA02u9jQo5B3QTcGmXQHcRWqJ+KzK1MavTJn Qzf5W1o+ByDHXWU21lXGcghI/sd3lWw+c/TXnxcq4LQ4J5kszHXaUiV4i+Jc6tk2FLfu TABo/27GYKL01bWmiQ7cL56AWlXblcy3mg625ocpDZT4ySQQAu6JITtTjxpBD6APrmIZ McFg== X-Gm-Message-State: AOAM53004KT+illPUB0baDAlsso8IawFqsUk9395ysiwGU156I8NVfqK kwyd1Ce/pLb6TNiwlGaJeqo6M56fSck= X-Google-Smtp-Source: ABdhPJz3Ju3ZYksNE6VLei3mZ716l9XCpkMQMsUEDfm8yZs1z5Q+Hou0IWNvMcBULRLDRxjYhEQqZg== X-Received: by 2002:a50:ec0f:: with SMTP id g15mr3548364edr.122.1644925965036; Tue, 15 Feb 2022 03:52:45 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id l19sm4191639edb.87.2022.02.15.03.52.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Feb 2022 03:52:44 -0800 (PST) Message-ID: Date: Tue, 15 Feb 2022 14:41:39 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 From: Alper Nebi Yasak Subject: Re: [PATCH 02/24] moveconfig: Allow regex matches when finding combinations To: Simon Glass , U-Boot Mailing List Cc: huang lin , Jeffy Chen , Kever Yang , Tom Rini , Philippe Reynes , Ivan Mikhaylov , Heinrich Schuchardt , Trevor Woerner References: <20220208185008.35843-1-sjg@chromium.org> <20220208114935.2.I061931956016352181753039d4df732997a7ab15@changeid> Content-Language: en-US In-Reply-To: <20220208114935.2.I061931956016352181753039d4df732997a7ab15@changeid> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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.5 at phobos.denx.de X-Virus-Status: Clean On 08/02/2022 21:49, Simon Glass wrote: > It is useful to be able to search for CONFIG options that match a regex, > such as this, which lists boards which define SPL_FIT_GENERATOR and > anything not starting with ROCKCHIP: > > ./tools/moveconfig.py -f SPL_FIT_GENERATOR ~ROCKCHIP.* > > Add support for this. > > Signed-off-by: Simon Glass > --- > > tools/moveconfig.py | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/tools/moveconfig.py b/tools/moveconfig.py > index 5ef5a95eb6..cff1e30658 100755 > --- a/tools/moveconfig.py > +++ b/tools/moveconfig.py > @@ -1606,12 +1606,31 @@ def do_imply_config(config_list, add_imply, imply_flags, skip_added, > for linenum in sorted(linenums, reverse=True): > add_imply_rule(config[CONFIG_LEN:], fname, linenum) > > +def defconfig_matches(configs, re_match): > + """Check if any CONFIG option matches a regex > + > + The match must be complete, i.e. from the start to end of the CONFIG option. > + > + Args: > + configs (dict): Dict of CONFIG options: > + key: CONFIG option > + value: Value of option > + re_match (re.Pattern): Match to check > + > + Returns: > + bool: True if any CONFIG matches the regex > + """ > + for cfg in configs: > + m_cfg = re_match.match(cfg) > + if m_cfg and m_cfg.span()[1] == len(cfg): > + return True > + return False Consider re_match.fullmatch() to match the entire string. I think this can be further reduced into any(map(re_match.fullmatch, configs)) and used directly below instead of adding this extra function. > > def do_find_config(config_list): > """Find boards with a given combination of CONFIGs > > Params: > - config_list: List of CONFIG options to check (each a string consisting > + config_list: List of CONFIG options to check (each a regex consisting > of a config option, with or without a CONFIG_ prefix. If an option > is preceded by a tilde (~) then it must be false, otherwise it must > be true) > @@ -1643,8 +1662,9 @@ def do_find_config(config_list): > # running for the next stage > in_list = out > out = set() > + re_match = re.compile(cfg) > for defc in in_list: > - has_cfg = cfg in config_db[defc] > + has_cfg = defconfig_matches(config_db[defc], re_match) > if has_cfg == want: > out.add(defc) > if adhoc: