1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
17 static const char *can_build(struct manifest *m)
20 return "Safe mode enabled";
24 /* FIXME: recursive ccanlint if they ask for it. */
25 static bool expect_obj_file(const char *dir)
28 struct manifest *dep_man;
31 olddir = talloc_getcwd(dir);
33 err(1, "Getting current directory");
35 /* We will fail below if this doesn't exist. */
39 dep_man = get_manifest(dir);
40 if (chdir(olddir) != 0)
41 err(1, "Returning to original directory '%s'", olddir);
44 /* If it has C files, we expect an object file built from them. */
45 has_c_files = !list_empty(&dep_man->c_files);
50 static void *check_depends_built(struct manifest *m)
55 list_for_each(&m->dep_dirs, i, list) {
59 if (!expect_obj_file(i->name))
62 objfile = talloc_asprintf(m, "%s.o", i->name);
63 if (stat(objfile, &st) != 0) {
64 report = talloc_asprintf_append(report,
68 struct ccan_file *f = new_ccan_file(m, objfile);
69 list_add_tail(&m->dep_objs, &f->list);
73 return talloc_steal(m, report);
76 static const char *describe_depends_built(struct manifest *m,
79 return talloc_asprintf(check_result,
80 "The following dependencies are not built:\n"
81 "%s", (char *)check_result);
84 struct ccanlint depends_built = {
85 .name = "CCAN dependencies are built",
87 .check = check_depends_built,
88 .describe = describe_depends_built,
92 REGISTER_TEST(depends_built, &depends_exist, NULL);