Add new API characterset(); make Premake match Visual Studio default behavior
Visual Studio has been defaulting its projects to Unicode since at least 2008. Premake has been defaulting to MBCS to maintain backward compatibility with earlier Premake versions. This PR tries to set things right by switching Premake's default to Unicode. This might set a record for most broken projects.
This commit is contained in:
parent
7181799760
commit
16b62f0877
@ -132,6 +132,17 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "characterset",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
"Default",
|
||||
"MBCS",
|
||||
"Unicode",
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "cleancommands",
|
||||
scope = "config",
|
||||
@ -474,7 +485,7 @@
|
||||
"StaticRuntime",
|
||||
"Symbols",
|
||||
"UndefinedIdentifiers",
|
||||
"Unicode",
|
||||
"Unicode", -- DEPRECATED
|
||||
"Unsafe", -- DEPRECATED
|
||||
"WinMain",
|
||||
"WPF",
|
||||
@ -1230,6 +1241,16 @@
|
||||
clr "On"
|
||||
end)
|
||||
|
||||
-- 18 Dec 2015
|
||||
|
||||
api.deprecateValue("flags", "Unicode", nil,
|
||||
function(value)
|
||||
characterset "Unicode"
|
||||
end,
|
||||
function(value)
|
||||
characterset "Default"
|
||||
end)
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
@ -952,7 +952,7 @@
|
||||
|
||||
function m.characterSet(cfg)
|
||||
if not vstudio.isMakefile(cfg) then
|
||||
p.w('CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2))
|
||||
p.w('CharacterSet="%s"', iif(cfg.characterset == p.MBCS, 2, 1))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1018,7 +1018,7 @@
|
||||
|
||||
function m.characterSet(cfg)
|
||||
if not vstudio.isMakefile(cfg) then
|
||||
m.element("CharacterSet", nil, iif(cfg.flags.Unicode, "Unicode", "MultiByte"))
|
||||
m.element("CharacterSet", nil, iif(cfg.characterset == p.MBCS, "MultiByte", "Unicode"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
premake.LINUX = "linux"
|
||||
premake.MACOSX = "macosx"
|
||||
premake.MAKEFILE = "Makefile"
|
||||
premake.MBCS = "MBCS"
|
||||
premake.NONE = "None"
|
||||
premake.DEFAULT = "Default"
|
||||
premake.ON = "On"
|
||||
@ -44,6 +45,7 @@
|
||||
premake.PS3 = "ps3"
|
||||
premake.SHAREDLIB = "SharedLib"
|
||||
premake.STATICLIB = "StaticLib"
|
||||
premake.UNICODE = "Unicode"
|
||||
premake.UNIVERSAL = "universal"
|
||||
premake.UTILITY = "Utility"
|
||||
premake.WINDOWEDAPP = "WindowedApp"
|
||||
|
@ -103,6 +103,7 @@ return {
|
||||
"actions/vstudio/vc2010/test_assembly_refs.lua",
|
||||
"actions/vstudio/vc2010/test_build_events.lua",
|
||||
"actions/vstudio/vc2010/test_build_log.lua",
|
||||
"actions/vstudio/vc2010/test_character_set.lua",
|
||||
"actions/vstudio/vc2010/test_compile_settings.lua",
|
||||
"actions/vstudio/vc2010/test_config_props.lua",
|
||||
"actions/vstudio/vc2010/test_debug_settings.lua",
|
||||
|
@ -40,7 +40,7 @@
|
||||
OutputDirectory="bin\Debug"
|
||||
IntermediateDirectory="obj\Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
]]
|
||||
end
|
||||
|
47
tests/actions/vstudio/vc2010/test_character_set.lua
Normal file
47
tests/actions/vstudio/vc2010/test_character_set.lua
Normal file
@ -0,0 +1,47 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_character_set.lua
|
||||
-- Validate generation Unicode/MBCS settings.
|
||||
-- Copyright (c) 2011-2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs2010_character_set")
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2010"
|
||||
wks, prj = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
local cfg = test.getconfig(prj, "Debug")
|
||||
vc2010.characterSet(cfg)
|
||||
end
|
||||
|
||||
|
||||
function suite.onDefault()
|
||||
prepare()
|
||||
test.capture [[
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.onUnicode()
|
||||
characterset "Unicode"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.onMBCS()
|
||||
characterset "MBCS"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
]]
|
||||
end
|
@ -36,7 +36,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
]]
|
||||
end
|
||||
@ -96,21 +96,6 @@
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check the support for Unicode.
|
||||
--
|
||||
|
||||
function suite.characterSet_onUnicode()
|
||||
flags "Unicode"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check the support for Managed C++.
|
||||
@ -298,7 +283,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
]]
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user