Patrick Georgi | 53ea1d4 | 2019-11-22 16:55:58 +0100 | [diff] [blame] | 1 | commit ab0cc6067d5a00182e89fbec82b942eb3d803204 |
| 2 | Author: Patrick Georgi <pgeorgi@google.com> |
| 3 | Date: 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 Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 13 | Index: kconfig/confdata.c |
| 14 | =================================================================== |
| 15 | --- kconfig.orig/confdata.c |
| 16 | +++ kconfig/confdata.c |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 17 | @@ -738,7 +738,12 @@ static void print_symbol_for_dotconfig(F |
Patrick Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 18 | |
| 19 | static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym) |
| 20 | { |
Patrick Georgi | 7eb03cb | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 21 | - __print_symbol(fp, sym, OUTPUT_N_NONE, false); |
Patrick Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 22 | + 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 Georgi | 7eb03cb | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 27 | + __print_symbol(fp, sym, out, false); |
Patrick Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | void print_symbol_for_listconfig(struct symbol *sym) |
Patrick Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 31 | @@ -763,6 +768,10 @@ static void print_symbol_for_c(FILE *fp, |
Patrick Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 32 | 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 Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 42 | @@ -774,6 +783,12 @@ static void print_symbol_for_c(FILE *fp, |
Patrick Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 43 | 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 Georgi | 0eab62b | 2023-11-20 19:49:29 +0100 | [diff] [blame^] | 55 | @@ -1190,8 +1205,9 @@ static int __conf_write_autoconf(const c |
Patrick Georgi | 4c9b9e9 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 56 | |
| 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 Georgi | 5526be2 | 2022-10-28 01:00:26 +0200 | [diff] [blame] | 65 | fflush(file); |