From 891a1dbcd60878aa7ca07a9276f9d299cbdc9a9e Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Tue, 18 Sep 2012 11:24:18 -0400 Subject: [PATCH] Fixed handling of exact path matches in vpath building --- src/project/project.lua | 15 +++++++++------ tests/project/test_vpaths.lua | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/project/project.lua b/src/project/project.lua index 0eed9329..7ccd52f8 100755 --- a/src/project/project.lua +++ b/src/project/project.lua @@ -438,7 +438,7 @@ node.realpath = node.path end end) - + -- Store full file configuration in file (leaf) nodes for key, value in pairs(fcfg) do node[key] = value @@ -469,11 +469,15 @@ -- does the filename match this vpath pattern? local i = filename:find(path.wildcards(pattern)) - if i == 1 then - - -- yes; trim the leading portion of the path + if i == 1 then + -- yes; trim the pattern out of the target file's path + local leaf i = pattern:find("*", 1, true) or (pattern:len() + 1) - local leaf = filename:sub(i) + if i < filename:len() then + leaf = filename:sub(i) + else + leaf = path.getname(filename) + end if leaf:startswith("/") then leaf = leaf:sub(2) end @@ -491,7 +495,6 @@ end vpath = path.join(stem, leaf) - end end end diff --git a/tests/project/test_vpaths.lua b/tests/project/test_vpaths.lua index 4993d9d4..f076ba44 100644 --- a/tests/project/test_vpaths.lua +++ b/tests/project/test_vpaths.lua @@ -65,6 +65,13 @@ test.isequal("sources/hello.c", project.getvpath(prj, cfg.files[1])) end + function suite.ExactFilenameMatch() + files { "src/hello.c" } + vpaths { ["sources"] = "src/hello.c" } + prepare() + test.isequal("sources/hello.c", project.getvpath(prj, cfg.files[1])) + end + -- -- Test wildcard patterns