X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Frun_tests.c;h=105a3e4b10b688c8466174414101b0ee1996aaaf;hb=c4b2c672dcb8da1c16d0e2ec918a944cf82f0553;hp=eab42add8dfb06a6cf623181d37a30a7b3811298;hpb=41069549813a04a2875063cb12e8057f5d54d7f1;p=ccan diff --git a/tools/run_tests.c b/tools/run_tests.c index eab42add..105a3e4b 100644 --- a/tools/run_tests.c +++ b/tools/run_tests.c @@ -4,9 +4,11 @@ #include #include #include +#include +#include #include "ccan/tap/tap.h" #include "ccan/talloc/talloc.h" -#include "ccan/string/string.h" +#include "ccan/str/str.h" #include "tools.h" /* FIXME: Use build bug later. */ @@ -106,12 +108,20 @@ static int build(const char *dir, const char *name, int fail) char *externals = talloc_strdup(name, ""); char **deps; - for (deps = get_deps(objs, dir); *deps; deps++) { + for (deps = get_deps(talloc_autofree_context(), dir, true); *deps; deps++) { + char *newobj; + struct stat st; + if (!strstarts(*deps, "ccan/")) continue; /* ccan/foo -> ccan/foo.o */ - externals = talloc_asprintf_append(externals, " %s.o", *deps); + newobj = talloc_asprintf(name, "%s.o", *deps); + + /* Only if it exists. Makefile sorts this out. */ + if (stat(newobj, &st) == 0 || errno != ENOENT) + externals = talloc_asprintf_append(externals, + " %s", newobj); } cmd = talloc_asprintf(name, "gcc " CFLAGS " %s -o %s %s %s%s%s",