Move character set command line flags from switch lists to defines

This commit is contained in:
Jason Perkins 2016-01-18 14:11:50 -05:00
parent 84cb655069
commit 309ef32ff8
3 changed files with 26 additions and 12 deletions

View File

@ -390,7 +390,7 @@
function make.defines(cfg, toolset)
_p(' DEFINES +=%s', make.list(table.join(toolset.getdefines(cfg.defines), toolset.getundefines(cfg.undefines))))
_p(' DEFINES +=%s', make.list(table.join(toolset.getdefines(cfg.defines, cfg), toolset.getundefines(cfg.undefines))))
end

View File

@ -29,11 +29,6 @@
--
msc.cflags = {
characterset = {
Default = { '/D"_UNICODE"', '/D"UNICODE"' },
MBCS = '/D"_MBCS"',
Unicode = { '/D"_UNICODE"', '/D"UNICODE"' },
},
clr = {
On = "/clr",
Unsafe = "/clr",
@ -133,8 +128,27 @@
-- Decorate defines for the MSVC command line.
--
function msc.getdefines(defines)
local result = {}
msc.defines = {
characterset = {
Default = { '/D"_UNICODE"', '/D"UNICODE"' },
MBCS = '/D"_MBCS"',
Unicode = { '/D"_UNICODE"', '/D"UNICODE"' },
}
}
function msc.getdefines(defines, cfg)
local result
-- HACK: I need the cfg to tell what the character set defines should be. But
-- there's lots of legacy code using the old getdefines(defines) signature.
-- For now, detect one or two arguments and apply the right behavior; will fix
-- it properly when the I roll out the adapter overhaul
if cfg and defines then
result = config.mapFlags(cfg, msc.defines)
else
result = {}
end
for _, define in ipairs(defines) do
table.insert(result, '/D"' .. define .. '"')
end

View File

@ -196,7 +196,7 @@
function suite.defines()
defines "DEF"
prepare()
test.contains({ '/D"DEF"' }, msc.getdefines(cfg.defines))
test.contains({ '/D"DEF"' }, msc.getdefines(cfg.defines, cfg))
end
function suite.undefines()
@ -317,19 +317,19 @@
function suite.cflags_onCharSetDefault()
prepare()
test.contains('/D"_UNICODE"', msc.getcflags(cfg))
test.contains('/D"_UNICODE"', msc.getdefines(cfg.defines, cfg))
end
function suite.cflags_onCharSetUnicode()
characterset "Unicode"
prepare()
test.contains('/D"_UNICODE"', msc.getcflags(cfg))
test.contains('/D"_UNICODE"', msc.getdefines(cfg.defines, cfg))
end
function suite.cflags_onCharSetMBCS()
characterset "MBCS"
prepare()
test.contains('/D"_MBCS"', msc.getcflags(cfg))
test.contains('/D"_MBCS"', msc.getdefines(cfg.defines, cfg))
end