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,
33 enum compile_type ctype)
37 list_for_each(&m->c_files, i, list) {
38 char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
41 i->compiled[ctype] = maybe_temp_file(m, "", false, fullfile);
42 if (!compile_object(m, fullfile, ccan_dir, compiler, flags,
43 i->compiled[ctype], &output)) {
44 talloc_free(i->compiled[ctype]);
45 i->compiled[ctype] = NULL;
46 return talloc_asprintf(m,
48 " did not build:\n%s",
55 char *build_submodule(struct manifest *m, const char *flags,
56 enum compile_type ctype)
60 if (m->compiled[ctype])
63 if (!expect_obj_file(m))
67 printf(" Building dependency %s\n", m->dir);
69 errstr = build_subdir_objs(m, flags, ctype);
73 m->compiled[ctype] = build_module(m, false, ctype, &errstr);
74 if (!m->compiled[ctype])
79 static void check_depends_built(struct manifest *m,
81 unsigned int *timeleft, struct score *score)
85 list_for_each(&m->deps, i, list) {
86 char *errstr = build_submodule(i, cflags, COMPILE_NORMAL);
89 score->error = talloc_asprintf(score,
91 " did not build:\n%s",
98 score->score = score->total;
101 struct ccanlint depends_build = {
102 .key = "depends_build",
103 .name = "Module's CCAN dependencies can be found or built",
104 .check = check_depends_built,
105 .can_run = can_build,
106 .needs = "depends_exist"
109 REGISTER_TEST(depends_build);