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 char *add_dep(char *sofar, struct manifest *m, const char *dep)
22 f = new_ccan_file(m, ccan_dir, talloc_strdup(m, dep));
23 if (stat(f->fullname, &st) != 0) {
24 return talloc_asprintf_append(sofar,
25 "ccan/%s: expected it in"
30 list_add_tail(&m->dep_dirs, &f->list);
34 static void *check_depends_exist(struct manifest *m, unsigned int *timeleft)
39 char *updir = talloc_strdup(m, m->dir);
41 *strrchr(updir, '/') = '\0';
44 deps = get_safe_ccan_deps(m, m->dir, true,
45 &m->info_file->compiled);
47 deps = get_deps(m, m->dir, true, &m->info_file->compiled);
49 for (i = 0; deps[i]; i++) {
50 if (!strstarts(deps[i], "ccan/"))
53 report = add_dep(report, m, deps[i]);
58 static const char *describe_depends_exist(struct manifest *m,
61 return talloc_asprintf(check_result,
62 "The following dependencies are are expected:\n"
63 "%s", (char *)check_result);
66 struct ccanlint depends_exist = {
67 .key = "depends-exist",
68 .name = "Module's CCAN dependencies are present",
70 .check = check_depends_exist,
71 .describe = describe_depends_exist,
74 REGISTER_TEST(depends_exist, NULL);