-- -- tests/actions/vstudio/vc2010/test_files.lua -- Validate generation of files block in Visual Studio 2010 C/C++ projects. -- Copyright (c) 2011-2013 Jason Perkins and the Premake project -- local suite = test.declare("vstudio_vs2010_files") local vc2010 = premake.vstudio.vc2010 -- -- Setup -- local sln, prj function suite.setup() sln = test.createsolution() end local function prepare() prj = premake.solution.getproject(sln, 1) vc2010.files(prj) end -- -- Test filtering of source files into the correct categories. -- function suite.clInclude_onHFile() files { "include/hello.h" } prepare() test.capture [[ ]] end function suite.clCompile_onCFile() files { "hello.c" } prepare() test.capture [[ ]] end function suite.resourceCompile_onRCFile() files { "resources/hello.rc" } prepare() test.capture [[ ]] end function suite.none_onTxtFile() files { "docs/hello.txt" } prepare() test.capture [[ ]] end function suite.customBuild_onBuildRule() files { "hello.cg" } configuration "**.cg" buildcommands { "cgc $(InputFile)" } buildoutputs { "$(InputName).obj" } prepare() test.capture [[ Document cgc $(InputFile) $(InputName).obj cgc $(InputFile) $(InputName).obj ]] end function suite.customBuild_onBuildRuleWithMessage() files { "hello.cg" } configuration "**.cg" buildmessage "Compiling shader $(InputFile)" buildcommands { "cgc $(InputFile)" } buildoutputs { "$(InputName).obj" } prepare() test.capture [[ Document cgc $(InputFile) $(InputName).obj Compiling shader $(InputFile) cgc $(InputFile) $(InputName).obj Compiling shader $(InputFile) ]] end -- -- If a PCH source is specified, ensure it is included in the file configuration. -- function suite.precompiledHeader_onPchSource() files { "afxwin.cpp" } pchheader "afxwin.h" pchsource "afxwin.cpp" prepare() test.capture [[ Create Create ]] end -- -- If a file is excluded from a configuration, make sure it is marked as such. -- function suite.excludedFromBuild_onExcludedFile() files { "hello.cpp" } configuration "Debug" removefiles { "hello.cpp" } prepare() test.capture [[ true ]] end function suite.excludedFromBuild_onExcludeFlag() files { "hello.cpp" } configuration "hello.cpp" flags { "ExcludeFromBuild" } prepare() test.capture [[ true true ]] end -- -- If two files at different folder levels have the same name, a different -- object file name should be used for each. -- function suite.uniqueObjectNames_onSourceNameCollision() files { "hello.cpp", "greetings/hello.cpp" } prepare() test.capture [[ $(IntDir)\hello1.obj $(IntDir)\hello1.obj ]] end -- -- Check handling of per-file forced includes. -- function suite.forcedIncludeFiles() files { "hello.cpp" } configuration "**.cpp" forceincludes { "../include/force1.h", "../include/force2.h" } prepare() test.capture [[ ..\include\force1.h;..\include\force2.h ..\include\force1.h;..\include\force2.h ]] end -- -- Check handling of per-file command line build options. -- function suite.additionalOptions() files { "hello.cpp" } configuration "**.cpp" buildoptions { "/Xc" } prepare() test.capture [[ /Xc %(AdditionalOptions) /Xc %(AdditionalOptions) ]] end -- -- Check handling of per-file optimization levels. -- function suite.onOptimize() files { "hello.cpp" } configuration "hello.cpp" optimize "On" prepare() test.capture [[ Full ]] end function suite.onOptimizeSize() files { "hello.cpp" } configuration "hello.cpp" optimize "Size" prepare() test.capture [[ MinSpace ]] end function suite.onOptimizeSpeed() files { "hello.cpp" } configuration "hello.cpp" optimize "Speed" prepare() test.capture [[ MaxSpeed ]] end function suite.onOptimizeFull() files { "hello.cpp" } configuration "hello.cpp" optimize "Full" prepare() test.capture [[ Full ]] end function suite.onOptimizeOff() files { "hello.cpp" } configuration "hello.cpp" optimize "Off" prepare() test.capture [[ Disabled ]] end function suite.onOptimizeDebug() files { "hello.cpp" } configuration "hello.cpp" optimize "Debug" prepare() test.capture [[ Disabled ]] end -- -- Check handling of per-file no PCH build options. -- function suite.excludedFromPCH() files { "hello.cpp" } configuration "**.cpp" flags { "NoPCH" } prepare() test.capture [[ NotUsing NotUsing ]] end