X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_compile.c;h=cb71bf8329db7e54227b7c26af94e97cfb2b18e6;hb=9961094e2422cf0c2d9cb21387da7c65ddddafe2;hp=2479d80a70a7ff9d93dc58f9428eaefb09e80ed8;hpb=09d5cd70d7e8105a003ed9583eadb077de014f3b;p=ccan diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index 2479d80a..cb71bf83 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/tools/ccanlint/tests/examples_compile.c @@ -126,6 +126,17 @@ static char *example_lib_list(const void *ctx, struct manifest **deps) return list; } +static char *cflags_list(const struct manifest *m) +{ + unsigned int i; + char *ret = tal_strdup(m, cflags); + + char **flags = get_cflags(m, m->dir, get_or_compile_info); + for (i = 0; flags[i]; i++) + tal_append_fmt(&ret, " %s", flags[i]); + return ret; +} + /* FIXME: Test with reduced features! */ static bool compile(const void *ctx, struct manifest *m, @@ -133,11 +144,12 @@ static bool compile(const void *ctx, char **output) { struct manifest **deps = get_example_deps(m, file); + const char *flags = cflags_list(m); file->compiled[COMPILE_NORMAL] = temp_file(ctx, "", file->fullname); if (!compile_and_link(ctx, file->fullname, ccan_dir, example_obj_list(file, deps), - compiler, cflags, + compiler, flags, example_lib_list(file, deps), file->compiled[COMPILE_NORMAL], output)) { @@ -464,8 +476,8 @@ static struct ccan_file *mangle_example(struct manifest *m, name = temp_file(example, ".c", take(tal_fmt(NULL, "mangled-%s", example->name))); f = new_ccan_file(example, - path_dirname(example, name), - path_basename(example, name)); + take(path_dirname(example, name)), + take(path_basename(example, name))); tal_steal(f, name); fd = open(f->fullname, O_WRONLY | O_CREAT | O_EXCL, 0600); @@ -473,7 +485,7 @@ static struct ccan_file *mangle_example(struct manifest *m, return NULL; contents = mangle(m, lines); - if (write(fd, contents, strlen(contents)) != strlen(contents)) { + if (write(fd, contents, strlen(contents)) != (int)strlen(contents)) { close(fd); return NULL; } @@ -538,7 +550,7 @@ static unsigned int try_compiling(struct manifest *m, } static void build_examples(struct manifest *m, - unsigned int *timeleft, struct score *score) + unsigned int *timeleft UNNEEDED, struct score *score) { struct ccan_file *i; char **prev = NULL;