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,
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)) {
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;
+}
+
static char *lib_list(const struct manifest *m)
{
unsigned int i;
char *contents;
char *tmpfile, *cmdout;
int fd;
+ char *flags;
tmpfile = temp_file(m, ".c", "example.c");
err(1, "Failure writing to temporary file %s", tmpfile);
close(fd);
+ flags = cflags_list(m);
+
if (compile_and_link(score, tmpfile, ccan_dir, obj_list(m),
- compiler, cflags, lib_list(m),
+ compiler, flags, lib_list(m),
temp_file(m, "", tmpfile),
&cmdout)) {
score->pass = true;
return NULL;
}
+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;
+}
+
void build_objects(struct manifest *m,
struct score *score, const char *flags,
enum compile_type ctype)
static void check_objs_build(struct manifest *m,
unsigned int *timeleft, struct score *score)
{
- build_objects(m, score, cflags, COMPILE_NORMAL);
+ const char *flags;
+
+ flags = cflags_list(m);
+ build_objects(m, score, flags, COMPILE_NORMAL);
}
struct ccanlint objects_build = {
return ret;
}
+static char *cflags_list(const struct manifest *m, const char *iflags)
+{
+ unsigned int i;
+ char *ret = tal_strdup(m, iflags);
+
+ 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;
+}
+
static bool compile(const void *ctx,
struct manifest *m,
struct ccan_file *file,
cflags,
ctype == COMPILE_NOFEAT
? " "REDUCE_FEATURES_FLAGS : "");
+ flags = cflags_list(m, flags);
fname = temp_file(ctx, "", file->fullname);
if (!compile_and_link(ctx, file->fullname, ccan_dir,
cflags,
ctype == COMPILE_NOFEAT
? " "REDUCE_FEATURES_FLAGS : "");
+ flags = cflags_list(m, flags);
compile_and_link_async(file, time_ms, file->fullname, ccan_dir,
test_obj_list(m, link_with_module, ctype, ctype),
#endif
}
+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;
+}
+
+static char *cflags_list_append(const struct manifest *m, char *iflags)
+{
+ unsigned int i;
+
+ char **flags = get_cflags(m, m->dir, get_or_compile_info);
+ for (i = 0; flags[i]; i++)
+ tal_append_fmt(&iflags, " %s", flags[i]);
+ return iflags;
+}
+
static void cov_compile(const void *ctx,
unsigned int time_ms,
struct manifest *m,
bool link_with_module)
{
char *flags = tal_fmt(ctx, "%s %s", cflags, COVERAGE_CFLAGS);
+ flags = cflags_list_append(m, flags);
file->compiled[COMPILE_COVERAGE] = temp_file(ctx, "", file->fullname);
compile_and_link_async(file, time_ms, file->fullname, ccan_dir,
struct ccan_file *i;
struct list_head *h;
bool ok;
- char *f = tal_fmt(score, "%s %s", cflags, COVERAGE_CFLAGS);
+ char *f = cflags_list(m);
+ tal_append_fmt(&f, " %s", COVERAGE_CFLAGS);
/* For API tests, we need coverage version of module. */
if (!list_empty(&m->api_tests)) {
}
/* Can return NULL: _info may not support 'libs'. */
-static char **get_one_libs(const void *ctx, const char *dir,
+static char **get_one_prop(const void *ctx, const char *dir, const char *prop,
char *(*get_info)(const void *ctx, const char *dir))
{
char *cmd, **lines;
- cmd = tal_fmt(ctx, "%s libs", get_info(ctx, dir));
+ cmd = tal_fmt(ctx, "%s %s", get_info(ctx, dir), prop);
lines = lines_from_cmd(cmd, "%s", cmd);
/* Strip final NULL. */
if (lines)
return lines;
}
+static char **get_one_libs(const void *ctx, const char *dir,
+ char *(*get_info)(const void *ctx, const char *dir))
+{
+ return get_one_prop(ctx, dir, "libs", get_info);
+}
+
+static char **get_one_cflags(const void *ctx, const char *dir,
+ char *(*get_info)(const void *ctx, const char *dir))
+{
+ return get_one_prop(ctx, dir, "cflags", get_info);
+}
+
/* O(n^2) but n is small. */
static char **add_deps(char **deps1, char **deps2)
{
return deps1;
}
+char **get_cflags(const void *ctx, const char *dir,
+ char *(*get_info)(const void *ctx, const char *dir))
+{
+ char **flags;
+ unsigned int len;
+ flags = get_one_cflags(ctx, dir, get_info);
+ len = tal_count(flags);
+ tal_resize(&flags, len + 1);
+ flags[len] = NULL;
+ return flags;
+}
+
char **get_libs(const void *ctx, const char *dir, const char *style,
char *(*get_info)(const void *ctx, const char *dir))
{
char **get_libs(const void *ctx, const char *dir, const char *style,
char *(*get_info)(const void *ctx, const char *dir));
+char **get_cflags(const void *ctx, const char *dir,
+ char *(*get_info)(const void *ctx, const char *dir));
+
/* From tools.c */
/* If set, print all commands run, all output they give and exit status. */
extern bool tools_verbose;