Translate rule var paths for Visual Studio projects and make relative to project

This commit is contained in:
Jason Perkins 2015-05-08 16:30:47 -04:00
parent 120bf0ad73
commit 15fd9fd43b
2 changed files with 44 additions and 26 deletions

View File

@ -516,7 +516,11 @@
local fld = p.rule.getPropertyField(rule, prop)
local value = cfg[fld.name]
if value ~= nil then
value = p.rule.getPropertyString(rule, prop, value)
if fld.kind == "path" then
value = path.translate(project.getrelative(cfg.project, value))
else
value = p.rule.getPropertyString(rule, prop, value)
end
if value ~= nil and #value > 0 then
m.element(prop.name, nil, '%s', value)
end

View File

@ -1,7 +1,8 @@
--
-- tests/actions/vstudio/vc2010/test_rule_vars.lua
-- Validate generation of custom rule variables at the project level.
-- Copyright (c) 2014 Jason Perkins and the Premake project
-- Author Jason Perkins
-- Copyright (c) 2014-2015 Jason Perkins and the Premake project
--
local suite = test.declare("vstudio_vs2010_rule_vars")
@ -49,18 +50,6 @@
-- Test setting the various property kinds.
--
function suite.onStringVar()
createVar { name="MyVar", kind="string" }
myRuleVars { MyVar = "hello" }
prepare()
test.capture [[
<MyRule>
<MyVar>hello</MyVar>
</MyRule>
]]
end
function suite.onBooleanVar()
createVar { name="MyVar", kind="boolean" }
myRuleVars { MyVar = false }
@ -73,18 +62,6 @@
end
function suite.onListVar()
createVar { name="MyVar", kind="list" }
myRuleVars { MyVar = { "a", "b", "c" } }
prepare()
test.capture [[
<MyRule>
<MyVar>a b c</MyVar>
</MyRule>
]]
end
function suite.onEnumVar()
createVar {
name = "MyVar",
@ -106,3 +83,40 @@
</MyRule>
]]
end
function suite.onListVar()
createVar { name="MyVar", kind="list" }
myRuleVars { MyVar = { "a", "b", "c" } }
prepare()
test.capture [[
<MyRule>
<MyVar>a b c</MyVar>
</MyRule>
]]
end
function suite.onPathVar()
createVar { name="MyVar", kind="path" }
myRuleVars { MyVar = "../../path/to/file" }
prepare()
test.capture [[
<MyRule>
<MyVar>..\..\path\to\file</MyVar>
</MyRule>
]]
end
function suite.onStringVar()
createVar { name="MyVar", kind="string" }
myRuleVars { MyVar = "hello" }
prepare()
test.capture [[
<MyRule>
<MyVar>hello</MyVar>
</MyRule>
]]
end