]> git.ozlabs.org Git - ccan/commitdiff
--direct for ccan_depends
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Aug 2008 07:49:52 +0000 (17:49 +1000)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Aug 2008 07:49:52 +0000 (17:49 +1000)
tools/ccan_depends.c
tools/depends.c
tools/tools.h

index 5e9f812ecc46667557097e3bd2dc67fe71fab930..ca8c4a610967402a9a8047e7e2b73172eabc81ad 100644 (file)
@@ -10,20 +10,27 @@ int main(int argc, char *argv[])
        char **deps;
        unsigned int i;
        bool compile = false;
+       bool recurse = true;
 
+       if (argv[1] && streq(argv[1], "--direct")) {
+               argv++;
+               argc--;
+               recurse = false;
+       }
        if (argv[1] && streq(argv[1], "--compile")) {
                argv++;
                argc--;
                compile = true;
        }
        if (argc != 2)
-               errx(1, "Usage: ccan_depends [--compile] <dir>\n"
-                       "Spits out all the ccan dependencies (recursively)");
+               errx(1, "Usage: ccan_depends [--direct] [--compile] <dir>\n"
+                       "Spits out all the ccan dependencies (recursively unless --direct)");
 
        if (compile)
-               deps = get_deps(talloc_autofree_context(), argv[1]);
+               deps = get_deps(talloc_autofree_context(), argv[1], recurse);
        else
-               deps = get_safe_ccan_deps(talloc_autofree_context(), argv[1]);
+               deps = get_safe_ccan_deps(talloc_autofree_context(), argv[1],
+                                         recurse);
 
        for (i = 0; deps[i]; i++)
                if (strstarts(deps[i], "ccan/"))
index 7eac9da419a17233e28d0e5dbb1aed4a7c9907f1..d215441eead6acebe84b629d2b3c855b4191098c 100644 (file)
@@ -173,13 +173,21 @@ get_all_deps(const void *ctx, const char *dir,
        return deps;
 }
 
-char **get_deps(const void *ctx, const char *dir)
+char **get_deps(const void *ctx, const char *dir, bool recurse)
 {
+       if (!recurse) {
+               unsigned int num;
+               return get_one_deps(ctx, dir, &num);
+       }
        return get_all_deps(ctx, dir, get_one_deps);
 }
 
-char **get_safe_ccan_deps(const void *ctx, const char *dir)
+char **get_safe_ccan_deps(const void *ctx, const char *dir, bool recurse)
 {
+       if (!recurse) {
+               unsigned int num;
+               return get_one_safe_deps(ctx, dir, &num);
+       }
        return get_all_deps(ctx, dir, get_one_safe_deps);
 }
        
index e43643ddb4d2028ffe1f3f9f9a9b018204876259..a7612c7a4022043f76c40e929dbc362fddc1ef58 100644 (file)
@@ -1,13 +1,14 @@
 #ifndef CCAN_TOOLS_H
 #define CCAN_TOOLS_H
+#include <stdbool.h>
 
 #define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I."
 
 /* This actually compiles and runs the _info.c file to get dependencies. */
-char **get_deps(const void *ctx, const char *dir);
+char **get_deps(const void *ctx, const char *dir, bool recurse);
 
 /* This is safer: just looks for ccan/ strings in _info.c */
-char **get_safe_ccan_deps(const void *ctx, const char *dir);
+char **get_safe_ccan_deps(const void *ctx, const char *dir, bool recurse);
 
 #endif /* CCAN_TOOLS_H */