From 053d276d8e2e8fc0a5bdee9f1886ee46eeda4771 Mon Sep 17 00:00:00 2001 From: Nicholaus Clark Date: Sun, 1 Feb 2026 16:38:07 -0500 Subject: [PATCH] Fixes filters using an aliased value --- modules/vstudio/tests/_tests.lua | 1 + .../vstudio/tests/vc2010/test_target_name.lua | 128 ++++++++++++++++++ modules/vstudio/vstudio.lua | 4 + src/base/context.lua | 4 +- src/base/criteria.lua | 5 +- src/base/field.lua | 13 ++ 6 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 modules/vstudio/tests/vc2010/test_target_name.lua diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua index cec8c14be5..e9f8bfa231 100644 --- a/modules/vstudio/tests/_tests.lua +++ b/modules/vstudio/tests/_tests.lua @@ -96,6 +96,7 @@ return { "vc2010/test_rule_xml.lua", "vc2010/test_tokens.lua", "vc2010/test_target_machine.lua", + "vc2010/test_target_name.lua", "vc2010/test_user_file.lua", "vc2010/test_vectorextensions.lua", "vc2010/test_ensure_nuget_imports.lua", diff --git a/modules/vstudio/tests/vc2010/test_target_name.lua b/modules/vstudio/tests/vc2010/test_target_name.lua new file mode 100644 index 0000000000..d27083eb99 --- /dev/null +++ b/modules/vstudio/tests/vc2010/test_target_name.lua @@ -0,0 +1,128 @@ +-- +-- test_target_name.lua +-- Test target names. +-- Author: Nick Clark +-- Copyright (c) 2026 Jess Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vs2010_target_name") + local vc2010 = p.vstudio.vc2010 + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks, prj = test.createWorkspace() + end + + local function prepare(platform) + local cfg = test.getconfig(prj, "Debug", platform) + vc2010.targetName(cfg) + end + + +-- +-- Default target name is the project name +-- + + function suite.defaultTargetName() + prepare() + test.capture [[ +MyProject + ]] + end + + + function suite.targetWithSuffix() + targetsuffix "_suffix" + + prepare() + test.capture [[ +MyProject_suffix + ]] + end + + +-- +-- Target name with targetsuffix with AARCH architecture +-- + + function suite.targetWithAarch64FilterSuffix() + architecture "AARCH64" + + filter { "architecture:AARCH64" } -- Fails if it is set to ARM64 + targetsuffix "_ARM64" + + prepare() + test.capture [[ +MyProject_ARM64 + ]] + end + + +-- +-- Target name with targetsuffix with ARM64 architecture +-- + + function suite.targetWithArm64FilterSuffix() + architecture "ARM64" + + filter { "architecture:ARM64" } -- Should match when architecture is AARCH64 + targetsuffix "_ARM64" + + prepare() + test.capture [[ +MyProject_ARM64 + ]] + end + + +-- +-- Target name with targetsuffix and x64 architecture +-- + + function suite.targetWithX64FilterSuffix() + architecture "x64" + + filter { "architecture:x64" } + targetsuffix "_x64" + + prepare() + test.capture [[ +MyProject_x64 + ]] + end + + +-- +-- Target name with targetprefix +-- + + function suite.targetWithPrefix() + targetprefix "lib" + + prepare() + test.capture [[ +libMyProject + ]] + end + + +-- +-- Target name with targetprefix and targetsuffix +-- + + function suite.targetWithPrefixAndSuffix() + targetprefix "lib" + targetsuffix "_suffix" + + prepare() + test.capture [[ +libMyProject_suffix + ]] + end \ No newline at end of file diff --git a/modules/vstudio/vstudio.lua b/modules/vstudio/vstudio.lua index 2f8a6c6fa6..2897f3b3b2 100644 --- a/modules/vstudio/vstudio.lua +++ b/modules/vstudio/vstudio.lua @@ -34,6 +34,10 @@ vstudio.vs2010_architectures = { win32 = "x86", + x86 = "x86", + x86_64 = "x64", + ARM = "ARM", + AARCH64 = "ARM64", } local function architecture(system, arch) diff --git a/src/base/context.lua b/src/base/context.lua index 9a78ce90be..a83d17c53b 100644 --- a/src/base/context.lua +++ b/src/base/context.lua @@ -99,10 +99,10 @@ function context.addFilter(ctx, key, value) if type(value) == "table" then for i = 1, #value do - value[i] = tostring(value[i]):lower() + value[i] = p.field.resolvealias(key, tostring(value[i])) end elseif value ~= nil then - value = tostring(value):lower() + value = p.field.resolvealias(key, value) end ctx.terms[key:lower()] = value end diff --git a/src/base/criteria.lua b/src/base/criteria.lua index c5a5f8c739..6e71a0abb4 100644 --- a/src/base/criteria.lua +++ b/src/base/criteria.lua @@ -111,10 +111,7 @@ -- check for field value aliases if prefix then - local fld = p.field.get(prefix) - if fld and fld.aliases then - word[1] = fld.aliases[word[1]] or word[1] - end + word[1] = p.field.resolvealias(prefix, word[1]) end -- Check if the prefix is an action diff --git a/src/base/field.lua b/src/base/field.lua index ac247b104e..fc43a00956 100644 --- a/src/base/field.lua +++ b/src/base/field.lua @@ -389,3 +389,16 @@ return (field.accessor(f, "translate") ~= nil) end + + function field.resolvealias(key, value) + value = value:lower() + local f = field.get(key) + if f and f.aliases then + local alias = f.aliases[value] + if alias then + return tostring(alias):lower() + end + end + return value + end +