diff options
| author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2016-02-12 15:00:50 -0500 |
|---|---|---|
| committer | Nicolas Pitre <nicolas.pitre@linaro.org> | 2016-03-29 16:19:40 -0400 |
| commit | d8329e35cc08e07a3250b3873325d300c1e91c81 (patch) | |
| tree | 91982e1d23c85b78ec45fd16f0c3e7f1f8071356 /scripts/basic | |
| parent | f235541699bcf14fb8be797c6bc1d7106df0eb64 (diff) | |
fixdep: accept extra dependencies on stdin
... and merge them in the list of parsed dependencies.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Diffstat (limited to 'scripts/basic')
| -rw-r--r-- | scripts/basic/fixdep.c | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index caef815d1743..7e90a1f7de0f 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c | |||
| @@ -120,13 +120,15 @@ | |||
| 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 | ||
| 123 | int insert_extra_deps; | ||
| 123 | char *target; | 124 | char *target; |
| 124 | char *depfile; | 125 | char *depfile; |
| 125 | char *cmdline; | 126 | char *cmdline; |
| 126 | 127 | ||
| 127 | static void usage(void) | 128 | static 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) | |||
| 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 | */ | ||
| 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 | |||
| 141 | struct item { | 177 | struct 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) | |||
| 197 | static void use_config(const char *m, int slen) | 233 | static 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 | ||
| 219 | static void parse_config_file(const char *map, size_t len) | 244 | 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) | |||
| 250 | } | 275 | } |
| 251 | } | 276 | } |
| 252 | 277 | ||
| 253 | /* test is s ends in sub */ | 278 | /* test if s ends in sub */ |
| 254 | static int strrcmp(const char *s, const char *sub) | 279 | static 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) | |||
| 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[]) | |||
| 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]; |
