blob: 101bc695a41e2509083f09d1a4a693a271852b65 [file] [log] [blame]
Patrick Georgi53ea1d42019-11-22 16:55:58 +01001commit ab0cc6067d5a00182e89fbec82b942eb3d803204
2Author: Patrick Georgi <pgeorgi@google.com>
3Date: Fri Nov 22 22:08:15 2019 +0100
4
5 util/kconfig: Allow emitting false booleans into kconfig output
6
7 This is controlled by an environment variable so the same tool is
8 useful in different contexts.
9
10 Change-Id: I9e62b05e45709f1539e455e2eed37308609be15e
11 Signed-off-by: Patrick Georgi <pgeorgi@google.com>
12
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020013Index: kconfig/confdata.c
14===================================================================
15--- kconfig.orig/confdata.c
16+++ kconfig/confdata.c
Patrick Georgi0eab62b2023-11-20 19:49:29 +010017@@ -738,7 +738,12 @@ static void print_symbol_for_dotconfig(F
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020018
19 static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
20 {
Patrick Georgi7eb03cb2022-10-28 01:00:26 +020021- __print_symbol(fp, sym, OUTPUT_N_NONE, false);
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020022+ int print_negatives = getenv("KCONFIG_NEGATIVES") != NULL;
23+ enum output_n out = OUTPUT_N_NONE;
24+ if (print_negatives) {
25+ out = OUTPUT_N;
26+ }
Patrick Georgi7eb03cb2022-10-28 01:00:26 +020027+ __print_symbol(fp, sym, out, false);
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020028 }
29
30 void print_symbol_for_listconfig(struct symbol *sym)
Patrick Georgi0eab62b2023-11-20 19:49:29 +010031@@ -763,6 +768,10 @@ static void print_symbol_for_c(FILE *fp,
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020032 case S_TRISTATE:
33 switch (*val) {
34 case 'n':
35+ if (getenv("KCONFIG_NEGATIVES") != NULL) {
36+ val = "0";
37+ break;
38+ }
39 return;
40 case 'm':
41 sym_suffix = "_MODULE";
Patrick Georgi0eab62b2023-11-20 19:49:29 +010042@@ -774,6 +783,12 @@ static void print_symbol_for_c(FILE *fp,
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020043 case S_HEX:
44 if (val[0] != '0' || (val[1] != 'x' && val[1] != 'X'))
45 val_prefix = "0x";
46+ /* fall through */
47+ case S_INT:
48+ if (val[0] == '\0') {
49+ val = "0";
50+ val_prefix = "";
51+ }
52 break;
53 case S_STRING:
54 escaped = escape_string_value(val);
Patrick Georgi0eab62b2023-11-20 19:49:29 +010055@@ -1190,8 +1205,9 @@ static int __conf_write_autoconf(const c
Patrick Georgi4c9b9e92022-10-28 01:00:26 +020056
57 conf_write_heading(file, comment_style);
58
59+ int print_negatives = getenv("KCONFIG_NEGATIVES") != NULL;
60 for_all_symbols(i, sym)
61- if ((sym->flags & SYMBOL_WRITE) && sym->name)
62+ if (((sym->flags & SYMBOL_WRITE) || (print_negatives && sym->type != S_STRING)) && sym->name)
63 print_symbol(file, sym);
64
Patrick Georgi5526be22022-10-28 01:00:26 +020065 fflush(file);