ccan_depends.c 851 B

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