]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/compulsory_tests/build_objs.c
2f189e859f25a8b523505609cafd31c429e3a443
[ccan] / tools / ccanlint / compulsory_tests / build_objs.c
1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include <limits.h>
10 #include <errno.h>
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <err.h>
14 #include <string.h>
15 #include <ctype.h>
16
17 static const char *can_build(struct manifest *m)
18 {
19         if (safe_mode)
20                 return "Safe mode enabled";
21         return NULL;
22 }
23
24 static void *check_objs_build(struct manifest *m)
25 {
26         char *report = NULL;
27         struct ccan_file *i;
28
29         list_for_each(&m->c_files, i, list) {
30                 char *err;
31
32                 /* One point for each obj file. */
33                 build_objs.total_score++;
34
35                 i->compiled = compile_object(m, i->name, &err);
36                 if (!i->compiled) {
37                         if (report)
38                                 report = talloc_append_string(report, err);
39                         else
40                                 report = err;
41                 }
42         }
43         return report;
44 }
45
46 static const char *describe_objs_build(struct manifest *m, void *check_result)
47 {
48         return check_result;
49 }
50
51 struct ccanlint build_objs = {
52         .name = "Module object files can be built",
53         .check = check_objs_build,
54         .describe = describe_objs_build,
55         .can_run = can_build,
56 };
57
58 REGISTER_TEST(build_objs, &depends_exist, NULL);