X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Fcheck_depends_built.c;h=c4c649dd9e2fe44d168c656fe54349dc360c7922;hp=3bd82f830971ff4ec7eefcde5b4bb342d31b1390;hb=016a19d260cd7f4afeb5b2b2cc28c8bbed1cd170;hpb=51a56b52627e635566253a3fae081c3f466b6bb6 diff --git a/tools/ccanlint/compulsory_tests/check_depends_built.c b/tools/ccanlint/compulsory_tests/check_depends_built.c index 3bd82f83..c4c649dd 100644 --- a/tools/ccanlint/compulsory_tests/check_depends_built.c +++ b/tools/ccanlint/compulsory_tests/check_depends_built.c @@ -50,48 +50,62 @@ static char *build_subdir_objs(struct manifest *m) return NULL; } +char *build_submodule(struct manifest *m) +{ + char *errstr; + struct stat st; + + if (m->compiled) + return NULL; + + if (!expect_obj_file(m)) + return NULL; + + m->compiled = talloc_asprintf(m, "%s.o", m->dir); + if (stat(m->compiled, &st) == 0) + return NULL; + + if (verbose >= 2) + printf(" Building dependency %s\n", m->dir); + + errstr = build_subdir_objs(m); + if (errstr) + return errstr; + + m->compiled = build_module(m, false, &errstr); + if (!m->compiled) + return errstr; + return NULL; +} + static void check_depends_built(struct manifest *m, bool keep, unsigned int *timeleft, struct score *score) { struct manifest *i; - struct stat st; list_for_each(&m->deps, i, list) { - char *errstr; - if (!expect_obj_file(i)) - continue; - - i->compiled = talloc_asprintf(i, "%s.o", i->dir); - if (stat(i->compiled, &st) == 0) - continue; - - if (verbose >= 2) - printf(" Building dependency %s\n", i->dir); - score->error = build_subdir_objs(i); - if (score->error) - return; - i->compiled = build_module(i, keep, &errstr); - if (!i->compiled) { + char *errstr = build_submodule(i); + + if (errstr) { score->error = talloc_asprintf(score, "Dependency %s" " did not build:\n%s", i->basename, errstr); return; - } + } } - if (!score->error) { - score->pass = true; - score->score = score->total; - } + score->pass = true; + score->score = score->total; } struct ccanlint depends_built = { - .key = "depends-built", + .key = "depends_build", .name = "Module's CCAN dependencies can be found or built", .check = check_depends_built, .can_run = can_build, + .needs = "depends_exist" }; -REGISTER_TEST(depends_built, &depends_exist, NULL); +REGISTER_TEST(depends_built);