tools.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef CCAN_TOOLS_H
  2. #define CCAN_TOOLS_H
  3. #include <stdbool.h>
  4. #define IDENT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
  5. "abcdefghijklmnopqrstuvwxyz" \
  6. "01234567889_"
  7. #define SPACE_CHARS " \f\n\r\t\v"
  8. #define CFLAGS "-g -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror"
  9. #define COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage"
  10. /* This actually compiles and runs the info file to get dependencies. */
  11. char **get_deps(const void *ctx, const char *dir, bool recurse,
  12. char **infofile);
  13. /* This is safer: just looks for ccan/ strings in info */
  14. char **get_safe_ccan_deps(const void *ctx, const char *dir,
  15. bool recurse, char **infofile);
  16. /* This also needs to compile the info file. */
  17. char **get_libs(const void *ctx, const char *dir,
  18. unsigned int *num, char **infofile);
  19. /* From tools.c */
  20. /* If set, print all commands run, all output they give and exit status. */
  21. extern bool tools_verbose;
  22. char *talloc_basename(const void *ctx, const char *dir);
  23. char *talloc_dirname(const void *ctx, const char *dir);
  24. char *talloc_getcwd(const void *ctx);
  25. char *run_command(const void *ctx, unsigned int *time_ms, const char *fmt, ...);
  26. char *run_with_timeout(const void *ctx, const char *cmd,
  27. bool *ok, unsigned *timeout_ms);
  28. char *temp_dir(const void *ctx);
  29. bool move_file(const char *oldname, const char *newname);
  30. /* From compile.c.
  31. *
  32. * These all compile into a temporary dir, and return the filename.
  33. * On failure they return NULL, and errmsg is set to compiler output.
  34. */
  35. /* If set, say what we're compiling to. */
  36. extern bool compile_verbose;
  37. /* Compile multiple object files into a single. */
  38. char *link_objects(const void *ctx, const char *basename, bool in_pwd,
  39. const char *objs, char **errmsg);
  40. /* Compile a single C file to an object file. Returns errmsg if fails. */
  41. char *compile_object(const void *ctx, const char *cfile, const char *ccandir,
  42. const char *extra_cflags,
  43. const char *outfile);
  44. /* Compile and link single C file, with object files, libs, etc. NULL on
  45. * success, error output on fail. */
  46. char *compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
  47. const char *objs, const char *extra_cflags,
  48. const char *libs, const char *outfile);
  49. /* If in_pwd is false, return a file int temp_dir, otherwise a local file. */
  50. char *maybe_temp_file(const void *ctx, const char *extension, bool in_pwd,
  51. const char *srcname);
  52. /* Default wait for run_command. Should never time out. */
  53. extern const unsigned int default_timeout_ms;
  54. #endif /* CCAN_TOOLS_H */