ccan_depends.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. bool ccan = true;
  14. if (argv[1] && streq(argv[1], "--direct")) {
  15. argv++;
  16. argc--;
  17. recurse = false;
  18. }
  19. if (argv[1] && streq(argv[1], "--compile")) {
  20. argv++;
  21. argc--;
  22. compile = true;
  23. }
  24. if (argv[1] && streq(argv[1], "--non-ccan")) {
  25. argv++;
  26. argc--;
  27. ccan = false;
  28. }
  29. if (argc != 2)
  30. errx(1, "Usage: ccan_depends [--direct] [--compile] [--non-ccan] <dir>\n"
  31. "Spits out all the ccan dependencies (recursively unless --direct)");
  32. /* We find depends without compiling by looking for ccan/ */
  33. if (!ccan && !compile)
  34. errx(1, "--non-ccan needs --compile");
  35. if (compile)
  36. deps = get_deps(talloc_autofree_context(), argv[1], recurse);
  37. else
  38. deps = get_safe_ccan_deps(talloc_autofree_context(), argv[1],
  39. recurse);
  40. for (i = 0; deps[i]; i++)
  41. if (strstarts(deps[i], "ccan/") == ccan)
  42. printf("%s\n", deps[i]);
  43. return 0;
  44. }