From ac2919e74c84b7eb5f504cda0f619305b6d9fef9 Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Wed, 1 Feb 2017 08:47:50 -0800 Subject: [PATCH] stringpooling api. (#682) * stringpooling api. * add options to msc.lua --- src/_premake_init.lua | 6 +++ src/actions/vstudio/vs2010_vcxproj.lua | 8 +++- src/base/config.lua | 3 ++ src/tools/msc.lua | 4 ++ .../vstudio/vc2010/test_compile_settings.lua | 44 +++++++++++++++++++ tests/tools/test_msc.lua | 17 +++++++ 6 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 55925d0d..e0515dac 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -969,6 +969,12 @@ } } + api.register { + name = "stringpooling", + scope = "config", + kind = "boolean" + } + api.register { name = "symbols", scope = "config", diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 93414b54..69daeca2 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -1979,7 +1979,13 @@ end function m.stringPooling(cfg) - if config.isOptimizedBuild(cfg) then + if cfg.stringpooling ~= nil then + if cfg.stringpooling then + m.element("StringPooling", nil, "true") + else + m.element("StringPooling", nil, "false") + end + elseif config.isOptimizedBuild(cfg) then m.element("StringPooling", nil, "true") end end diff --git a/src/base/config.lua b/src/base/config.lua index 43e98388..136a05cf 100755 --- a/src/base/config.lua +++ b/src/base/config.lua @@ -493,6 +493,9 @@ -- replacement, if any, to the result local values = cfg[field.name] + if type(values) == "boolean" then + values = iif(values, "On", "Off") + end if type(values) ~= "table" then values = { values } end diff --git a/src/tools/msc.lua b/src/tools/msc.lua index aa42464f..2f10babd 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -75,6 +75,10 @@ Extra = "/W4", Off = "/W0", }, + stringpooling = { + On = "/GF", + Off = "/GF-", + }, symbols = { On = "/Z7" } diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/tests/actions/vstudio/vc2010/test_compile_settings.lua index ff9b4cd7..1268c7c5 100644 --- a/tests/actions/vstudio/vc2010/test_compile_settings.lua +++ b/tests/actions/vstudio/vc2010/test_compile_settings.lua @@ -786,3 +786,47 @@ Disabled ]] end + + + +-- +-- Check handling of the stringpooling api +-- + function suite.onStringPoolingOff() + stringpooling 'Off' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + function suite.onStringPoolingOn() + stringpooling 'On' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + function suite.onStringPoolingNotSpecified() + optimize "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Full + true + true + false + true + ]] + end diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 5401a58e..a89cc15b 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -77,6 +77,23 @@ test.contains("/GL", msc.getldflags(cfg)) end + function suite.cflags_onStringPoolingOn() + stringpooling "On" + prepare() + test.contains("/GF", msc.getcflags(cfg)) + end + + function suite.cflags_onStringPoolingOff() + stringpooling "Off" + prepare() + test.contains("/GF-", msc.getcflags(cfg)) + end + + function suite.cflags_onStringPoolingNotSpecified() + prepare() + test.excludes("/GF", msc.getcflags(cfg)) + test.excludes("/GF-", msc.getcflags(cfg)) + end -- -- Check the translation of symbols.