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