]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/objects_build.c
ccanlint: Add cflags support to _info
[ccan] / tools / ccanlint / tests / objects_build.c
index b86c53beeff096a2c27f1b7be76e10ff2ea8f890..5e6daf7827a1c5104d5e9dd81c49f671e834ea5f 100644 (file)
@@ -1,6 +1,7 @@
 #include <tools/ccanlint/ccanlint.h>
 #include <tools/tools.h>
 #include <ccan/str/str.h>
+#include <ccan/tal/path/path.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -21,6 +22,17 @@ static const char *can_build(struct manifest *m)
        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)
@@ -35,7 +47,7 @@ void build_objects(struct manifest *m,
 
        list_for_each(&m->c_files, i, list) {
                char *output;
-               char *fullfile = tal_fmt(m, "%s/%s", m->dir, i->name);
+               char *fullfile = path_join(m, m->dir, i->name);
 
                i->compiled[ctype] = temp_file(m, "", fullfile);
                if (!compile_object(score, fullfile, ccan_dir, compiler, flags,
@@ -57,13 +69,17 @@ void build_objects(struct manifest *m,
        if (!errors) {
                score->pass = true;
                score->score = score->total - warnings;
-       }
+       } else
+               build_failed = true;
 }
 
 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 = {