]> git.tdb.fi Git - builder.git/commitdiff
Only get DataTransform directory contents when needed
authorMikko Rasa <tdb@tdb.fi>
Fri, 10 Oct 2014 10:25:31 +0000 (13:25 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 10 Oct 2014 13:00:12 +0000 (16:00 +0300)
source/datatransform.cpp

index 67b892ede81de5f8ce1fda4db26dfff666870a35..31aaa378b2be35529a5a8d8336e59142f41c12f3 100644 (file)
@@ -28,15 +28,23 @@ void DataTransform::find_dependencies()
        else
        {
                builder.get_logger().log("files", format("Reading imports from %s", path.str()));
-
-               list<string> dir_files = list_files(FS::dirname(path));
                IO::File in(path.str());
                DataFile::Parser parser(in, path.str());
+
+               list<string> dir_files;
                while(!in.eof())
                {
                        DataFile::Statement st = parser.parse();
                        if(st.keyword=="for_each")
                        {
+                               // There's bound to be at least one file: the transform itself
+                               if(dir_files.empty())
+                               {
+                                       FS::Path dir = FS::dirname(path);
+                                       builder.get_logger().log("files", format("Traversing %s", dir.str()));
+                                       dir_files = list_files(dir);
+                               }
+
                                for(DataFile::Statement::Arguments::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
                                {
                                        Regex re(i->get<string>());