diff options
author | Jason Perkins <starkos@industriousone.com> | 2012-09-18 19:28:36 +0400 |
---|---|---|
committer | Jason Perkins <starkos@industriousone.com> | 2012-09-18 19:28:36 +0400 |
commit | 4e8d01487d3bb90a66098d03ab5d0e8a4b29af3f (patch) | |
tree | 3d22510464d89b13dc246eda3e61de0ff2f6db26 | |
parent | a4e68c68cf6b2364846937ac93e30ade58878a3e (diff) |
Fixed handling of exact path matches in vpath building
-rw-r--r-- | src/base/project.lua | 9 | ||||
-rw-r--r-- | tests/project/test_vpaths.lua | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/base/project.lua b/src/base/project.lua index 2fcb0fa..ecf6800 100644 --- a/src/base/project.lua +++ b/src/base/project.lua @@ -552,9 +552,14 @@ -- does the filename match this vpath pattern? local i = vpath:find(path.wildcards(pattern)) if i == 1 then - -- yes; trim the leading portion of the path + -- yes; trim the pattern out of the target file's path + local leaf i = pattern:find("*", 1, true) or (pattern:len() + 1) - local leaf = vpath: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 diff --git a/tests/project/test_vpaths.lua b/tests/project/test_vpaths.lua index 8616907..9a099ee 100644 --- a/tests/project/test_vpaths.lua +++ b/tests/project/test_vpaths.lua @@ -57,6 +57,13 @@ test.isequal("sources/hello.c", project.getvpath(prj, "src/myproject/hello.c")) end + function suite.ExactFilenameMatch() + files { "src/hello.c" } + vpaths { ["sources"] = "src/hello.c" } + prepare() + test.isequal("sources/hello.c", project.getvpath(prj, "src/hello.c")) + end + -- -- Test wildcard patterns |