Enable per-file optimization levels for Visual Studio
This commit is contained in:
parent
133cf7ce7c
commit
d1eb67d43b
@ -404,7 +404,7 @@
|
||||
|
||||
function vc200x.VCCLBuiltInCompilerTool(cfg)
|
||||
vc200x.VCCLCompilerTool_additionalOptions(cfg)
|
||||
vc200x.optimization(cfg)
|
||||
vc200x.optimization(cfg, 4)
|
||||
|
||||
if cfg.flags.NoFramePointer then
|
||||
_p(4,'OmitFramePointers="%s"', vc200x.bool(true))
|
||||
@ -880,6 +880,7 @@
|
||||
if filecfg then
|
||||
vc200x.customBuildTool(filecfg, depth)
|
||||
vc200x.objectFile(filecfg, depth)
|
||||
vc200x.optimization(filecfg, depth)
|
||||
vc200x.usePrecompiledHeader(filecfg, depth)
|
||||
vc200x.VCCLCompilerTool_fileConfig_additionalOptions(filecfg, depth)
|
||||
vc200x.forcedIncludeFiles(filecfg, depth)
|
||||
@ -1088,9 +1089,12 @@
|
||||
end
|
||||
|
||||
|
||||
function vc200x.optimization(cfg)
|
||||
local map = { On = 3, Full = 3, Size = 1, Speed = 2 }
|
||||
_p(4,'Optimization="%s"', map[cfg.optimize] or 0)
|
||||
function vc200x.optimization(cfg, depth)
|
||||
local map = { Off=0, On=3, Debug=0, Full=3, Size=1, Speed=2 }
|
||||
local value = map[cfg.optimize]
|
||||
if value or not cfg.abspath then
|
||||
_p(depth,'Optimization="%s"', value or 0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -495,6 +495,7 @@
|
||||
vc2010.excludedFromBuild(cfg, filecfg)
|
||||
if filecfg then
|
||||
vc2010.objectFileName(filecfg)
|
||||
vc2010.optimization(filecfg, condition)
|
||||
vc2010.forceIncludes(filecfg, condition)
|
||||
vc2010.precompiledHeader(cfg, filecfg, condition)
|
||||
vc2010.additionalCompileOptions(filecfg, condition)
|
||||
@ -978,9 +979,12 @@
|
||||
end
|
||||
|
||||
|
||||
function vc2010.optimization(cfg)
|
||||
local map = { On = "Full", Full = "Full", Size = "MinSpace", Speed = "MaxSpeed" }
|
||||
_p(3,'<Optimization>%s</Optimization>', map[cfg.optimize] or "Disabled")
|
||||
function vc2010.optimization(cfg, condition)
|
||||
local map = { Off="Disabled", On="Full", Debug="Disabled", Full="Full", Size="MinSpace", Speed="MaxSpeed" }
|
||||
local value = map[cfg.optimize]
|
||||
if value or not condition then
|
||||
vc2010.element(3, 'Optimization', condition, value or "Disabled")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -354,7 +354,6 @@
|
||||
--
|
||||
|
||||
function suite.forcedIncludeFiles()
|
||||
language "C++"
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
forceincludes { "../include/force1.h", "../include/force2.h" }
|
||||
@ -379,7 +378,6 @@
|
||||
--
|
||||
|
||||
function suite.additionalOptions()
|
||||
language "C++"
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
buildoptions { "/Xc" }
|
||||
@ -397,3 +395,117 @@
|
||||
AdditionalOptions="/Xc"
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of per-file optimization levels.
|
||||
--
|
||||
|
||||
function suite.onOptimize()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
optimize "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.onOptimizeSize()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
optimize "Size"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeSpeed()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
optimize "Speed"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeFull()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
optimize "Full"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeOff()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
optimize "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeDebug()
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
optimize "Debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<File
|
||||
RelativePath="hello.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
]]
|
||||
end
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
--
|
||||
-- Check the basic element structure with default settings.
|
||||
--
|
||||
---
|
||||
|
||||
function suite.defaultSettings()
|
||||
prepare()
|
||||
|
@ -190,7 +190,6 @@
|
||||
--
|
||||
|
||||
function suite.forcedIncludeFiles()
|
||||
language "C++"
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
forceincludes { "../include/force1.h", "../include/force2.h" }
|
||||
@ -212,7 +211,6 @@
|
||||
--
|
||||
|
||||
function suite.additionalOptions()
|
||||
language "C++"
|
||||
files { "hello.cpp" }
|
||||
configuration "**.cpp"
|
||||
buildoptions { "/Xc" }
|
||||
@ -227,3 +225,81 @@
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of per-file optimization levels.
|
||||
--
|
||||
|
||||
function suite.onOptimize()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
optimize "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Full</Optimization>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.onOptimizeSize()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
optimize "Size"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MinSpace</Optimization>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeSpeed()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
optimize "Speed"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MaxSpeed</Optimization>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeFull()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
optimize "Full"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Full</Optimization>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeOff()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
optimize "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onOptimizeDebug()
|
||||
files { "hello.cpp" }
|
||||
configuration "hello.cpp"
|
||||
optimize "Debug"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ClCompile Include="hello.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
]]
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user