4 #include <ccan/compiler/compiler.h>
5 #include <ccan/rbuf/rbuf.h>
10 #define CCAN_COMPILER "cc"
13 #define CCAN_CFLAGS "-g -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror"
16 #define IDENT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
17 "abcdefghijklmnopqrstuvwxyz" \
20 #define SPACE_CHARS " \f\n\r\t\v"
22 #define COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage"
24 /* This compiles up the _info file into a temporary. */
25 char *compile_info(const void *ctx, const char *dir);
27 /* This actually compiles and runs the info file to get dependencies. */
28 char **get_deps(const void *ctx, const char *dir, const char *style,
30 char *(*get_info)(const void *ctx, const char *dir));
32 /* This is safer: just looks for ccan/ strings in info */
33 char **get_safe_ccan_deps(const void *ctx, const char *dir, const char *style,
36 /* This also needs to compile the info file:
37 * style == NULL: don't recurse.
38 * style == depends: recurse dependencies.
39 * style == testdepends: recurse testdepends and depends.
41 char **get_libs(const void *ctx, const char *dir, const char *style,
42 char *(*get_info)(const void *ctx, const char *dir));
45 /* If set, print all commands run, all output they give and exit status. */
46 extern bool tools_verbose;
47 char *talloc_basename(const void *ctx, const char *dir);
48 char *talloc_dirname(const void *ctx, const char *dir);
49 char *talloc_getcwd(const void *ctx);
50 bool PRINTF_FMT(4,5) run_command(const void *ctx,
51 unsigned int *time_ms,
53 const char *fmt, ...);
54 char *run_with_timeout(const void *ctx, const char *cmd,
55 bool *ok, unsigned *timeout_ms);
56 const char *temp_dir(const void *ctx);
57 bool move_file(const char *oldname, const char *newname);
59 void *do_talloc_realloc(void *p, size_t size);
60 void *talloc_grab_file(const void *ctx, const char *filename, size_t *size);
64 * These all compile into a temporary dir, and return the filename.
65 * On failure they return NULL, and errmsg is set to compiler output.
67 /* If set, say what we're compiling to. */
68 extern bool compile_verbose;
69 /* Compile multiple object files into a single. */
70 char *link_objects(const void *ctx, const char *basename,
71 const char *objs, char **errmsg);
72 /* Compile a single C file to an object file. Returns false if fails. */
73 bool compile_object(const void *ctx, const char *cfile, const char *ccandir,
76 const char *outfile, char **output);
77 /* Compile and link single C file, with object files, libs, etc. */
78 bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
80 const char *compiler, const char *cflags,
81 const char *libs, const char *outfile, char **output);
83 /* Returns a file in temp_dir() */
84 char *temp_file(const void *ctx, const char *extension, const char *srcname);
86 /* Default wait for run_command. Should never time out. */
87 extern const unsigned int default_timeout_ms;
89 /* Talloc destructor which unlinks file. */
90 int unlink_file_destructor(char *filename);
92 /* Get ccan/ top dir, given a directory within it. */
93 const char *find_ccan_dir(const char *base);
94 #endif /* CCAN_TOOLS_H */