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
120#define INT_NFIG ntohl(0x4e464947)120#define INT_NFIG ntohl(0x4e464947)
121#define INT_FIG_ ntohl(0x4649475f)121#define INT_FIG_ ntohl(0x4649475f)
122 122
123int insert_extra_deps;
123char *target;124char *target;
124char *depfile;125char *depfile;
125char *cmdline;126char *cmdline;
126 127
127static void usage(void)128static void usage(void)
128{129{
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");
130 exit(1);132 exit(1);
131}133}
132 134
@@ -138,6 +140,40 @@ static void print_cmdline(void) · 5 unmodified lines
138 printf("cmd_%s := %s\n\n", target, cmdline);140 printf("cmd_%s := %s\n\n", target, cmdline);
139}141}
140 142
143/*
144 * Print out a dependency path from a symbol name
145 */
146static 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
162static 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
141struct item {177struct item {
142 struct item *next;178 struct item *next;
143 unsigned int len;179 unsigned int len;
@@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash) · 53 unmodified lines
197static void use_config(const char *m, int slen)233static void use_config(const char *m, int slen)
198{234{
199 unsigned int hash = strhash(m, slen);235 unsigned int hash = strhash(m, slen);
200 int c, i;
201 236
202 if (is_defined_config(m, slen, hash))237 if (is_defined_config(m, slen, hash))
203 return;238 return;
204 239
205 define_config(m, slen, hash);240 define_config(m, slen, hash);
206 241 print_config(m, slen);
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");
217}242}
218 243
219static void parse_config_file(const char *map, size_t len)244static 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
250 }275 }
251}276}
252 277
253/* test is s ends in sub */278/* test if s ends in sub */
254static int strrcmp(const char *s, const char *sub)279static int strrcmp(const char *s, const char *sub)
255{280{
256 int slen = strlen(s);281 int slen = strlen(s);
@@ -378,6 +403,8 @@ static void parse_dep_file(void *map, size_t len) · 121 unmodified lines
378 exit(1);403 exit(1);
379 }404 }
380 405
406 do_extra_deps();
407
381 printf("\n%s: $(deps_%s)\n\n", target, target);408 printf("\n%s: $(deps_%s)\n\n", target, target);
382 printf("$(deps_%s):\n", target);409 printf("$(deps_%s):\n", target);
383}410}
@@ -434,7 +461,10 @@ int main(int argc, char *argv[]) · 50 unmodified lines
434{461{
435 traps();462 traps();
436 463
437 if (argc != 4)464 if (argc == 5 && !strcmp(argv[1], "-e")) {
465 insert_extra_deps = 1;
466 argv++;
467 } else if (argc != 4)
438 usage();468 usage();
439 469
440 depfile = argv[1];470 depfile = argv[1];