1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
17 static const char *can_build(struct manifest *m)
20 return "Safe mode enabled";
24 static bool compile_obj(struct ccan_file *c_file, char *objfile, char **report)
28 contents = run_command(objfile, "cc " CFLAGS " -o %s -c %s",
29 objfile, c_file->name);
32 *report = talloc_append_string(*report, contents);
40 static int cleanup_obj(char *objfile)
46 static void *check_objs_build(struct manifest *m)
51 /* One point for each obj file. */
52 list_for_each(&m->c_files, i, list)
53 build_objs.total_score++;
55 list_for_each(&m->c_files, i, list) {
56 char *objfile = talloc_strdup(m, i->name);
57 objfile[strlen(objfile)-1] = 'o';
59 if (compile_obj(i, objfile, &report))
60 talloc_set_destructor(objfile, cleanup_obj);
65 static const char *describe_objs_build(struct manifest *m, void *check_result)
67 return talloc_asprintf(check_result,
68 "%s", (char *)check_result);
71 struct ccanlint build_objs = {
72 .name = "Module object files can be built",
73 .check = check_objs_build,
74 .describe = describe_objs_build,
78 REGISTER_TEST(build_objs, &depends_exist, NULL);