diff --git a/src/project/project.lua b/src/project/project.lua index da4c13bc..28c060cc 100755 --- a/src/project/project.lua +++ b/src/project/project.lua @@ -79,9 +79,28 @@ -- function project.eachfile(prj) - local cfg = project.getconfig(prj, nil, nil, "files") - local files = cfg.files + -- make sure I have the project, and not it's root configuration + prj = prj.project or prj + + -- find *all* files referenced by the project, regardless of configuration, + -- and cache the list for future calls + if not prj.files then + local files = {} + for _, block in ipairs(prj.blocks) do + for _, file in ipairs(block.files) do + if not files[file] then + -- add it both indexed for iteration and keyed for quick tests + table.insert(files, file) + files[file] = file + end + end + end + prj.files = files + end + + local files = prj.files local i = 0 + return function() i = i + 1 if i <= #files then diff --git a/tests/project/test_eachfile.lua b/tests/project/test_eachfile.lua index bbb67b89..a30a17a2 100644 --- a/tests/project/test_eachfile.lua +++ b/tests/project/test_eachfile.lua @@ -67,3 +67,18 @@ hello.c ]] end + +-- +-- A file listed in a configuration should be included in the list. +-- + + function suite.includesFile_setInConfiguration() + files { "hello.h" } + configuration { "Debug" } + files { "hello.c" } + prepare() + test.capture [[ + hello.h + hello.c + ]] + end