diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2006-06-08 22:12:42 -0700 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-06-09 07:31:30 +0200 |
commit | 2e3646e51b2d6415549b310655df63e7e0d7a080 (patch) | |
tree | f717c0ede91122ab776a6b0fce9b8c941797f170 /scripts/kconfig | |
parent | 669bfad906522e74ee8d962801552a8c224c0d63 (diff) | |
download | linux-3.10-2e3646e51b2d6415549b310655df63e7e0d7a080.tar.gz linux-3.10-2e3646e51b2d6415549b310655df63e7e0d7a080.tar.bz2 linux-3.10-2e3646e51b2d6415549b310655df63e7e0d7a080.zip |
kconfig: integrate split config into silentoldconfig
Now that kconfig can load multiple configurations, it becomes simple to
integrate the split config step, by simply comparing the new .config file with
the old auto.conf (and then saving the new auto.conf). A nice side effect is
that this saves a bit of disk space and cache, as no data needs to be read
from or saved into the splitted config files anymore (e.g. include/config is
now 648KB instead of 5.2MB).
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/confdata.c | 121 | ||||
-rw-r--r-- | scripts/kconfig/expr.h | 3 |
2 files changed, 121 insertions, 3 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index ca693fcd023..e28cd0c2ca0 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -5,6 +5,7 @@ #include <sys/stat.h> #include <ctype.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -520,6 +521,119 @@ int conf_write(const char *name) return 0; } +int conf_split_config(void) +{ + char *name, path[128]; + char *s, *d, c; + struct symbol *sym; + struct stat sb; + int res, i, fd; + + name = getenv("KCONFIG_AUTOCONFIG"); + if (!name) + name = "include/config/auto.conf"; + conf_read_simple(name, S_DEF_AUTO); + + if (chdir("include/config")) + return 1; + + res = 0; + for_all_symbols(i, sym) { + sym_calc_value(sym); + if ((sym->flags & SYMBOL_AUTO) || !sym->name) + continue; + if (sym->flags & SYMBOL_WRITE) { + if (sym->flags & SYMBOL_DEF_AUTO) { + /* + * symbol has old and new value, + * so compare them... + */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_get_tristate_value(sym) == + sym->def[S_DEF_AUTO].tri) + continue; + break; + case S_STRING: + case S_HEX: + case S_INT: + if (!strcmp(sym_get_string_value(sym), + sym->def[S_DEF_AUTO].val)) + continue; + break; + default: + break; + } + } else { + /* + * If there is no old value, only 'no' (unset) + * is allowed as new value. + */ + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (sym_get_tristate_value(sym) == no) + continue; + break; + default: + break; + } + } + } else if (!(sym->flags & SYMBOL_DEF_AUTO)) + /* There is neither an old nor a new value. */ + continue; + /* else + * There is an old value, but no new value ('no' (unset) + * isn't saved in auto.conf, so the old value is always + * different from 'no'). + */ + + /* Replace all '_' and append ".h" */ + s = sym->name; + d = path; + while ((c = *s++)) { + c = tolower(c); + *d++ = (c == '_') ? '/' : c; + } + strcpy(d, ".h"); + + /* Assume directory path already exists. */ + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + if (errno != ENOENT) { + res = 1; + break; + } + /* + * Create directory components, + * unless they exist already. + */ + d = path; + while ((d = strchr(d, '/'))) { + *d = 0; + if (stat(path, &sb) && mkdir(path, 0755)) { + res = 1; + goto out; + } + *d++ = '/'; + } + /* Try it again. */ + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + res = 1; + break; + } + } + close(fd); + } +out: + if (chdir("../..")) + return 1; + + return res; +} + int conf_write_autoconf(void) { struct symbol *sym; @@ -529,8 +643,13 @@ int conf_write_autoconf(void) time_t now; int i, l; + sym_clear_all_valid(); + file_write_dep("include/config/auto.conf.cmd"); + if (conf_split_config()) + return 1; + out = fopen(".tmpconfig", "w"); if (!out) return 1; @@ -558,8 +677,6 @@ int conf_write_autoconf(void) "#define AUTOCONF_INCLUDED\n", sym_get_string_value(sym), ctime(&now)); - sym_clear_all_valid(); - for_all_symbols(i, sym) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE) || !sym->name) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 998cf4f656b..ffd42c7007e 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -65,6 +65,7 @@ enum symbol_type { enum { S_DEF_USER, /* main user value */ + S_DEF_AUTO, }; struct symbol { @@ -97,7 +98,7 @@ struct symbol { #define SYMBOL_WARNED 0x8000 #define SYMBOL_DEF 0x10000 #define SYMBOL_DEF_USER 0x10000 -#define SYMBOL_DEF2 0x20000 +#define SYMBOL_DEF_AUTO 0x20000 #define SYMBOL_DEF3 0x40000 #define SYMBOL_DEF4 0x80000 |