tools.h 2.6 KB

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