| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #include <tools/ccanlint/ccanlint.h>
- #include <tools/tools.h>
- #include <ccan/talloc/talloc.h>
- #include <ccan/str/str.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <limits.h>
- #include <errno.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <err.h>
- #include <string.h>
- #include <ctype.h>
- #include "build.h"
- static const char *can_build(struct manifest *m)
- {
- if (safe_mode)
- return "Safe mode enabled";
- return NULL;
- }
- static bool expect_obj_file(struct manifest *m)
- {
- /* If it has C files, we expect an object file built from them. */
- return !list_empty(&m->c_files);
- }
- static char *build_subdir_objs(struct manifest *m)
- {
- struct ccan_file *i;
- list_for_each(&m->c_files, i, list) {
- char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
- char *output;
- i->compiled = maybe_temp_file(m, "", false, fullfile);
- if (!compile_object(m, fullfile, ccan_dir, "", i->compiled,
- &output)) {
- talloc_free(i->compiled);
- i->compiled = NULL;
- return talloc_asprintf(m,
- "Dependency %s"
- " did not build:\n%s",
- m->basename, output);
- }
- }
- 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) {
- 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;
- }
- }
- struct ccanlint depends_built = {
- .key = "depends-built",
- .name = "Module's CCAN dependencies can be found or built",
- .check = check_depends_built,
- .can_run = can_build,
- };
- REGISTER_TEST(depends_built, &depends_exist, NULL);
|