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