linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent)
@ 2011-02-24 18:36 Yann E. MORIN
  2011-02-24 18:36 ` [PATCH 1/2] kconfig: allow multiple inclusion of the same file Yann E. MORIN
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yann E. MORIN @ 2011-02-24 18:36 UTC (permalink / raw)
  To: linux-kbuild

Hello All!

This patch series makes it possible to source a file multiple times,
eg. from different files, and/or under different conditions. Care has
been taken to avoid circular inclusion, of course.

For example, this would allow to include a common set of options to
more than one drivers, and move that common set to a single file.

We are using kconfig in crosstool-NG, and there are now a few places
where including the same file would be a great improvement. Having
this feature in the upstream kconfig will also greatly help future
resyncs.

This is in response to:
  http://www.spinics.net/lists/linux-kbuild/msg03937.html

 [PATCH 1/2] kconfig: allow multiple inclusion of the same file
 [PATCH 2/2] kconfig: get rid of unused flags

Regards,
Yann E. MORIN.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] kconfig: allow multiple inclusion of the same file
  2011-02-24 18:36 [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
@ 2011-02-24 18:36 ` Yann E. MORIN
  2011-02-24 18:36 ` [PATCH 2/2] kconfig: get rid of unused flags Yann E. MORIN
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2011-02-24 18:36 UTC (permalink / raw)
  To: linux-kbuild

Allow 'source'ing the same file from multiple places (eg. from
different files, and/or under different conditions).

To avoid circular inclusion, scan the source-ancestry of the
current file, and abort if already sourced in this branch.

Regenerate the pre-parsed lex.zconf.c_shipped file.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
---
 scripts/kconfig/lex.zconf.c_shipped |   29 +++++++++++++++++++----------
 scripts/kconfig/zconf.l             |   29 +++++++++++++++++++----------
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
index 6eb0397..f4b3b1a 100644
--- a/scripts/kconfig/lex.zconf.c_shipped
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -2368,6 +2368,7 @@ void zconf_initscan(const char *name)
 
 void zconf_nextfile(const char *name)
 {
+	struct file *iter;
 	struct file *file = file_lookup(name);
 	struct buffer *buf = malloc(sizeof(*buf));
 	memset(buf, 0, sizeof(*buf));
@@ -2383,16 +2384,24 @@ void zconf_nextfile(const char *name)
 	buf->parent = current_buf;
 	current_buf = buf;
 
-	if (file->flags & FILE_BUSY) {
-		printf("%s:%d: do not source '%s' from itself\n",
-		       zconf_curname(), zconf_lineno(), name);
-		exit(1);
-	}
-	if (file->flags & FILE_SCANNED) {
-		printf("%s:%d: file '%s' is already sourced from '%s'\n",
-		       zconf_curname(), zconf_lineno(), name,
-		       file->parent->name);
-		exit(1);
+	for (iter = current_file->parent; iter; iter = iter->parent ) {
+		if (!strcmp(current_file->name,iter->name) ) {
+			printf("%s:%d: recursive inclusion detected. "
+			       "Inclusion path:\n  current file : '%s'\n",
+			       zconf_curname(), zconf_lineno(),
+			       zconf_curname());
+			iter = current_file->parent;
+			while (iter && \
+			       strcmp(iter->name,current_file->name)) {
+				printf("  included from: '%s:%d'\n",
+				       iter->name, iter->lineno-1);
+				iter = iter->parent;
+			}
+			if (iter)
+				printf("  included from: '%s:%d'\n",
+				       iter->name, iter->lineno+1);
+			exit(1);
+		}
 	}
 	file->flags |= FILE_BUSY;
 	file->lineno = 1;
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 3dbaec1..f23e3af 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -299,6 +299,7 @@ void zconf_initscan(const char *name)
 
 void zconf_nextfile(const char *name)
 {
+	struct file *iter;
 	struct file *file = file_lookup(name);
 	struct buffer *buf = malloc(sizeof(*buf));
 	memset(buf, 0, sizeof(*buf));
@@ -314,16 +315,24 @@ void zconf_nextfile(const char *name)
 	buf->parent = current_buf;
 	current_buf = buf;
 
-	if (file->flags & FILE_BUSY) {
-		printf("%s:%d: do not source '%s' from itself\n",
-		       zconf_curname(), zconf_lineno(), name);
-		exit(1);
-	}
-	if (file->flags & FILE_SCANNED) {
-		printf("%s:%d: file '%s' is already sourced from '%s'\n",
-		       zconf_curname(), zconf_lineno(), name,
-		       file->parent->name);
-		exit(1);
+	for (iter = current_file->parent; iter; iter = iter->parent ) {
+		if (!strcmp(current_file->name,iter->name) ) {
+			printf("%s:%d: recursive inclusion detected. "
+			       "Inclusion path:\n  current file : '%s'\n",
+			       zconf_curname(), zconf_lineno(),
+			       zconf_curname());
+			iter = current_file->parent;
+			while (iter && \
+			       strcmp(iter->name,current_file->name)) {
+				printf("  included from: '%s:%d'\n",
+				       iter->name, iter->lineno-1);
+				iter = iter->parent;
+			}
+			if (iter)
+				printf("  included from: '%s:%d'\n",
+				       iter->name, iter->lineno+1);
+			exit(1);
+		}
 	}
 	file->flags |= FILE_BUSY;
 	file->lineno = 1;
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] kconfig: get rid of unused flags
  2011-02-24 18:36 [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
  2011-02-24 18:36 ` [PATCH 1/2] kconfig: allow multiple inclusion of the same file Yann E. MORIN
@ 2011-02-24 18:36 ` Yann E. MORIN
  2011-03-02 19:48 ` [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
  2011-03-15 19:58 ` Yann E. MORIN
  3 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2011-02-24 18:36 UTC (permalink / raw)
  To: linux-kbuild

Now that we detect recusrion of sourced files, get rid of
now unused flags.

Regenerate lex.zconf.c_shipped file.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
---
 scripts/kconfig/expr.h              |    4 ----
 scripts/kconfig/lex.zconf.c_shipped |    4 ----
 scripts/kconfig/zconf.l             |    4 ----
 3 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 79ab6e7..c2ea931 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -20,12 +20,8 @@ struct file {
 	struct file *parent;
 	const char *name;
 	int lineno;
-	int flags;
 };
 
-#define FILE_BUSY		0x0001
-#define FILE_SCANNED		0x0002
-
 typedef enum tristate {
 	no, mod, yes
 } tristate;
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
index f4b3b1a..d918291 100644
--- a/scripts/kconfig/lex.zconf.c_shipped
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -2363,7 +2363,6 @@ void zconf_initscan(const char *name)
 
 	current_file = file_lookup(name);
 	current_file->lineno = 1;
-	current_file->flags = FILE_BUSY;
 }
 
 void zconf_nextfile(const char *name)
@@ -2403,7 +2402,6 @@ void zconf_nextfile(const char *name)
 			exit(1);
 		}
 	}
-	file->flags |= FILE_BUSY;
 	file->lineno = 1;
 	file->parent = current_file;
 	current_file = file;
@@ -2413,8 +2411,6 @@ static void zconf_endfile(void)
 {
 	struct buffer *parent;
 
-	current_file->flags |= FILE_SCANNED;
-	current_file->flags &= ~FILE_BUSY;
 	current_file = current_file->parent;
 
 	parent = current_buf->parent;
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index f23e3af..b22f884 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -294,7 +294,6 @@ void zconf_initscan(const char *name)
 
 	current_file = file_lookup(name);
 	current_file->lineno = 1;
-	current_file->flags = FILE_BUSY;
 }
 
 void zconf_nextfile(const char *name)
@@ -334,7 +333,6 @@ void zconf_nextfile(const char *name)
 			exit(1);
 		}
 	}
-	file->flags |= FILE_BUSY;
 	file->lineno = 1;
 	file->parent = current_file;
 	current_file = file;
@@ -344,8 +342,6 @@ static void zconf_endfile(void)
 {
 	struct buffer *parent;
 
-	current_file->flags |= FILE_SCANNED;
-	current_file->flags &= ~FILE_BUSY;
 	current_file = current_file->parent;
 
 	parent = current_buf->parent;
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent)
  2011-02-24 18:36 [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
  2011-02-24 18:36 ` [PATCH 1/2] kconfig: allow multiple inclusion of the same file Yann E. MORIN
  2011-02-24 18:36 ` [PATCH 2/2] kconfig: get rid of unused flags Yann E. MORIN
@ 2011-03-02 19:48 ` Yann E. MORIN
  2011-03-15 19:58 ` Yann E. MORIN
  3 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2011-03-02 19:48 UTC (permalink / raw)
  To: linux-kbuild

Hello All!

On Thursday 24 February 2011 19:36:41 Yann E. MORIN wrote:
> This patch series makes it possible to source a file multiple times,
> eg. from different files, and/or under different conditions. Care has
> been taken to avoid circular inclusion, of course.

Ping ?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent)
  2011-02-24 18:36 [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
                   ` (2 preceding siblings ...)
  2011-03-02 19:48 ` [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
@ 2011-03-15 19:58 ` Yann E. MORIN
  2011-04-15 13:31   ` Michal Marek
  3 siblings, 1 reply; 6+ messages in thread
From: Yann E. MORIN @ 2011-03-15 19:58 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Michal Marek

Hello !

On Thursday 24 February 2011 19:36:41 Yann E. MORIN wrote:
> This patch series makes it possible to source a file multiple times,
> eg. from different files, and/or under different conditions. Care has
> been taken to avoid circular inclusion, of course.

Really, no comment on this? :-)

Even if it is not wanted upstream, any comment on the validity of the code?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent)
  2011-03-15 19:58 ` Yann E. MORIN
@ 2011-04-15 13:31   ` Michal Marek
  0 siblings, 0 replies; 6+ messages in thread
From: Michal Marek @ 2011-04-15 13:31 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: linux-kbuild

On Tue, Mar 15, 2011 at 08:58:57PM +0100, Yann E. MORIN wrote:
> Hello !
> 
> On Thursday 24 February 2011 19:36:41 Yann E. MORIN wrote:
> > This patch series makes it possible to source a file multiple times,
> > eg. from different files, and/or under different conditions. Care has
> > been taken to avoid circular inclusion, of course.
> 
> Really, no comment on this? :-)
> 
> Even if it is not wanted upstream, any comment on the validity of the code?

Sorry for the delay. I had a look at the patch now, and it doesn't allow
anything worse than what is already possible if you open-code the
included kconfig snippet. So I merged it into kbuild-2.6.git#kconfig.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-15 13:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24 18:36 [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
2011-02-24 18:36 ` [PATCH 1/2] kconfig: allow multiple inclusion of the same file Yann E. MORIN
2011-02-24 18:36 ` [PATCH 2/2] kconfig: get rid of unused flags Yann E. MORIN
2011-03-02 19:48 ` [PATCH 0/2] kconfig: allow multiple inclusion of the same file (resent) Yann E. MORIN
2011-03-15 19:58 ` Yann E. MORIN
2011-04-15 13:31   ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).