Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1214567 > unrolled thread

[RFC/PATCH 0/2] A simpler way to maintain custom defconfigs

Started byFelipe Contreras <felipe.contreras@gmail.com>
First post2015-08-27 15:20 +0200
Last post2015-08-28 15:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs Felipe Contreras <felipe.contreras@gmail.com> - 2015-08-27 15:20 +0200
    [RFC/PATCH 2/2] kconfig: add KCONFIG_BASECONFIG option to savedefconfig Felipe Contreras <felipe.contreras@gmail.com> - 2015-08-27 15:20 +0200
    Re: [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs "John Stoffel" <john@stoffel.org> - 2015-08-28 15:10 +0200

#1214567 — [RFC/PATCH 0/2] A simpler way to maintain custom defconfigs

FromFelipe Contreras <felipe.contreras@gmail.com>
Date2015-08-27 15:20 +0200
Subject[RFC/PATCH 0/2] A simpler way to maintain custom defconfigs
Message-ID<q25fX-5vZ-7@gated-at.bofh.it>
Hi,

For several years I've used a trick to be able to maintain a simple defconfig
that works across many versions, and requires little maintenance from my
part:

% cat arch/x86/configs/x86_64_defconfig ~/my-config > .config && make olddefconfig

I'm sending a proposal to integrate it on the build system so that many people
can do the same in a simple manner.

The interesting part is how to generate this simplified defconfig. In a
nutshell; you want to take your .config, remove everything that is the default
in the Kconfig files (what savedefconfig does), but also removes anything that
is in the default defconfig (e.g. x86_64_defconfig)

I've been doing this by hand, but today I gave it a shot to automate this. The
result is a bit crude, but it works.

Thoughts?

Felipe Contreras (2):
  kconfig: add KBUILD_USERCONFIG option
  kconfig: add KCONFIG_BASECONFIG option to savedefconfig

 scripts/kconfig/Makefile    |  6 +++
 scripts/kconfig/conf.c      |  3 ++
 scripts/kconfig/confdata.c  | 89 +++++++++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/lkc_proto.h |  1 +
 4 files changed, 99 insertions(+)

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1214570 — [RFC/PATCH 2/2] kconfig: add KCONFIG_BASECONFIG option to savedefconfig

FromFelipe Contreras <felipe.contreras@gmail.com>
Date2015-08-27 15:20 +0200
Subject[RFC/PATCH 2/2] kconfig: add KCONFIG_BASECONFIG option to savedefconfig
Message-ID<q25fY-5vZ-33@gated-at.bofh.it>
In reply to#1214567
This option parses a defconfig file, and sets all the values as default
ones. The result is a much simplified defconfig.

This defconfig can be used as a KBUILD_USERCONFIG, which added to the
default defconfig generates exactly the same config file.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 scripts/kconfig/conf.c      |  3 ++
 scripts/kconfig/confdata.c  | 89 +++++++++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/lkc_proto.h |  1 +
 3 files changed, 93 insertions(+)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 6c20431..382151c 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -698,6 +698,9 @@ int main(int ac, char **av)
 			return 1;
 		}
 	} else if (input_mode == savedefconfig) {
+		name = getenv("KCONFIG_BASECONFIG");
+		if (name)
+			conf_read_def(name);
 		if (conf_write_defconfig(defconfig_file)) {
 			fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
 				defconfig_file);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c814f57..af96042 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -476,6 +476,95 @@ int conf_read(const char *name)
 	return 0;
 }
 
+static void conf_set_sym_default(struct symbol *sym, char *p)
+{
+	struct property *prop, **propp;
+
+	prop = xmalloc(sizeof(*prop));
+	memset(prop, 0, sizeof(*prop));
+	prop->type = P_DEFAULT;
+	prop->sym = sym;
+	prop->file = current_file;
+	prop->lineno = zconf_lineno();
+
+	for (propp = &sym->prop; *propp; propp = &(*propp)->next) {
+		if ((*propp)->type == P_DEFAULT) {
+			prop->next = *propp;
+			break;
+		}
+	}
+	*propp = prop;
+
+	prop->expr = expr_alloc_symbol(sym_lookup(p, SYMBOL_CONST));
+}
+
+int conf_read_def(const char *name)
+{
+	FILE *in = NULL;
+	char *line = NULL;
+	size_t line_asize = 0;
+	char *p, *p2;
+	struct symbol *sym;
+
+	in = zconf_fopen(name);
+	if (!in)
+		return 1;
+
+	conf_filename = name;
+	conf_lineno = 0;
+	conf_warnings = 0;
+
+	while (compat_getline(&line, &line_asize, in) != -1) {
+		conf_lineno++;
+		sym = NULL;
+		if (line[0] == '#') {
+			if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
+				continue;
+			p = strchr(line + 2 + strlen(CONFIG_), ' ');
+			if (!p)
+				continue;
+			*p++ = 0;
+			if (strncmp(p, "is not set", 10))
+				continue;
+			sym = sym_find(line + 2 + strlen(CONFIG_));
+			if (!sym)
+				continue;
+			switch (sym->type) {
+			case S_BOOLEAN:
+			case S_TRISTATE:
+				conf_set_sym_default(sym, "n");
+				break;
+			default:
+				;
+			}
+		} else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
+			p = strchr(line + strlen(CONFIG_), '=');
+			if (!p)
+				continue;
+			*p++ = 0;
+			p2 = strchr(p, '\n');
+			if (p2) {
+				*p2-- = 0;
+				if (*p2 == '\r')
+					*p2 = 0;
+			}
+
+			sym = sym_find(line + strlen(CONFIG_));
+			if (!sym)
+				continue;
+			conf_set_sym_default(sym, p);
+		} else {
+			if (line[0] != '\r' && line[0] != '\n')
+				conf_warning("unexpected data");
+			continue;
+		}
+	}
+	free(line);
+	fclose(in);
+
+	return 0;
+}
+
 /*
  * Kconfig configuration printer
  *
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index d539871..69c3785 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -3,6 +3,7 @@
 /* confdata.c */
 void conf_parse(const char *name);
 int conf_read(const char *name);
+int conf_read_def(const char *name);
 int conf_read_simple(const char *name, int);
 int conf_write_defconfig(const char *name);
 int conf_write(const char *name);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1215332

From"John Stoffel" <john@stoffel.org>
Date2015-08-28 15:10 +0200
Message-ID<q2rzR-49f-37@gated-at.bofh.it>
In reply to#1214567
Felipe> For several years I've used a trick to be able to maintain a simple defconfig
Felipe> that works across many versions, and requires little maintenance from my
Felipe> part:

Felipe> % cat arch/x86/configs/x86_64_defconfig ~/my-config > .config && make olddefconfig

Felipe> I'm sending a proposal to integrate it on the build system so that many people
Felipe> can do the same in a simple manner.

Felipe> The interesting part is how to generate this simplified defconfig. In a
Felipe> nutshell; you want to take your .config, remove everything that is the default
Felipe> in the Kconfig files (what savedefconfig does), but also removes anything that
Felipe> is in the default defconfig (e.g. x86_64_defconfig)

Felipe> I've been doing this by hand, but today I gave it a shot to automate this. The
Felipe> result is a bit crude, but it works.

Felipe> Thoughts?

I like this idea, it makes alot of sense to me, and looks like it will
simplify things for people.  

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web