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


Groups > linux.kernel > #1366694

[PATCH v7 3/8] fixdep: accept extra dependencies on stdin

From Nicolas Pitre <nicolas.pitre@linaro.org>
Newsgroups linux.kernel
Subject [PATCH v7 3/8] fixdep: accept extra dependencies on stdin
Date 2016-03-29 22:50 +0200
Message-ID <ri8Km-35X-13@gated-at.bofh.it> (permalink)
References <ri8Kl-35X-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


... and merge them in the list of parsed dependencies.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
---
 scripts/basic/fixdep.c | 60 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 45 insertions(+), 15 deletions(-)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index caef815d17..7e90a1f7de 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -120,13 +120,15 @@
 #define INT_NFIG ntohl(0x4e464947)
 #define INT_FIG_ ntohl(0x4649475f)
 
+int insert_extra_deps;
 char *target;
 char *depfile;
 char *cmdline;
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
+	fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n");
+	fprintf(stderr, " -e  insert extra dependencies given on stdin\n");
 	exit(1);
 }
 
@@ -138,6 +140,40 @@ static void print_cmdline(void)
 	printf("cmd_%s := %s\n\n", target, cmdline);
 }
 
+/*
+ * Print out a dependency path from a symbol name
+ */
+static void print_config(const char *m, int slen)
+{
+	int c, i;
+
+	printf("    $(wildcard include/config/");
+	for (i = 0; i < slen; i++) {
+		c = m[i];
+		if (c == '_')
+			c = '/';
+		else
+			c = tolower(c);
+		putchar(c);
+	}
+	printf(".h) \\\n");
+}
+
+static void do_extra_deps(void)
+{
+	if (insert_extra_deps) {
+		char buf[80];
+		while(fgets(buf, sizeof(buf), stdin)) {
+			int len = strlen(buf);
+			if (len < 2 || buf[len-1] != '\n') {
+				fprintf(stderr, "fixdep: bad data on stdin\n");
+				exit(1);
+			}
+			print_config(buf, len-1);
+		}
+	}
+}
+
 struct item {
 	struct item	*next;
 	unsigned int	len;
@@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash)
 static void use_config(const char *m, int slen)
 {
 	unsigned int hash = strhash(m, slen);
-	int c, i;
 
 	if (is_defined_config(m, slen, hash))
 	    return;
 
 	define_config(m, slen, hash);
-
-	printf("    $(wildcard include/config/");
-	for (i = 0; i < slen; i++) {
-		c = m[i];
-		if (c == '_')
-			c = '/';
-		else
-			c = tolower(c);
-		putchar(c);
-	}
-	printf(".h) \\\n");
+	print_config(m, slen);
 }
 
 static void parse_config_file(const char *map, size_t len)
@@ -250,7 +275,7 @@ static void parse_config_file(const char *map, size_t len)
 	}
 }
 
-/* test is s ends in sub */
+/* test if s ends in sub */
 static int strrcmp(const char *s, const char *sub)
 {
 	int slen = strlen(s);
@@ -378,6 +403,8 @@ static void parse_dep_file(void *map, size_t len)
 		exit(1);
 	}
 
+	do_extra_deps();
+
 	printf("\n%s: $(deps_%s)\n\n", target, target);
 	printf("$(deps_%s):\n", target);
 }
@@ -434,7 +461,10 @@ int main(int argc, char *argv[])
 {
 	traps();
 
-	if (argc != 4)
+	if (argc == 5 && !strcmp(argv[1], "-e")) {
+		insert_extra_deps = 1;
+		argv++;
+	} else if (argc != 4)
 		usage();
 
 	depfile = argv[1];
-- 
2.5.5

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v7 0/8]/[PULL REQUEST] Trim unused exported kernel symbols Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 2/8] export.h: allow for per-symbol configurable EXPORT_SYMBOL() Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 3/8] fixdep: accept extra dependencies on stdin Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 4/8] kbuild: de-duplicate fixdep usage Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 1/8] kbuild: record needed exported symbols for modules Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 8/8] kconfig option for TRIM_UNUSED_KSYMS Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 6/8] kbuild: create/adjust generated/autoksyms.h Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200
  [PATCH v7 7/8] kbuild: build sample modules along with the rest of the kernel Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-03-29 22:50 +0200

csiph-web