--
-- tests/actions/vstudio/vc200x/test_files.lua
-- Validate generation of block in Visual Studio 200x projects.
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
--
local suite = test.declare("vstudio_vs200x_files")
local vc200x = premake.vstudio.vc200x
--
-- Setup
--
local sln, prj
function suite.setup()
io.esc = premake.vstudio.vs2005.esc
sln = test.createsolution()
end
local function prepare()
prj = premake.solution.getproject(sln, 1)
vc200x.files(prj)
end
--
-- Check the structure of an individual file element.
--
function suite.file_onDefaults()
files { "hello.cpp" }
prepare()
test.capture [[
]]
end
--
-- Check the structure of a file contained in a folder.
--
function suite.file_onSingleLevelFolder()
files { "src/hello.cpp", "so_long.cpp" }
prepare()
test.capture [[
]]
end
--
-- Check the structure of a file contained in multiple folders.
--
function suite.file_onMultipleFolderLevels()
files { "src/greetings/hello.cpp", "so_long.cpp" }
prepare()
test.capture [[
]]
end
--
-- Check the structure of a file with a virtual path.
--
function suite.file_onVpath()
files { "src/hello.cpp", "so_long.h" }
vpaths { ["Source Files"] = "**.cpp" }
prepare()
test.capture [[
]]
end
--
-- Make sure that the special "build a C code" logic only gets triggered
-- by actual C source code files.
--
function suite.file_markedAsNonBuildable_onSupportFiles()
language "C"
files { "hello.lua" }
prepare()
test.capture [[
]]
end
--
-- When a C code file is listed in a C++ project, it should still be
-- compiled as C (and not C++), and vice versa.
--
function suite.compileAsSet_onCFileInCppProject()
language "C++"
files { "hello.c" }
prepare()
test.capture [[
]]
end
function suite.excludedFromBuild_onExcludeFlag()
files { "hello.cpp" }
configuration "hello.cpp"
flags { "ExcludeFromBuild" }
prepare()
test.capture [[
]]
end
--
-- If a custom build rule is supplied, the custom build tool settings should be used.
--
function suite.customBuildTool_onBuildRule()
files { "hello.x" }
configuration "**.x"
buildmessage "Compiling $(InputFile)"
buildcommands {
'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"',
'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"'
}
buildoutputs { "$(IntDir)/$(InputName).obj" }
prepare()
test.capture [[
]]
end
function suite.customBuildTool_onBuildRuleWithTokens()
files { "hello.x" }
objdir "../tmp/%{cfg.name}"
configuration "**.x"
buildmessage "Compiling $(InputFile)"
buildcommands {
'cxc -c %{file.relpath} -o %{cfg.objdir}/%{file.basename}.xo',
'c2o -c %{cfg.objdir}/%{file.basename}.xo -o %{cfg.objdir}/%{file.basename}.obj'
}
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
prepare()
test.capture [[
]]
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 [[
]]
end
--
-- Check handling of per-file forced includes.
--
function suite.forcedIncludeFiles()
language "C++"
files { "hello.cpp" }
configuration "**.cpp"
forceincludes { "../include/force1.h", "../include/force2.h" }
prepare()
test.capture [[