+vector<FS::Path> Component::collect_source_files() const
+{
+ vector<FS::Path> files;
+ for(const FS::Path &p: sources)
+ {
+ if(FS::is_dir(p))
+ {
+ vector<FS::Path> dirs;
+ dirs.reserve(1+overlays.size());
+ dirs.push_back(p);
+ for(const string &o: overlays)
+ {
+ FS::Path opath = p/o;
+ if(FS::is_dir(opath))
+ dirs.push_back(opath);
+ }
+ set<string> overlay_files;
+ for(auto j=dirs.begin(); j!=dirs.end(); ++j)
+ {
+ package.get_builder().get_logger().log("files", format("Traversing %s", *j));
+ for(const string &f: list_files(*j))
+ {
+ if(j!=dirs.begin())
+ {
+ if(overlay_files.count(f))
+ continue;
+ overlay_files.insert(f);
+ }
+ FS::Path fn = *j/f;
+ if(!FS::is_dir(fn))
+ files.push_back(fn);
+ }
+ }
+ }
+ else
+ {
+ files.push_back(p);
+ for(const string &o: overlays)
+ {
+ FS::Path opath = FS::dirname(p)/o/FS::basename(p);
+ if(FS::is_reg(opath))
+ files.push_back(opath);
+ }
+ }
+ }
+
+ return files;
+}
+
+