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, compiler, cflags,
41 i->compiled, &output)) {
42 talloc_free(i->compiled);
44 return talloc_asprintf(m,
46 " did not build:\n%s",
53 char *build_submodule(struct manifest *m)
61 if (!expect_obj_file(m))
64 m->compiled = talloc_asprintf(m, "%s.o", m->dir);
65 if (stat(m->compiled, &st) == 0)
69 printf(" Building dependency %s\n", m->dir);
71 errstr = build_subdir_objs(m);
75 m->compiled = build_module(m, false, &errstr);
81 static void check_depends_built(struct manifest *m,
83 unsigned int *timeleft, struct score *score)
87 list_for_each(&m->deps, i, list) {
88 char *errstr = build_submodule(i);
91 score->error = talloc_asprintf(score,
93 " did not build:\n%s",
100 score->score = score->total;
103 struct ccanlint depends_build = {
104 .key = "depends_build",
105 .name = "Module's CCAN dependencies can be found or built",
106 .check = check_depends_built,
107 .can_run = can_build,
108 .needs = "depends_exist"
111 REGISTER_TEST(depends_build);