Fixed #3381011: location breaks vpaths
This commit is contained in:
parent
f1795693ba
commit
8f6fd68f7a
@ -381,7 +381,7 @@
|
||||
|
||||
vpaths =
|
||||
{
|
||||
kind = "keyvalue",
|
||||
kind = "keypath",
|
||||
scope = "container",
|
||||
},
|
||||
|
||||
@ -622,7 +622,7 @@
|
||||
return premake.setdirarray(scope, name, value)
|
||||
elseif kind == "filelist" then
|
||||
return premake.setfilearray(scope, name, value)
|
||||
elseif kind == "keyvalue" then
|
||||
elseif kind == "keyvalue" or kind == "keypath" then
|
||||
return premake.setkeyvalue(scope, name, value)
|
||||
end
|
||||
end
|
||||
|
@ -116,14 +116,22 @@
|
||||
--
|
||||
|
||||
local function adjustpaths(location, obj)
|
||||
function adjustpathlist(list)
|
||||
for i, p in ipairs(list) do
|
||||
list[i] = path.getrelative(location, p)
|
||||
end
|
||||
end
|
||||
|
||||
for name, value in pairs(obj) do
|
||||
local field = premake.fields[name]
|
||||
if field and value and not keeprelative[name] then
|
||||
if field.kind == "path" then
|
||||
obj[name] = path.getrelative(location, value)
|
||||
elseif field.kind == "dirlist" or field.kind == "filelist" then
|
||||
for i, p in ipairs(value) do
|
||||
value[i] = path.getrelative(location, p)
|
||||
adjustpathlist(value)
|
||||
elseif field.kind == "keypath" then
|
||||
for k,v in pairs(value) do
|
||||
adjustpathlist(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -144,7 +152,7 @@
|
||||
|
||||
local function mergefield(kind, dest, src)
|
||||
local tbl = dest or { }
|
||||
if kind == "keyvalue" then
|
||||
if kind == "keyvalue" or kind == "keypath" then
|
||||
for key, value in pairs(src) do
|
||||
tbl[key] = mergefield("list", tbl[key], value)
|
||||
end
|
||||
|
@ -124,3 +124,32 @@
|
||||
prepare()
|
||||
test.isequal("src/hello.c", project.getvpath(prj, "../../src/hello.c"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test with project locations
|
||||
--
|
||||
|
||||
function suite.MatchPath_OnProjectLocationSet()
|
||||
location "build"
|
||||
files "src/hello.h"
|
||||
vpaths { [""] = "src" }
|
||||
prepare()
|
||||
test.isequal("hello.h", project.getvpath(prj, prj.files[1]))
|
||||
end
|
||||
|
||||
function suite.MatchFilePattern_OnProjectLocationSet()
|
||||
location "build"
|
||||
files "src/hello.h"
|
||||
vpaths { ["Headers"] = "**.h" }
|
||||
prepare()
|
||||
test.isequal("Headers/hello.h", project.getvpath(prj, prj.files[1]))
|
||||
end
|
||||
|
||||
function suite.MatchFilePatternWithPath_OnProjectLocationSet()
|
||||
location "build"
|
||||
files "src/hello.h"
|
||||
vpaths { ["Headers"] = "src/**.h" }
|
||||
prepare()
|
||||
test.isequal("Headers/hello.h", project.getvpath(prj, prj.files[1]))
|
||||
end
|
||||
|
Reference in New Issue
Block a user