]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/build.c
Web updates.
[ccan] / tools / ccanlint / tests / build.c
index c3b570e421271ae5917a037356323dfb5528873d..1b3d878928b53ca738fba2c13b2f2f394a508d19 100644 (file)
@@ -16,8 +16,6 @@
 
 static const char *can_build(struct manifest *m)
 {
-       if (list_empty(&m->c_files))
-               return "No C files in module";
        if (safe_mode)
                return "Safe mode enabled";
        return NULL;
@@ -28,18 +26,32 @@ static char *obj_list(const struct manifest *m)
        char *list = talloc_strdup(m, "");
        struct ccan_file *i;
 
-       /* Object from all the C files. */
+       /* Objects from all the C files. */
        list_for_each(&m->c_files, i, list)
-               list = talloc_asprintf_append(list, "%.*s.o ",
-                                             strlen(i->name) - 2, i->name);
+               list = talloc_asprintf_append(list, "%s ", i->compiled);
 
        return list;
 }
 
-/* We leave this object file around after ccanlint runs, all built. */
 static void *do_build(struct manifest *m)
 {
-       return run_command(m, "ld -r -o ../%s.o %s", m->basename, obj_list(m));
+       char *filename, *err;
+
+       if (list_empty(&m->c_files)) {
+               /* No files?  No score, but we "pass". */
+               build.total_score = 0;
+               return NULL;
+       }
+       filename = link_objects(m, obj_list(m), &err);
+       if (filename) {
+               char *realname = talloc_asprintf(m, "../%s.o", m->basename);
+               /* We leave this object file around, all built. */
+               if (rename(filename, realname) != 0)
+                       return talloc_asprintf(m, "Failed to rename %s to %s",
+                                              filename, realname);
+               return NULL;
+       }
+       return err;
 }
 
 static const char *describe_build(struct manifest *m, void *check_result)