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)
60 if (!expect_obj_file(m))
64 printf(" Building dependency %s\n", m->dir);
66 errstr = build_subdir_objs(m);
70 m->compiled = build_module(m, false, &errstr);
76 static void check_depends_built(struct manifest *m,
78 unsigned int *timeleft, struct score *score)
82 list_for_each(&m->deps, i, list) {
83 char *errstr = build_submodule(i);
86 score->error = talloc_asprintf(score,
88 " did not build:\n%s",
95 score->score = score->total;
98 struct ccanlint depends_build = {
99 .key = "depends_build",
100 .name = "Module's CCAN dependencies can be found or built",
101 .check = check_depends_built,
102 .can_run = can_build,
103 .needs = "depends_exist"
106 REGISTER_TEST(depends_build);