]> git.ozlabs.org Git - ccan/blob - tools/ccan_depends.c
compiler: Add PURE_FUNCTION
[ccan] / tools / ccan_depends.c
1 #include "tools.h"
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <ccan/err/err.h>
5 #include <ccan/str/str.h>
6
7 int main(int argc, char *argv[])
8 {
9         char **deps;
10         unsigned int i;
11         bool compile = false;
12         bool recurse = true;
13         bool ccan = true;
14         const char *style = "depends";
15
16         if (argv[1] && streq(argv[1], "--direct")) {
17                 argv++;
18                 argc--;
19                 recurse = false;
20         }
21         if (argv[1] && streq(argv[1], "--compile")) {
22                 argv++;
23                 argc--;
24                 compile = true;
25         }
26         if (argv[1] && streq(argv[1], "--non-ccan")) {
27                 argv++;
28                 argc--;
29                 ccan = false;
30         }
31         if (argv[1] && streq(argv[1], "--tests")) {
32                 argv++;
33                 argc--;
34                 style = "testdepends";
35         }
36         if (argc != 2)
37                 errx(1, "Usage: ccan_depends [--direct] [--compile] [--non-ccan] [--tests] <dir>\n"
38                         "Spits out all the ccan dependencies (recursively unless --direct)");
39
40         /* We find depends without compiling by looking for ccan/ */
41         if (!ccan && !compile)
42                 errx(1, "--non-ccan needs --compile");
43
44         if (compile)
45                 deps = get_deps(NULL, argv[1], style, recurse, compile_info);
46         else
47                 deps = get_safe_ccan_deps(NULL, argv[1], style, recurse);
48
49         for (i = 0; deps[i]; i++)
50                 if (strstarts(deps[i], "ccan/") == ccan)
51                         printf("%s\n", deps[i]);
52         return 0;
53 }