]> git.ozlabs.org Git - ccan/blobdiff - tools/manifest.c
tools: don't include submodules in manifest.
[ccan] / tools / manifest.c
index fe3e4680b2d49117338def1e27bfc3b2ff58607e..6e246d8bf71de42a37f01ae4779102f57dd8d8ea 100644 (file)
@@ -3,6 +3,7 @@
 #include "tools.h"
 #include <ccan/str/str.h>
 #include <ccan/tal/link/link.h>
+#include <ccan/tal/grab_file/grab_file.h>
 #include <ccan/tal/path/path.h>
 #include <ccan/hash/hash.h>
 #include <ccan/htable/htable_type.h>
@@ -43,10 +44,10 @@ static struct htable_manifest *manifests;
 const char *get_ccan_file_contents(struct ccan_file *f)
 {
        if (!f->contents) {
-               f->contents = tal_grab_file(f, f->fullname,
-                                              &f->contents_size);
+               f->contents = grab_file(f, f->fullname);
                if (!f->contents)
                        err(1, "Reading file %s", f->fullname);
+               f->contents_size = tal_count(f->contents) - 1;
        }
        return f->contents;
 }
@@ -168,8 +169,15 @@ static void add_files(struct manifest *m, const char *base, const char *subdir)
                    && list_empty(&m->h_files))
                        errx(1, "No _info, C or H files found here!");
 
-               for (i = 0; i < tal_count(subs); i++)
-                       add_files(m, base, subs[i]);
+               /* Don't enter subdirs with _info: they're separate modules. */
+               for (i = 0; i < tal_count(subs); i++) {
+                       struct stat st;
+                       char *subinfo = path_join(subs, base,
+                                                 path_join(subs, subs[i],
+                                                           "_info"));
+                       if (lstat(subinfo, &st) != 0)
+                               add_files(m, base, subs[i]);
+               }
        }
        tal_free(subs);
 }