1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/foreach/foreach.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 = tal_fmt(m, "%s/%s", m->dir, i->name);
41 i->compiled[ctype] = temp_file(m, "", fullfile);
42 if (!compile_object(m, fullfile, ccan_dir, compiler, flags,
43 i->compiled[ctype], &output)) {
44 tal_free(i->compiled[ctype]);
45 i->compiled[ctype] = NULL;
47 "Dependency %s did not build:\n%s",
54 char *build_submodule(struct manifest *m, const char *flags,
55 enum compile_type ctype)
59 if (m->compiled[ctype])
62 if (!expect_obj_file(m))
66 printf(" Building dependency %s\n", m->dir);
68 errstr = build_subdir_objs(m, flags, ctype);
72 m->compiled[ctype] = build_module(m, ctype, &errstr);
73 if (!m->compiled[ctype])
78 static void check_depends_built(struct manifest *m,
79 unsigned int *timeleft, struct score *score)
81 struct list_head *list;
83 foreach_ptr(list, &m->deps, &m->test_deps) {
85 list_for_each(list, i, list) {
88 errstr = build_submodule(i, cflags, COMPILE_NORMAL);
91 score->error = tal_fmt(score,
103 score->score = score->total;
106 struct ccanlint depends_build = {
107 .key = "depends_build",
108 .name = "Module's CCAN dependencies can be found or built",
109 .check = check_depends_built,
110 .can_run = can_build,
111 .needs = "depends_exist test_depends_exist info_ported"
114 REGISTER_TEST(depends_build);