From patchwork Mon Sep 1 07:16:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 4817171 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 327EFC0338 for ; Mon, 1 Sep 2014 07:17:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 382DB200F4 for ; Mon, 1 Sep 2014 07:17:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DD1320172 for ; Mon, 1 Sep 2014 07:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbaIAHQp (ORCPT ); Mon, 1 Sep 2014 03:16:45 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:34319 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752570AbaIAHQn (ORCPT ); Mon, 1 Sep 2014 03:16:43 -0400 Received: by mail-lb0-f169.google.com with SMTP id l4so5442065lbv.0 for ; Mon, 01 Sep 2014 00:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=ULQosUEHCB9la5FdTFhmzK9BYjvepKaMOJSxp4udbCI=; b=EN5ms6riTVxM77jUatAxhW1acl9eVyBTRAkuKXHxkIYnidgM4zbrRmR73WEJNiStuq 6sqOsSArUsMYsjRTjUblWOns2xFBfSCa02sfmQ9mo3DBn4k34ery5wXnG0BbTMpK00tl S4D8kogOTWeW/QlWpuf1ssCauQdpIFqbhWrNSFuxOWs73oxADU5rh7WgrJRWqkuLV+G+ io0kQpnQw2sd88+lhXjEh1K4S9vDfB99KsmcrbX0cXOeL1ziTtgd2mavYLzRLVbRpzo9 ZkQM/JQ+bK16hw4m4jAw43M7l1BbAec69/H7RMKbR0UrW90Gx5n0cqrLivWyrrly+P0z eNiA== X-Received: by 10.152.234.162 with SMTP id uf2mr25461746lac.44.1409555801644; Mon, 01 Sep 2014 00:16:41 -0700 (PDT) Received: from localhost (37-145-28-45.broadband.corbina.ru. [37.145.28.45]) by mx.google.com with ESMTPSA id r1sm4885274lae.33.2014.09.01.00.16.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Sep 2014 00:16:40 -0700 (PDT) Subject: [PATCH v2 1/4] kconfig: save values imported from environment into config file From: Konstantin Khlebnikov To: Michal Marek , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Paul Bolle , Geert Uytterhoeven Date: Mon, 01 Sep 2014 11:16:29 +0400 Message-ID: <20140901071629.28909.20328.stgit@zurg> In-Reply-To: <20140901065916.28909.35097.stgit@zurg> References: <20140901065916.28909.35097.stgit@zurg> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After this patch option env="..." behaves more like user input. Environment variable becomes optional, its last state is saved in config. Impact of this change is minimal. This option is used only three times: for ARCH, SRCARCH and KERNELVERSION. All of them are always defined by root Makefile. Signed-off-by: Konstantin Khlebnikov --- Documentation/kbuild/kconfig-language.txt | 10 ++++------ scripts/kconfig/confdata.c | 26 ++++++++++++++++++++++++++ scripts/kconfig/expr.h | 2 +- scripts/kconfig/symbol.c | 3 --- 4 files changed, 31 insertions(+), 10 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index 350f733..0dad00a 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -149,13 +149,11 @@ applicable everywhere (see syntax). enables the third modular state for all config symbols. At most one symbol may have the "modules" option set. - - "env"= + - "env"= This imports the environment variable into Kconfig. It behaves like - a default, except that the value comes from the environment, this - also means that the behaviour when mixing it with normal defaults is - undefined at this point. The symbol is currently not exported back - to the build environment (if this is desired, it can be done via - another symbol). + the user input, except that the value comes from the environment. + Environment variable overrides all defaults and value from the file. + If environment variable is not defined this option has no effect. - "allnoconfig_y" This declares the symbol as one that should have the value y when diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f88d90f..5cb0034 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -404,6 +404,30 @@ setsym: return 0; } +static void conf_read_env(void) +{ + struct symbol *sym, *env_sym; + struct property *prop; + struct expr *expr; + char *value; + + expr_list_for_each_sym(sym_env_list, expr, sym) { + prop = sym_get_env_prop(sym); + env_sym = prop_get_symbol(prop); + value = getenv(env_sym->name); + if (value) { + sym_calc_value(sym); + if (!sym_set_string_value(sym, value)) + conf_warning("evironment variable %s value " + "'%s' invalid for %s", + env_sym->name, value, sym->name); + } else if (!(sym->flags & SYMBOL_DEF_USER)) + conf_warning("neither symbol %s nor evironment " + "variable %s are defined", + sym->name, env_sym->name); + } +} + int conf_read(const char *name) { struct symbol *sym; @@ -414,6 +438,8 @@ int conf_read(const char *name) if (conf_read_simple(name, S_DEF_USER)) return 1; + conf_read_env(); + for_all_symbols(i, sym) { sym_calc_value(sym); if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 412ea8a..8d9bbc9 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -95,7 +95,7 @@ struct symbol { #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400 /* ? */ -#define SYMBOL_AUTO 0x1000 /* value from environment variable */ +#define SYMBOL_AUTO 0x1000 /* calculated value - not saved into file */ #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ #define SYMBOL_WARNED 0x8000 /* warning has been issued */ diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 7caabdb..9dce811 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1350,7 +1350,6 @@ static void prop_add_env(const char *env) char *p; sym = current_entry->sym; - sym->flags |= SYMBOL_AUTO; for_all_properties(sym, prop, P_ENV) { sym2 = prop_get_symbol(prop); if (strcmp(sym2->name, env)) @@ -1368,6 +1367,4 @@ static void prop_add_env(const char *env) p = getenv(env); if (p) sym_add_default(sym, p); - else - menu_warn(current_entry, "environment variable %s undefined", env); }