History

fixdep: accept extra dependencies on stdin

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

Nicolas Pitre committed 10 years ago

Commit d8329e31 parent f2355411 file · +45 −15Browse files

Showing the changes to scripts/basic (1 of 1 file). Show all

Unified · Split

scripts/basic/fixdep.c+45−15
@@ -120,13 +120,15 @@ · 119 unmodified lines
120120 #define INT_NFIG ntohl(0x4e464947)
121121 #define INT_FIG_ ntohl(0x4649475f)
122122
123+int insert_extra_deps;
123124 char *target;
124125 char *depfile;
125126 char *cmdline;
126127
127128 static void usage(void)
128129 {
129− fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
130+ fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n");
131+ fprintf(stderr, " -e insert extra dependencies given on stdin\n");
130132 exit(1);
131133 }
132134
@@ -138,6 +140,40 @@ static void print_cmdline(void) · 5 unmodified lines
138140 printf("cmd_%s := %s\n\n", target, cmdline);
139141 }
140142
143+/*
144+ * Print out a dependency path from a symbol name
145+ */
146+static void print_config(const char *m, int slen)
147+{
148+ int c, i;
149+
150+ printf(" $(wildcard include/config/");
151+ for (i = 0; i < slen; i++) {
152+ c = m[i];
153+ if (c == '_')
154+ c = '/';
155+ else
156+ c = tolower(c);
157+ putchar(c);
158+ }
159+ printf(".h) \\\n");
160+}
161+
162+static void do_extra_deps(void)
163+{
164+ if (insert_extra_deps) {
165+ char buf[80];
166+ while(fgets(buf, sizeof(buf), stdin)) {
167+ int len = strlen(buf);
168+ if (len < 2 || buf[len-1] != '\n') {
169+ fprintf(stderr, "fixdep: bad data on stdin\n");
170+ exit(1);
171+ }
172+ print_config(buf, len-1);
173+ }
174+ }
175+}
176+
141177 struct item {
142178 struct item *next;
143179 unsigned int len;
@@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash) · 53 unmodified lines
197233 static void use_config(const char *m, int slen)
198234 {
199235 unsigned int hash = strhash(m, slen);
200− int c, i;
201236
202237 if (is_defined_config(m, slen, hash))
203238 return;
204239
205240 define_config(m, slen, hash);
206−
207− printf(" $(wildcard include/config/");
208− for (i = 0; i < slen; i++) {
209− c = m[i];
210− if (c == '_')
211− c = '/';
212− else
213− c = tolower(c);
214− putchar(c);
215− }
216− printf(".h) \\\n");
241+ print_config(m, slen);
217242 }
218243
219244 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) · 30 unmodified lines
250275 }
251276 }
252277
253−/* test is s ends in sub */
278+/* test if s ends in sub */
254279 static int strrcmp(const char *s, const char *sub)
255280 {
256281 int slen = strlen(s);
@@ -378,6 +403,8 @@ static void parse_dep_file(void *map, size_t len) · 121 unmodified lines
378403 exit(1);
379404 }
380405
406+ do_extra_deps();
407+
381408 printf("\n%s: $(deps_%s)\n\n", target, target);
382409 printf("$(deps_%s):\n", target);
383410 }
@@ -434,7 +461,10 @@ int main(int argc, char *argv[]) · 50 unmodified lines
434461 {
435462 traps();
436463
437− if (argc != 4)
464+ if (argc == 5 && !strcmp(argv[1], "-e")) {
465+ insert_extra_deps = 1;
466+ argv++;
467+ } else if (argc != 4)
438468 usage();
439469
440470 depfile = argv[1];