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, enum compile_type ctype)
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 ",
38 char *build_module(struct manifest *m, bool keep,
39 enum compile_type ctype, char **errstr)
41 char *name = link_objects(m, m->basename, false, obj_list(m, ctype),
45 char *realname = talloc_asprintf(m, "%s.o", m->dir);
46 assert(ctype == COMPILE_NORMAL);
47 /* We leave this object file around, all built. */
48 if (!move_file(name, realname))
49 err(1, "Renaming %s to %s", name, realname);
56 static void do_build(struct manifest *m,
58 unsigned int *timeleft,
63 if (list_empty(&m->c_files)) {
64 /* No files? No score, but we "pass". */
70 m->compiled[COMPILE_NORMAL]
71 = build_module(m, keep, COMPILE_NORMAL, &errstr);
72 if (!m->compiled[COMPILE_NORMAL]) {
73 score_file_error(score, NULL, 0, "%s", errstr);
78 score->score = score->total;
81 struct ccanlint module_builds = {
82 .key = "module_builds",
83 .name = "Module can be built from object files",
86 .needs = "objects_build"
89 REGISTER_TEST(module_builds);