]> git.ozlabs.org Git - ccan/blob - tools/ccan_depends.c
5e9f812ecc46667557097e3bd2dc67fe71fab930
[ccan] / tools / ccan_depends.c
1 #include "tools.h"
2 #include <err.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include "string/string.h"
6 #include "talloc/talloc.h"
7
8 int main(int argc, char *argv[])
9 {
10         char **deps;
11         unsigned int i;
12         bool compile = false;
13
14         if (argv[1] && streq(argv[1], "--compile")) {
15                 argv++;
16                 argc--;
17                 compile = true;
18         }
19         if (argc != 2)
20                 errx(1, "Usage: ccan_depends [--compile] <dir>\n"
21                         "Spits out all the ccan dependencies (recursively)");
22
23         if (compile)
24                 deps = get_deps(talloc_autofree_context(), argv[1]);
25         else
26                 deps = get_safe_ccan_deps(talloc_autofree_context(), argv[1]);
27
28         for (i = 0; deps[i]; i++)
29                 if (strstarts(deps[i], "ccan/"))
30                         printf("%s\n", deps[i]);
31         return 0;
32 }