-- -- tests/actions/vstudio/vc2010/test_compile_settings.lua -- Validate compiler settings in Visual Studio 2010 C/C++ projects. -- Copyright (c) 2011-2013 Jason Perkins and the Premake project -- local suite = test.declare("vstudio_vs2010_compile_settings") local vc2010 = premake.vstudio.vc2010 local project = premake.project -- -- Setup -- local sln, prj function suite.setup() sln, prj = test.createsolution() end local function prepare(platform) local cfg = test.getconfig(prj, "Debug", platform) vc2010.clCompile(cfg) end -- -- Check the basic element structure with default settings. --- function suite.defaultSettings() prepare() test.capture [[ NotUsing Level3 Disabled ]] end --- -- Test precompiled header handling; the header should be treated as -- a plain string value, with no path manipulation applied, since it -- needs to match the value of the #include statement used in the -- project code. --- function suite.usePrecompiledHeaders_onPrecompiledHeaders() location "build" pchheader "include/afxwin.h" prepare() test.capture [[ Use include/afxwin.h ]] end --- -- The NoPCH flag should override any other PCH settings. --- function suite.noPrecompiledHeaders_onNoPCH() pchheader "afxwin.h" flags "NoPCH" prepare() test.capture [[ NotUsing ]] end -- -- If extra warnings is specified, pump up the volume. -- function suite.warningLevel_onExtraWarnings() warnings "Extra" prepare() test.capture [[ NotUsing Level4 ]] end -- -- If the warnings are disabled, mute all warnings. -- function suite.warningLevel_onNoWarnings() warnings "Off" prepare() test.capture [[ NotUsing TurnOffAllWarnings ]] end -- -- If warnings are turned off, the fatal warnings flags should -- not be generated. -- function suite.warningLevel_onNoWarningsOverOtherWarningsFlags() flags { "FatalWarnings" } warnings "Off" prepare() test.capture [[ NotUsing TurnOffAllWarnings ]] end -- -- Check the optimization flags. -- function suite.optimization_onOptimize() optimize "On" prepare() test.capture [[ NotUsing Level3 Full true true false true ]] end function suite.optimization_onOptimizeSize() optimize "Size" prepare() test.capture [[ NotUsing Level3 MinSpace true true false true ]] end function suite.optimization_onOptimizeSpeed() optimize "Speed" prepare() test.capture [[ NotUsing Level3 MaxSpeed true true false true ]] end function suite.optimization_onOptimizeFull() optimize "Full" prepare() test.capture [[ NotUsing Level3 Full true true false true ]] end function suite.optimization_onOptimizeOff() optimize "Off" prepare() test.capture [[ NotUsing Level3 Disabled ]] end function suite.optimization_onOptimizeDebug() optimize "Debug" prepare() test.capture [[ NotUsing Level3 Disabled ]] end function suite.omitFrames_onNoFramePointer() flags "NoFramePointer" prepare() test.capture [[ NotUsing Level3 Disabled true ]] end -- -- If defines are specified, the element should be added. -- function suite.preprocessorDefinitions_onDefines() defines { "DEBUG", "_DEBUG" } prepare() test.capture [[ NotUsing Level3 DEBUG;_DEBUG;%(PreprocessorDefinitions) ]] end -- -- If build options are specified, the element should be specified. -- function suite.additionalOptions_onBuildOptions() buildoptions { "/xyz", "/abc" } prepare() test.capture [[ NotUsing Level3 Disabled /xyz /abc %(AdditionalOptions) ]] end -- -- If include directories are specified, the should be added. -- function suite.additionalIncludeDirs_onIncludeDirs() includedirs { "include/lua", "include/zlib" } prepare() test.capture [[ NotUsing Level3 include\lua;include\zlib;%(AdditionalIncludeDirectories) ]] end -- -- If include directories are specified, the should be added. -- function suite.additionalUsingDirs_onUsingDirs() usingdirs { "include/lua", "include/zlib" } prepare() test.capture [[ NotUsing Level3 include\lua;include\zlib;%(AdditionalUsingDirectories) ]] end -- -- Turn off minimal rebuilds if the NoMinimalRebuild flag is set. -- function suite.minimalRebuild_onNoMinimalRebuild() flags "NoMinimalRebuild" prepare() test.capture [[ NotUsing Level3 Disabled false ]] end -- -- Can't minimal rebuild with the C7 debugging format. -- function suite.minimalRebuild_onC7() debugformat "C7" prepare() test.capture [[ NotUsing Level3 Disabled false ]] end -- -- If the StaticRuntime flag is specified, add the element. -- function suite.runtimeLibrary_onStaticRuntime() flags { "StaticRuntime" } prepare() test.capture [[ NotUsing Level3 Disabled MultiThreaded ]] end function suite.runtimeLibrary_onStaticRuntimeAndSymbols() flags { "StaticRuntime", "Symbols" } prepare() test.capture [[ NotUsing Level3 EditAndContinue $(OutDir)MyProject.pdb Disabled MultiThreadedDebug ]] end -- -- Add if FatalWarnings flag is set. -- function suite.treatWarningsAsError_onFatalWarnings() flags { "FatalWarnings" } prepare() test.capture [[ NotUsing Level3 true ]] end -- -- Check the handling of the Symbols flag. -- function suite.onSymbolsFlag() flags "Symbols" prepare() test.capture [[ NotUsing Level3 EditAndContinue $(OutDir)MyProject.pdb Disabled ]] end -- -- Check the handling of the C7 debug information format. -- function suite.onC7DebugFormat() flags "Symbols" debugformat "c7" prepare() test.capture [[ NotUsing Level3 OldStyle Disabled ]] end -- -- Check handling of floating point and SSE flags. -- function suite.instructionSet_onSSE() vectorextensions "SSE" prepare() test.capture [[ NotUsing Level3 Disabled StreamingSIMDExtensions ]] end function suite.instructionSet_onSSE2() vectorextensions "SSE2" prepare() test.capture [[ NotUsing Level3 Disabled StreamingSIMDExtensions2 ]] end function suite.floatingPoint_onFloatFast() flags "FloatFast" prepare() test.capture [[ NotUsing Level3 Disabled Fast ]] end function suite.floatingPoint_onFloatStrict() flags "FloatStrict" prepare() test.capture [[ NotUsing Level3 Disabled Strict ]] end -- -- Verify character handling. -- function suite.wchar_onNative() flags "NativeWChar" prepare() test.capture [[ NotUsing Level3 Disabled true ]] end function suite.wchar_onNoNative() flags "NoNativeWChar" prepare() test.capture [[ NotUsing Level3 Disabled false ]] end -- -- Check exception handling and RTTI. -- function suite.exceptions_onNoExceptions() flags "NoExceptions" prepare() test.capture [[ NotUsing Level3 Disabled false ]] end function suite.exceptions_onSEH() flags "SEH" prepare() test.capture [[ NotUsing Level3 Disabled Async ]] end function suite.runtimeTypeInfo_onNoRTTI() flags "NoRTTI" prepare() test.capture [[ NotUsing Level3 Disabled false ]] end function suite.runtimeTypeInfo_onNoRTTI() flags "NoBufferSecurityCheck" prepare() test.capture [[ NotUsing Level3 Disabled false ]] end -- -- On Win32 builds, use the Edit-and-Continue debug information format. -- function suite.debugFormat_onWin32() flags "Symbols" architecture "x32" prepare() test.capture [[ NotUsing Level3 EditAndContinue ]] end -- -- Edit-and-Continue is not support on 64-bit builds. -- function suite.debugFormat_onWin64() flags "Symbols" architecture "x64" prepare() test.capture [[ NotUsing Level3 ProgramDatabase ]] end -- -- Check the handling of the NoEditAndContinue flag. -- function suite.debugFormat_onNoEditAndContinue() flags { "Symbols", "NoEditAndContinue" } prepare() test.capture [[ NotUsing Level3 ProgramDatabase ]] end -- -- Edit-and-Continue is not supported for optimized builds. -- function suite.debugFormat_onOptimizedBuild() flags { "Symbols" } optimize "On" prepare() test.capture [[ NotUsing Level3 ProgramDatabase ]] end -- -- Edit-and-Continue is not supported for Managed builds. -- function suite.debugFormat_onManagedCode() flags { "Symbols", "Managed" } prepare() test.capture [[ NotUsing Level3 ProgramDatabase ]] end -- -- Check handling of forced includes. -- function suite.forcedIncludeFiles() forceincludes { "stdafx.h", "include/sys.h" } prepare() test.capture [[ NotUsing Level3 stdafx.h;include\sys.h ]] end function suite.forcedUsingFiles() forceusings { "stdafx.h", "include/sys.h" } prepare() test.capture [[ NotUsing Level3 stdafx.h;include\sys.h ]] end -- -- Check handling of the NoRuntimeChecks flag. -- function suite.onNoRuntimeChecks() flags { "NoRuntimeChecks" } prepare() test.capture [[ NotUsing Level3 Default ]] end -- -- Check handling of the EnableMultiProcessorCompile flag. -- function suite.onMultiProcessorCompile() flags { "MultiProcessorCompile" } prepare() test.capture [[ NotUsing Level3 Disabled false true ]] end -- -- Check handling of the ReleaseRuntime flag; should override the -- default behavior of linking the debug runtime when symbols are -- enabled with no optimizations. -- function suite.releaseRuntime_onStaticAndReleaseRuntime() flags { "Symbols", "ReleaseRuntime", "StaticRuntime" } prepare() test.capture [[ NotUsing Level3 EditAndContinue $(OutDir)MyProject.pdb Disabled MultiThreaded ]] end -- -- Check handling of the OmitDefaultLibrary flag. -- function suite.onOmitDefaultLibrary() flags { "OmitDefaultLibrary" } prepare() test.capture [[ NotUsing Level3 Disabled true ]] end