Skip to content

Commit 12087d6

Browse files
committed
Fixes filters using an aliased value
1 parent 950cafb commit 12087d6

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed

modules/vstudio/tests/_tests.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ return {
9696
"vc2010/test_rule_xml.lua",
9797
"vc2010/test_tokens.lua",
9898
"vc2010/test_target_machine.lua",
99+
"vc2010/test_target_name.lua",
99100
"vc2010/test_user_file.lua",
100101
"vc2010/test_vectorextensions.lua",
101102
"vc2010/test_ensure_nuget_imports.lua",
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
--
2+
-- test_target_name.lua
3+
-- Test target names.
4+
-- Author: Nick Clark
5+
-- Copyright (c) 2026 Jess Perkins and the Premake project
6+
--
7+
8+
local p = premake
9+
local suite = test.declare("vstudio_vs2010_target_name")
10+
local vc2010 = p.vstudio.vc2010
11+
12+
--
13+
-- Setup
14+
--
15+
16+
local wks, prj
17+
18+
function suite.setup()
19+
p.action.set("vs2010")
20+
wks, prj = test.createWorkspace()
21+
end
22+
23+
local function prepare(platform)
24+
local cfg = test.getconfig(prj, "Debug", platform)
25+
vc2010.targetName(cfg)
26+
end
27+
28+
29+
--
30+
-- Default target name is the project name
31+
--
32+
33+
function suite.defaultTargetName()
34+
prepare()
35+
test.capture [[
36+
<TargetName>MyProject</TargetName>
37+
]]
38+
end
39+
40+
41+
function suite.targetWithSuffix()
42+
targetsuffix "_suffix"
43+
44+
prepare()
45+
test.capture [[
46+
<TargetName>MyProject_suffix</TargetName>
47+
]]
48+
end
49+
50+
51+
--
52+
-- Target name with targetsuffix with AARCH architecture
53+
--
54+
55+
function suite.targetWithAarch64FilterSuffix()
56+
architecture "AARCH64"
57+
58+
filter { "architecture:AARCH64" } -- Fails if it is set to ARM64
59+
targetsuffix "_ARM64"
60+
61+
prepare()
62+
test.capture [[
63+
<TargetName>MyProject_ARM64</TargetName>
64+
]]
65+
end
66+
67+
68+
--
69+
-- Target name with targetsuffix with ARM64 architecture
70+
--
71+
72+
function suite.targetWithArm64FilterSuffix()
73+
architecture "ARM64"
74+
75+
filter { "architecture:ARM64" } -- Should match when architecture is AARCH64
76+
targetsuffix "_ARM64"
77+
78+
prepare()
79+
test.capture [[
80+
<TargetName>MyProject_ARM64</TargetName>
81+
]]
82+
end
83+
84+
85+
--
86+
-- Target name with targetsuffix and x64 architecture
87+
--
88+
89+
function suite.targetWithX64FilterSuffix()
90+
architecture "x64"
91+
92+
filter { "architecture:x64" }
93+
targetsuffix "_x64"
94+
95+
prepare()
96+
test.capture [[
97+
<TargetName>MyProject_x64</TargetName>
98+
]]
99+
end
100+
101+
102+
--
103+
-- Target name with targetprefix
104+
--
105+
106+
function suite.targetWithPrefix()
107+
targetprefix "lib"
108+
109+
prepare()
110+
test.capture [[
111+
<TargetName>libMyProject</TargetName>
112+
]]
113+
end
114+
115+
116+
--
117+
-- Target name with targetprefix and targetsuffix
118+
--
119+
120+
function suite.targetWithPrefixAndSuffix()
121+
targetprefix "lib"
122+
targetsuffix "_suffix"
123+
124+
prepare()
125+
test.capture [[
126+
<TargetName>libMyProject_suffix</TargetName>
127+
]]
128+
end

src/base/context.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,19 @@
100100
if type(value) == "table" then
101101
for i = 1, #value do
102102
value[i] = tostring(value[i]):lower()
103+
104+
local field = p.field.get(key)
105+
if field and field.aliases then
106+
value[i] = field.aliases[value[i]] or value[i]
107+
end
103108
end
104109
elseif value ~= nil then
105110
value = tostring(value):lower()
111+
112+
local field = p.field.get(key)
113+
if field and field.aliases then
114+
value = field.aliases[value] or value
115+
end
106116
end
107117
ctx.terms[key:lower()] = value
108118
end

0 commit comments

Comments
 (0)