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