]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/compulsory_tests/check_build.c
ccanlint: use familiar names for temporary files, show them with -vv.
[ccan] / tools / ccanlint / compulsory_tests / check_build.c
index a0b596693c492824cade2404ba0f0ed1b6693249..42eda13ae56aede90e2fd9df85927e9a1260129c 100644 (file)
@@ -27,9 +27,10 @@ static char *obj_list(const struct manifest *m)
        struct ccan_file *i;
 
        /* Other CCAN deps. */
-       list_for_each(&m->dep_objs, i, list)
-               list = talloc_asprintf_append(list, "%s ", i->name);
-
+       list_for_each(&m->dep_dirs, i, list) {
+               if (i->compiled)
+                       list = talloc_asprintf_append(list, "%s ", i->compiled);
+       }
        return list;
 }
 
@@ -44,13 +45,16 @@ static char *lib_list(const struct manifest *m)
        return ret;
 }
 
-static void *check_use_build(struct manifest *m)
+static void *check_use_build(struct manifest *m,
+                            bool keep,
+                            unsigned int *timeleft)
 {
        char *contents;
-       char *tmpfile, *err;
+       char *tmpfile;
+       char *basename = talloc_asprintf(m, "%s/example.c", m->dir);
        int fd;
 
-       tmpfile = temp_file(m, ".c");
+       tmpfile = maybe_temp_file(m, ".c", keep, basename);
 
        fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
        if (fd < 0)
@@ -70,10 +74,9 @@ static void *check_use_build(struct manifest *m)
        }
        close(fd);
 
-       if (!compile_and_link(m, tmpfile, ccan_dir, obj_list(m), "",
-                             lib_list(m), &err))
-               return err;
-       return NULL;
+       return compile_and_link(m, tmpfile, ccan_dir, obj_list(m), "",
+                               lib_list(m),
+                               maybe_temp_file(m, "", keep, tmpfile));
 }
 
 static const char *describe_use_build(struct manifest *m, void *check_result)
@@ -84,8 +87,8 @@ static const char *describe_use_build(struct manifest *m, void *check_result)
 }
 
 struct ccanlint check_build = {
-       .key = "check-build",
-       .name = "Module can be used",
+       .key = "check-link",
+       .name = "Module can be linked against trivial program",
        .total_score = 1,
        .check = check_use_build,
        .describe = describe_use_build,