Commits

Jason Perkins committed 5836b56

Fixed handling of exact path matches in vpath building

  • Participants
  • Parent commits fc98f94

Comments (0)

Files changed (2)

src/project/project.lua

 					node.realpath = node.path
 				end
 			end)
-
+			
 			-- Store full file configuration in file (leaf) nodes
 			for key, value in pairs(fcfg) do
 				node[key] = value
 
 				-- 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
 					end
 					
 					vpath = path.join(stem, leaf)
-
 				end
 			end
 		end

tests/project/test_vpaths.lua

 		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