1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
18 static const char *can_build(struct manifest *m)
21 return "Safe mode enabled";
25 static char *obj_list(const struct manifest *m)
27 char *list = talloc_strdup(m, "");
30 /* Objects from all the C files. */
31 list_for_each(&m->c_files, i, list)
32 list = talloc_asprintf_append(list, "%s ", i->compiled);
37 char *build_module(struct manifest *m, bool keep, char **errstr)
39 char *name = link_objects(m, m->basename, false, obj_list(m), errstr);
42 char *realname = talloc_asprintf(m, "%s.o", m->dir);
43 /* We leave this object file around, all built. */
44 if (!move_file(name, realname))
45 err(1, "Renaming %s to %s", name, realname);
52 static void do_build(struct manifest *m,
54 unsigned int *timeleft,
59 if (list_empty(&m->c_files)) {
60 /* No files? No score, but we "pass". */
66 m->compiled = build_module(m, keep, &errstr);
68 score_file_error(score, NULL, 0, "%s", errstr);
73 score->score = score->total;
76 struct ccanlint module_builds = {
77 .key = "module_builds",
78 .name = "Module can be built from object files",
81 .needs = "objects_build"
84 REGISTER_TEST(module_builds);