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 bool expect_obj_file(struct manifest *m)
27 /* If it has C files, we expect an object file built from them. */
28 return !list_empty(&m->c_files);
31 static char *build_subdir_objs(struct manifest *m)
35 list_for_each(&m->c_files, i, list) {
36 char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
39 i->compiled = maybe_temp_file(m, "", false, fullfile);
40 if (!compile_object(m, fullfile, ccan_dir, "", i->compiled,
42 talloc_free(i->compiled);
44 return talloc_asprintf(m,
46 " did not build:\n%s",
53 static void check_depends_built(struct manifest *m,
55 unsigned int *timeleft, struct score *score)
60 list_for_each(&m->deps, i, list) {
62 if (!expect_obj_file(i))
65 i->compiled = talloc_asprintf(i, "%s.o", i->dir);
66 if (stat(i->compiled, &st) == 0)
70 printf(" Building dependency %s\n", i->dir);
71 score->error = build_subdir_objs(i);
74 i->compiled = build_module(i, keep, &errstr);
76 score->error = talloc_asprintf(score,
78 " did not build:\n%s",
86 score->score = score->total;
90 struct ccanlint depends_built = {
91 .key = "depends-built",
92 .name = "Module's CCAN dependencies can be found or built",
93 .check = check_depends_built,
97 REGISTER_TEST(depends_built, &depends_exist, NULL);