]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/compulsory_tests/build_objs.c
ccanlint: rename test keys
[ccan] / tools / ccanlint / compulsory_tests / build_objs.c
index 2f189e859f25a8b523505609cafd31c429e3a443..9393f62f11eb4507dc3ca76330e279a03fb136c8 100644 (file)
@@ -21,37 +21,46 @@ static const char *can_build(struct manifest *m)
        return NULL;
 }
 
-static void *check_objs_build(struct manifest *m)
+static void check_objs_build(struct manifest *m,
+                            bool keep,
+                            unsigned int *timeleft, struct score *score)
 {
-       char *report = NULL;
        struct ccan_file *i;
+       bool errors = false, warnings = false;
 
-       list_for_each(&m->c_files, i, list) {
-               char *err;
+       if (list_empty(&m->c_files))
+               score->total = 0;
+       else
+               score->total = 2;
 
-               /* One point for each obj file. */
-               build_objs.total_score++;
+       list_for_each(&m->c_files, i, list) {
+               char *output;
+               char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
 
-               i->compiled = compile_object(m, i->name, &err);
-               if (!i->compiled) {
-                       if (report)
-                               report = talloc_append_string(report, err);
-                       else
-                               report = err;
+               i->compiled = maybe_temp_file(m, "", keep, fullfile);
+               if (!compile_object(score, fullfile, ccan_dir, "", i->compiled,
+                                   &output)) {
+                       talloc_free(i->compiled);
+                       score->error = "Compiling object files";
+                       score_file_error(score, i, 0, output);
+                       errors = true;
+               } else if (!streq(output, "")) {
+                       score->error = "Compiling object files gave warnings";
+                       score_file_error(score, i, 0, output);
+                       warnings = true;
                }
        }
-       return report;
-}
 
-static const char *describe_objs_build(struct manifest *m, void *check_result)
-{
-       return check_result;
+       if (!errors) {
+               score->pass = true;
+               score->score = score->total - warnings;
+       }
 }
 
 struct ccanlint build_objs = {
+       .key = "objects_build",
        .name = "Module object files can be built",
        .check = check_objs_build,
-       .describe = describe_objs_build,
        .can_run = can_build,
 };