4 #include <ccan/compiler/compiler.h>
5 #include <ccan/rbuf/rbuf.h>
6 #include <ccan/tal/tal.h>
7 #include <ccan/tal/str/str.h>
11 /* These are the defaults. */
12 #define DEFAULT_CCAN_COMPILER "cc"
13 #define DEFAULT_CCAN_CFLAGS "-g"
15 #define IDENT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
16 "abcdefghijklmnopqrstuvwxyz" \
19 #define SPACE_CHARS " \f\n\r\t\v"
21 #define COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage"
23 /* Actual compiler and cflags (defaults to CCAN_COMPILER and CCAN_CFLAGS). */
24 extern const char *compiler, *cflags;
26 /* This compiles up the _info file into a temporary. */
27 char *compile_info(const void *ctx, const char *dir);
29 /* This actually compiles and runs the info file to get dependencies. */
30 char **get_deps(const void *ctx, const char *dir, const char *style,
32 char *(*get_info)(const void *ctx, const char *dir));
34 /* This is safer: just looks for ccan/ strings in info */
35 char **get_safe_ccan_deps(const void *ctx, const char *dir, const char *style,
38 /* This also needs to compile the info file:
39 * style == NULL: don't recurse.
40 * style == depends: recurse dependencies.
41 * style == testdepends: recurse testdepends and depends.
43 char **get_libs(const void *ctx, const char *dir, const char *style,
44 char *(*get_info)(const void *ctx, const char *dir));
46 char **get_cflags(const void *ctx, const char *dir,
47 char *(*get_info)(const void *ctx, const char *dir));
50 /* If set, print all commands run, all output they give and exit status. */
51 extern bool tools_verbose;
52 bool PRINTF_FMT(4,5) run_command(const void *ctx,
53 unsigned int *time_ms,
55 const char *fmt, ...);
56 char *run_with_timeout(const void *ctx, const char *cmd,
57 bool *ok, unsigned *timeout_ms);
58 const char *temp_dir(void);
59 void keep_temp_dir(void);
60 bool move_file(const char *oldname, const char *newname);
62 void *do_tal_realloc(void *p, size_t size);
64 /* Freed on exit: a good parent for auto cleanup. */
65 tal_t *autofree(void);
69 * These all compile into a temporary dir, and return the filename.
70 * On failure they return NULL, and errmsg is set to compiler output.
72 /* If set, say what we're compiling to. */
73 extern bool compile_verbose;
74 /* Compile multiple object files into a single. */
75 char *link_objects(const void *ctx, const char *basename,
76 const char *objs, char **errmsg);
77 /* Compile a single C file to an object file. Returns false if fails. */
78 bool compile_object(const void *ctx, const char *cfile, const char *ccandir,
81 const char *outfile, char **output);
82 /* Compile and link single C file, with object files, libs, etc. */
83 bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
85 const char *compiler, const char *cflags,
86 const char *libs, const char *outfile, char **output);
88 /* Returns a file in temp_dir() */
89 char *temp_file(const void *ctx, const char *extension, const char *srcname);
91 /* Default wait for run_command. Should never time out. */
92 extern const unsigned int default_timeout_ms;
94 /* Get ccan/ top dir, given a directory within it. */
95 const char *find_ccan_dir(const char *base);
96 #endif /* CCAN_TOOLS_H */