Skip to content

Commit fb0f79b

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

File tree

5 files changed

+153
-1
lines changed

5 files changed

+153
-1
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

modules/vstudio/vstudio.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
vstudio.vs2010_architectures =
3535
{
3636
win32 = "x86",
37+
x86 = "x86",
38+
x86_64 = "x64",
39+
ARM = "ARM",
40+
AARCH64 = "ARM64",
3741
}
3842

3943
local function architecture(system, arch)

src/base/context.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,25 @@
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+
local aliased = field.aliases[value[i]]
107+
if aliased then
108+
value[i] = tostring(aliased):lower()
109+
end
110+
end
103111
end
104112
elseif value ~= nil then
105113
value = tostring(value):lower()
114+
115+
local field = p.field.get(key)
116+
if field and field.aliases then
117+
local aliased = field.aliases[value]
118+
if aliased then
119+
value = tostring(aliased):lower()
120+
end
121+
end
106122
end
107123
ctx.terms[key:lower()] = value
108124
end

src/base/criteria.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@
113113
if prefix then
114114
local fld = p.field.get(prefix)
115115
if fld and fld.aliases then
116-
word[1] = fld.aliases[word[1]] or word[1]
116+
local aliased = fld.aliases[word[1]]
117+
if aliased then
118+
word[1] = tostring(aliased):lower()
119+
end
117120
end
118121
end
119122

0 commit comments

Comments
 (0)