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)
23 dir = talloc_asprintf(m, "%s/%s", ccan_dir, dep);
24 if (stat(dir, &st) != 0) {
25 return talloc_asprintf_append(sofar,
26 "ccan/%s: expected it in"
31 f = new_ccan_file(m, "", dir);
32 list_add_tail(&m->dep_dirs, &f->list);
36 static void *check_depends_exist(struct manifest *m, unsigned int *timeleft)
41 char *updir = talloc_strdup(m, m->dir);
43 *strrchr(updir, '/') = '\0';
46 deps = get_safe_ccan_deps(m, m->dir, true,
47 &m->info_file->compiled);
49 deps = get_deps(m, m->dir, true, &m->info_file->compiled);
51 for (i = 0; deps[i]; i++) {
52 if (!strstarts(deps[i], "ccan/"))
55 report = add_dep(report, m, deps[i]);
60 static const char *describe_depends_exist(struct manifest *m,
63 return talloc_asprintf(check_result,
64 "The following dependencies are are expected:\n"
65 "%s", (char *)check_result);
68 struct ccanlint depends_exist = {
69 .key = "depends-exist",
70 .name = "Module's CCAN dependencies are present",
72 .check = check_depends_exist,
73 .describe = describe_depends_exist,
76 REGISTER_TEST(depends_exist, NULL);