Message ID | 20230212231638.1134219-55-sjg@chromium.org |
---|---|
State | RFC |
Delegated to: | Tom Rini |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=IuIMj8vJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFNq31T3Gz23h0 for <incoming@patchwork.ozlabs.org>; Mon, 13 Feb 2023 10:24:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 482DB8595F; Mon, 13 Feb 2023 00:20:39 +0100 (CET) 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="IuIMj8vJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 87BC685762; Mon, 13 Feb 2023 00:18:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 6B4D8857F2 for <u-boot@lists.denx.de>; Mon, 13 Feb 2023 00:17:56 +0100 (CET) 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-xd29.google.com with SMTP id j17so3935583ioa.9 for <u-boot@lists.denx.de>; Sun, 12 Feb 2023 15:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=z0FpUJiJ+Yu4b6gDTjI2lIXB8WQSnv5nooci81LgclQ=; b=IuIMj8vJ53CZYWINUaPzGv75vNmk7Z7qnWaL9psUUAyeDiDn0SlRxaEYVuaBcXkVBB uP8n+tQDeyGmW6OlpMauQS04ZaJllHPz+u4Ics+ih2tl7dM9euGdBOott3tFd0rc+wM3 bIWVi93xgWnwnTBc8V4xDLABVuXm5EAngpmwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=z0FpUJiJ+Yu4b6gDTjI2lIXB8WQSnv5nooci81LgclQ=; b=TXU74emYF9bY3qnJxe3jbvXKjfbEdgdq0z37t27QOgv8Riek8bipCuJJ6/+D3h2w0F CgsqkNEb0BJrIhc/5z99yFHStgaMwB1D1+7htvti8KepXXVhqqJTkGxsos+tuTJ/GSAE /m5dz3jfKbq2W2J2N2UVAUmkewDbSbher/SODWiZ9ubKOZrWJPwYqlP3Na/7TIXercZM 6o5R+xEQqmYgkv7roUL3eNkefbSimmGDBPLst9Wesboz/MR2Ir5CIduNAHA4MMXpEtkh 8L2CwbSX0SPV0ni01Qssaw51JY/XD0RDUrmSymWxmAbuF7PEbQ1/H9QvdLIpdLkLVT88 3MIA== X-Gm-Message-State: AO0yUKWhuid6dOhBYlNEy/oI44DTPWqcjwVG/ToX3kU3pRzRvleso7R1 jP7riBQcu+eR6P+KQ2ejEDvnatEYuSVszY0r X-Google-Smtp-Source: AK7set8DyAlcrhRO3IiIBo/ol2yPjvdIySw7LtOurRBaSHa8N0l9O09woY2tP4GdNiopJ/cPIhAizg== X-Received: by 2002:a6b:fb1a:0:b0:71a:3545:72bd with SMTP id h26-20020a6bfb1a000000b0071a354572bdmr17757205iog.21.1676243875897; Sun, 12 Feb 2023 15:17:55 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id n16-20020a6b8b10000000b006dfbd35e995sm3627849iod.21.2023.02.12.15.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Feb 2023 15:17:55 -0800 (PST) From: Simon Glass <sjg@chromium.org> To: U-Boot Mailing List <u-boot@lists.denx.de> Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org> Subject: [PATCH v3 54/95] fixdep: Refactor to make testing easier Date: Sun, 12 Feb 2023 16:15:57 -0700 Message-Id: <20230212231638.1134219-55-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog In-Reply-To: <20230212231638.1134219-1-sjg@chromium.org> References: <20230212231638.1134219-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 <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean |
Series |
RFC: Migrate to split config
|
expand
|
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 3d40bd7ee25..a49d35ba5f6 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -236,47 +236,68 @@ static int str_ends_with(const char *s, int slen, const char *sub) return !memcmp(s + slen - sublen, sub, sublen); } -static void parse_config_file(const char *p) +static const char *parse_config_line(const char *p, const char **endp) { const char *q, *r; - const char *start = p; - while ((p = strstr(p, "CONFIG_"))) { - if (p > start && (isalnum(p[-1]) || p[-1] == '_')) { - p += 7; - continue; - } - p += 7; + p = strstr(p, "CONFIG_"); + if (!p) { + *endp = NULL; + return NULL; + } + if ((isalnum(p[-1]) || p[-1] == '_')) { + *endp = p + 7; + return NULL; + } + p += 7; + q = p; + while (isalnum(*q) || *q == '_') + q++; + if (str_ends_with(p, q - p, "_MODULE")) + r = q - 7; + else + r = q; + /* + * U-Boot also handles + * CONFIG_IS_ENABLED(...) + * CONFIG_VAL(...) + */ + if ((q - p == 10 && !memcmp(p, "IS_ENABLED(", 11)) || + (q - p == 3 && !memcmp(p, "VAL(", 4))) { + p = q + 1; q = p; while (isalnum(*q) || *q == '_') q++; - if (str_ends_with(p, q - p, "_MODULE")) - r = q - 7; - else - r = q; - /* - * U-Boot also handles - * CONFIG_IS_ENABLED(...) - * CONFIG_VAL(...) - */ - if ((q - p == 10 && !memcmp(p, "IS_ENABLED(", 11)) || - (q - p == 3 && !memcmp(p, "VAL(", 4))) { - p = q + 1; - q = p; - while (isalnum(*q) || *q == '_') - q++; - r = q; - if (r > p && tmp_buf[0]) { - memcpy(tmp_buf + 4, p, r - p); - r = tmp_buf + 4 + (r - p); - p = tmp_buf; - } + r = q; + if (r > p && tmp_buf[0]) { + memcpy(tmp_buf + 4, p, r - p); + r = tmp_buf + 4 + (r - p); + p = tmp_buf; } - /* end U-Boot hack */ + } + /* end U-Boot hack */ + *endp = r; + + if (r > p) + return p; - if (r > p) - use_config(p, r - p); - p = q; + return NULL; +} + +static void parse_config_file(const char *base) +{ + const char *p; + + if (!*base) + return; + p = base + 1; + while (p) { + const char *out, *end; + + out = parse_config_line(p, &end); + if (out) + use_config(out, end - out); + p = end; } }
Move the config parsing into a separate function so that it is possible to write tests for the function. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) scripts/basic/fixdep.c | 87 ++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 33 deletions(-)