]> git.ozlabs.org Git - ccan/blob - tools/tools.h
junkcode: new addition.
[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 /* FIXME: Nested functions break with -Wmissing-prototypes -Wmissing-declarations */
12 #define CFLAGS "-g -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Werror"
13
14 #define COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage"
15
16 /* This actually compiles and runs the info file to get dependencies. */
17 char **get_deps(const void *ctx, const char *dir, bool recurse,
18                 char **infofile);
19
20 /* This is safer: just looks for ccan/ strings in info */
21 char **get_safe_ccan_deps(const void *ctx, const char *dir,
22                           bool recurse, char **infofile);
23
24 /* This also needs to compile the info file. */
25 char **get_libs(const void *ctx, const char *dir,
26                 unsigned int *num, char **infofile);
27
28 /* From tools.c */
29 /* If set, print all commands run, all output they give and exit status. */
30 extern bool tools_verbose;
31 char *talloc_basename(const void *ctx, const char *dir);
32 char *talloc_dirname(const void *ctx, const char *dir);
33 char *talloc_getcwd(const void *ctx);
34 char *run_command(const void *ctx, unsigned int *time_ms, const char *fmt, ...);
35 char *run_with_timeout(const void *ctx, const char *cmd,
36                        bool *ok, unsigned *timeout_ms);
37 char *temp_dir(const void *ctx);
38 char *temp_file(const void *ctx, const char *extension);
39 bool move_file(const char *oldname, const char *newname);
40
41 /* From compile.c.
42  *
43  * These all compile into a temporary dir, and return the filename.
44  * On failure they return NULL, and errmsg is set to compiler output.
45  */
46 /* Compile multiple object files into a single. */
47 char *link_objects(const void *ctx, const char *objs, char **errmsg);
48 /* Compile a single C file to an object file.  Returns errmsg if fails. */
49 char *compile_object(const void *ctx, const char *cfile, const char *ccandir,
50                      const char *extra_cflags,
51                      const char *outfile);
52 /* Compile and link single C file, with object files, libs, etc.  NULL on
53  * success, error output on fail. */
54 char *compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
55                        const char *objs, const char *extra_cflags,
56                        const char *libs, const char *outfile);
57
58 /* If keep is false, return a temporary file.  Otherwise, base it on srcname */
59 char *maybe_temp_file(const void *ctx, const char *extension, bool keep,
60                       const char *srcname);
61
62 /* Default wait for run_command.  Should never time out. */
63 extern const unsigned int default_timeout_ms;
64
65 #endif /* CCAN_TOOLS_H */