Skip to content

Enable nested vsprops #2216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions modules/vstudio/tests/cs2005/test_additional_props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@
end


--
-- Check handling of nested AdditionalProps.
-- Elements are nested properly.
--

function suite.propsAreNested()
vsprops {
RandomKey = {
RandomNestedKey = "NestedValue"
}
}
prepare()
test.capture [[
<RandomKey>
<RandomNestedKey>NestedValue</RandomNestedKey>
</RandomKey>
]]
end


--
-- Check handling of AdditionialProps.
-- Element groups set multiple times are placed in the order in which they are set.
Expand Down Expand Up @@ -80,5 +100,3 @@
<ValueRequiringEscape>if (age &gt; 3 &amp;&amp; age &lt; 8)</ValueRequiringEscape>
]]
end


38 changes: 38 additions & 0 deletions modules/vstudio/tests/vc2010/test_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,44 @@ end
end


function suite.additionalPropsNested()
p.action.set("vs2022")
filter "Debug"
vsprops {
Key3 = {
NestedKey = "NestedValue"
}
}
filter "Release"
vsprops {
Key1 = "Value1",
Key2 = {
NestedKey = "NestedValue"
}
}
filter {}
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
<Key3>
<NestedKey>NestedValue</NestedKey>
</Key3>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Globals">
<Key1>Value1</Key1>
<Key2>
<NestedKey>NestedValue</NestedKey>
</Key2>
</PropertyGroup>
]]
end

function suite.disableFastUpToDateCheck()
fastuptodate "Off"
prepare()
Expand Down
16 changes: 13 additions & 3 deletions modules/vstudio/vs2005_dotnetbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,23 @@
--

function dotnetbase.additionalProps(cfg)
for i = 1, #cfg.vsprops do
for key, value in spairs(cfg.vsprops[i]) do
_p(2, '<%s>%s</%s>', key, vs2005.esc(value), key)
local function recurseTableIfNeeded(tbl, tab_level)
for key, value in spairs(tbl) do
if (type(value) == "table") then
_p(tab_level, '<%s>', key)
recurseTableIfNeeded(value, tab_level + 1)
_p(tab_level, '</%s>', key)
else
_p(tab_level, '<%s>%s</%s>', key, vs2005.esc(value), key)
end
end
end
for i = 1, #cfg.vsprops do
recurseTableIfNeeded(cfg.vsprops[i], 2)
end
end


--
-- Write the compiler flags for a particular configuration.
--
Expand Down
25 changes: 17 additions & 8 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@
if #includes > 0 then
m.element("ForcedIncludeFiles", condition, table.concat(includes, ';'))
end
end
end
end

function m.forceUsings(cfg, condition)
Expand Down Expand Up @@ -2793,7 +2793,7 @@
if llvmdir and _ACTION >= "vs2019" then
m.element("LLVMInstallDir", nil, vstudio.path(cfg, llvmdir))
end

if llvmversion and _ACTION >= "vs2019" then
m.element("LLVMToolsVersion", nil, llvmversion)
end
Expand Down Expand Up @@ -3128,11 +3128,20 @@


function m.additionalProps(prj, cfg)
for i = 1, #cfg.vsprops do
for key, value in spairs(cfg.vsprops[i]) do
m.element(key, nil, vs2010.esc(value))
local function recurseTableIfNeeded(tbl)
for key, value in spairs(tbl) do
if (type(value) == "table") then
p.push("<" .. key .. ">")
recurseTableIfNeeded(value)
p.pop("</" .. key .. ">")
else
m.element(key, nil, vs2010.esc(value))
end
end
end
for i = 1, #cfg.vsprops do
recurseTableIfNeeded(cfg.vsprops[i])
end
end


Expand Down Expand Up @@ -3481,7 +3490,7 @@

function m.linuxDebugInformationFormat(cfg)
if cfg.symbols then

if cfg.symbols == p.OFF then
m.element("DebugInformationFormat", nil, "None")
elseif cfg.symbols == "Full" then
Expand Down Expand Up @@ -3524,7 +3533,7 @@
["gnu++17"] = "gnu++17",
["gnu++20"] = "gnu++20",
}

if cpp_langmap[cfg.cppdialect] ~= nil then
m.element("CppLanguageStandard", nil, cpp_langmap[cfg.cppdialect])
end
Expand Down Expand Up @@ -3587,7 +3596,7 @@
["wsl"] = "WSL_1_0",
["wsl2"] = "WSL2_1_0",
}

local clang_map = {
["remote"] = "Remote_Clang_1_0",
["wsl"] = "WSL_Clang_1_0",
Expand Down
11 changes: 11 additions & 0 deletions website/docs/vsprops.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ If you want to output groups of values in any order, set multiple times.
}
```

Nested values are also supported.

```lua
vsprops {
Name1 = "value1",
Name2 = {
Name3 = "value3"
}
}
```

### Parameters ###

Name and value are strings
Expand Down
Loading