X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fbuild.c;fp=tools%2Fccanlint%2Ftests%2Fbuild.c;h=1b3d878928b53ca738fba2c13b2f2f394a508d19;hb=687cde2a8c561b68f17609b615eb930ea02f5aac;hp=0a5e11e66fbca66281c138c9de084a6ea592525b;hpb=5b7e9d904afa72961340c225de39daab29ff7d0e;p=ccan diff --git a/tools/ccanlint/tests/build.c b/tools/ccanlint/tests/build.c index 0a5e11e6..1b3d8789 100644 --- a/tools/ccanlint/tests/build.c +++ b/tools/ccanlint/tests/build.c @@ -26,23 +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) { + char *filename, *err; + if (list_empty(&m->c_files)) { /* No files? No score, but we "pass". */ build.total_score = 0; return NULL; } - return run_command(m, "ld -r -o ../%s.o %s", m->basename, obj_list(m)); + 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)