From patchwork Mon Sep 13 14:38:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maximilian attems X-Patchwork-Id: 174602 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8DEdCOn024103 for ; Mon, 13 Sep 2010 14:39:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751960Ab0IMOjL (ORCPT ); Mon, 13 Sep 2010 10:39:11 -0400 Received: from baikonur.stro.at ([213.239.196.228]:59879 "EHLO baikonur.stro.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949Ab0IMOjL (ORCPT ); Mon, 13 Sep 2010 10:39:11 -0400 Received: from stro.at (cp4.itp.tuwien.ac.at [128.131.48.204]) by baikonur.stro.at (Postfix) with ESMTP id 9CCC15C00F; Mon, 13 Sep 2010 16:28:41 +0200 (CEST) Received: by stro.at (Postfix, from userid 1000) id D415B21299; Mon, 13 Sep 2010 16:38:32 +0200 (CEST) Date: Mon, 13 Sep 2010 16:38:31 +0200 From: maximilian attems To: Michal Marek , linux-kbuild@vger.kernel.org Cc: Bastian Blank , Ben Hutchings Subject: Kconfig add reportoldconfig and updateoldconfig targets Message-ID: <20100913143830.GK2919@stro.at> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 13 Sep 2010 14:39:12 +0000 (UTC) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index de934de..57e96aa 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -3,7 +3,7 @@ # These targets are used from top-level makefile PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \ - localmodconfig localyesconfig + localmodconfig localyesconfig reportoldconfig updateoldconfig ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) @@ -29,10 +29,16 @@ nconfig: $(obj)/nconf oldconfig: $(obj)/conf $< --$@ $(Kconfig) +reportoldconfig: $(obj)/conf + $< --$@ $(Kconfig) + silentoldconfig: $(obj)/conf $(Q)mkdir -p include/generated $< --$@ $(Kconfig) +updateoldconfig: $(obj)/conf + $< --$@ $(Kconfig) + # if no path is given, then use src directory to find file ifdef LSMOD LSMOD_F := $(LSMOD) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 5b7c86e..9c2171c 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -33,6 +33,8 @@ enum input_mode { savedefconfig, listnewconfig, oldnoconfig, + reportoldconfig, + updateoldconfig, } input_mode = oldaskconfig; char *defconfig_file; @@ -453,6 +455,8 @@ static struct option long_opts[] = { {"randconfig", no_argument, NULL, randconfig}, {"listnewconfig", no_argument, NULL, listnewconfig}, {"oldnoconfig", no_argument, NULL, oldnoconfig}, + {"reportoldconfig", no_argument, NULL, reportoldconfig}, + {"updateoldconfig", no_argument, NULL, updateoldconfig}, {NULL, 0, NULL, 0} }; @@ -530,6 +534,8 @@ int main(int ac, char **av) } break; case savedefconfig: + case reportoldconfig: + case updateoldconfig: conf_read(NULL); break; case silentoldconfig: @@ -595,6 +601,8 @@ int main(int ac, char **av) conf_set_all_new_symbols(def_random); break; case defconfig: + case reportoldconfig: + case updateoldconfig: conf_set_all_new_symbols(def_default); break; case savedefconfig: @@ -618,6 +626,9 @@ int main(int ac, char **av) break; } + if (input_mode == reportoldconfig) + conf_write_changes(); + if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 515253f..ee81b42 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -893,6 +893,85 @@ int conf_write_autoconf(void) return 0; } +void conf_write_changes(void) +{ + struct symbol *sym; + struct menu *menu; + int l; + const char *str; + + fprintf(stdout, "\n#\n" + "# Changes:\n" + "#\n"); + menu = rootmenu.list; + while (menu) { + sym = menu->sym; + if (sym && + !(sym->flags & SYMBOL_CHOICE) && + sym->flags & SYMBOL_WRITE && + sym->flags & SYMBOL_NEW && + sym->visible != no && + sym_is_changable(sym)) { + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + switch (sym_get_tristate_value(sym)) { + case no: + fprintf(stdout, "# CONFIG_%s is not set\n", sym->name); + break; + case mod: + fprintf(stdout, "CONFIG_%s=m\n", sym->name); + break; + case yes: + fprintf(stdout, "CONFIG_%s=y\n", sym->name); + break; + } + break; + case S_STRING: + str = sym_get_string_value(sym); + fprintf(stdout, "CONFIG_%s=\"", sym->name); + while (1) { + l = strcspn(str, "\"\\"); + if (l) { + fwrite(str, l, 1, stdout); + str += l; + } + if (!*str) + break; + fprintf(stdout, "\\%c", *str++); + } + fputs("\"\n", stdout); + break; + case S_HEX: + str = sym_get_string_value(sym); + if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { + fprintf(stdout, "CONFIG_%s=%s\n", sym->name, str); + break; + } + case S_INT: + str = sym_get_string_value(sym); + fprintf(stdout, "CONFIG_%s=%s\n", sym->name, str); + break; + default: + break; + } + } + + if (menu->list) { + menu = menu->list; + continue; + } + if (menu->next) + menu = menu->next; + else while ((menu = menu->parent)) { + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + static int sym_change_count; static void (*conf_changed_callback)(void); @@ -991,6 +1070,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) for_all_symbols(i, sym) { if (sym_has_value(sym)) continue; + sym->flags |= SYMBOL_NEW; switch (sym_get_type(sym)) { case S_BOOLEAN: case S_TRISTATE: diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 6ee2e4f..09a6a7c 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -107,6 +107,7 @@ struct symbol { #define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ +#define SYMBOL_NEW 0x100000 #define SYMBOL_MAXLENGTH 256 #define SYMBOL_HASHSIZE 9973 diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 9a948c9..d5aeb72 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -6,6 +6,7 @@ P(conf_read_simple,int,(const char *name, int)); P(conf_write_defconfig,int,(const char *name)); P(conf_write,int,(const char *name)); P(conf_write_autoconf,int,(void)); +P(conf_write_changes,void,(void)); P(conf_get_changed,bool,(void)); P(conf_set_changed_callback, void,(void (*fn)(void)));