Skip to content

Commit c59cdd8

Browse files
committed
Enable nested vsprops
1 parent d842e67 commit c59cdd8

File tree

5 files changed

+99
-13
lines changed

5 files changed

+99
-13
lines changed

modules/vstudio/tests/cs2005/test_additional_props.lua

+20-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@
4747
end
4848

4949

50+
--
51+
-- Check handling of nested AdditionalProps.
52+
-- Elements are nested properly.
53+
--
54+
55+
function suite.propsAreNested()
56+
vsprops {
57+
RandomKey = {
58+
RandomNestedKey = "NestedValue"
59+
}
60+
}
61+
prepare()
62+
test.capture [[
63+
<RandomKey>
64+
<RandomNestedKey>NestedValue</RandomNestedKey>
65+
</RandomKey>
66+
]]
67+
end
68+
69+
5070
--
5171
-- Check handling of AdditionialProps.
5272
-- Element groups set multiple times are placed in the order in which they are set.
@@ -80,5 +100,3 @@
80100
<ValueRequiringEscape>if (age &gt; 3 &amp;&amp; age &lt; 8)</ValueRequiringEscape>
81101
]]
82102
end
83-
84-

modules/vstudio/tests/vc2010/test_globals.lua

+38
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,44 @@ end
540540
end
541541

542542

543+
function suite.additionalPropsNested()
544+
p.action.set("vs2022")
545+
filter "Debug"
546+
vsprops {
547+
Key3 = {
548+
NestedKey = "NestedValue"
549+
}
550+
}
551+
filter "Release"
552+
vsprops {
553+
Key1 = "Value1",
554+
Key2 = {
555+
NestedKey = "NestedValue"
556+
}
557+
}
558+
filter {}
559+
prepare()
560+
test.capture [[
561+
<PropertyGroup Label="Globals">
562+
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
563+
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
564+
<Keyword>Win32Proj</Keyword>
565+
<RootNamespace>MyProject</RootNamespace>
566+
</PropertyGroup>
567+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
568+
<Key3>
569+
<NestedKey>NestedValue</NestedKey>
570+
</Key3>
571+
</PropertyGroup>
572+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Globals">
573+
<Key1>Value1</Key1>
574+
<Key2>
575+
<NestedKey>NestedValue</NestedKey>
576+
</Key2>
577+
</PropertyGroup>
578+
]]
579+
end
580+
543581
function suite.disableFastUpToDateCheck()
544582
fastuptodate "Off"
545583
prepare()

modules/vstudio/vs2005_dotnetbase.lua

+13-3
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,23 @@
247247
--
248248

249249
function dotnetbase.additionalProps(cfg)
250-
for i = 1, #cfg.vsprops do
251-
for key, value in spairs(cfg.vsprops[i]) do
252-
_p(2, '<%s>%s</%s>', key, vs2005.esc(value), key)
250+
local function recurseTableIfNeeded(tbl, i)
251+
for key, value in spairs(tbl) do
252+
if (type(value) == "table") then
253+
_p(i, '<%s>', key)
254+
recurseTableIfNeeded(value, i + 1)
255+
_p(i, '</%s>', key)
256+
else
257+
_p(i, '<%s>%s</%s>', key, vs2005.esc(value), key)
258+
end
253259
end
254260
end
261+
for i = 1, #cfg.vsprops do
262+
recurseTableIfNeeded(cfg.vsprops[i], 2)
263+
end
255264
end
256265

266+
257267
--
258268
-- Write the compiler flags for a particular configuration.
259269
--

modules/vstudio/vs2010_vcxproj.lua

+17-8
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,7 @@
22012201
if #includes > 0 then
22022202
m.element("ForcedIncludeFiles", condition, table.concat(includes, ';'))
22032203
end
2204-
end
2204+
end
22052205
end
22062206

22072207
function m.forceUsings(cfg, condition)
@@ -2793,7 +2793,7 @@
27932793
if llvmdir and _ACTION >= "vs2019" then
27942794
m.element("LLVMInstallDir", nil, vstudio.path(cfg, llvmdir))
27952795
end
2796-
2796+
27972797
if llvmversion and _ACTION >= "vs2019" then
27982798
m.element("LLVMToolsVersion", nil, llvmversion)
27992799
end
@@ -3128,11 +3128,20 @@
31283128

31293129

31303130
function m.additionalProps(prj, cfg)
3131-
for i = 1, #cfg.vsprops do
3132-
for key, value in spairs(cfg.vsprops[i]) do
3133-
m.element(key, nil, vs2010.esc(value))
3131+
local function recurseTableIfNeeded(tbl)
3132+
for key, value in spairs(tbl) do
3133+
if (type(value) == "table") then
3134+
p.push("<" .. key .. ">")
3135+
recurseTableIfNeeded(value)
3136+
p.pop("</" .. key .. ">")
3137+
else
3138+
m.element(key, nil, vs2010.esc(value))
3139+
end
31343140
end
31353141
end
3142+
for i = 1, #cfg.vsprops do
3143+
recurseTableIfNeeded(cfg.vsprops[i])
3144+
end
31363145
end
31373146

31383147

@@ -3481,7 +3490,7 @@
34813490

34823491
function m.linuxDebugInformationFormat(cfg)
34833492
if cfg.symbols then
3484-
3493+
34853494
if cfg.symbols == p.OFF then
34863495
m.element("DebugInformationFormat", nil, "None")
34873496
elseif cfg.symbols == "Full" then
@@ -3524,7 +3533,7 @@
35243533
["gnu++17"] = "gnu++17",
35253534
["gnu++20"] = "gnu++20",
35263535
}
3527-
3536+
35283537
if cpp_langmap[cfg.cppdialect] ~= nil then
35293538
m.element("CppLanguageStandard", nil, cpp_langmap[cfg.cppdialect])
35303539
end
@@ -3587,7 +3596,7 @@
35873596
["wsl"] = "WSL_1_0",
35883597
["wsl2"] = "WSL2_1_0",
35893598
}
3590-
3599+
35913600
local clang_map = {
35923601
["remote"] = "Remote_Clang_1_0",
35933602
["wsl"] = "WSL_Clang_1_0",

website/docs/vsprops.md

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ If you want to output groups of values in any order, set multiple times.
1414
}
1515
```
1616

17+
Nested values are also supported.
18+
19+
```lua
20+
vsprops {
21+
Name1 = "value1",
22+
Name2 = {
23+
Name3 = "value3"
24+
}
25+
}
26+
```
27+
1728
### Parameters ###
1829

1930
Name and value are strings

0 commit comments

Comments
 (0)