2012-01-20 00:14:18 +00:00
|
|
|
--
|
|
|
|
-- tests/actions/vstudio/vc200x/test_files.lua
|
|
|
|
-- Validate generation of <files/> block in Visual Studio 200x projects.
|
|
|
|
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.vstudio_vs200x_files = { }
|
|
|
|
local suite = T.vstudio_vs200x_files
|
|
|
|
local vc200x = premake.vstudio.vc200x
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln, prj
|
|
|
|
|
|
|
|
function suite.setup()
|
|
|
|
sln = test.createsolution()
|
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
|
|
|
prj = premake.solution.getproject_ng(sln, 1)
|
|
|
|
vc200x.files_ng(prj)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check the structure of an individual file element.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.file_onDefaults()
|
|
|
|
files { "hello.cpp" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<File
|
|
|
|
RelativePath="hello.cpp"
|
|
|
|
>
|
|
|
|
</File>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check the structure of a file contained in a folder.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.file_inSingleLevelFolder()
|
2012-03-27 22:33:15 +00:00
|
|
|
files { "src/hello.cpp", "so_long.cpp" }
|
2012-01-20 00:14:18 +00:00
|
|
|
prepare()
|
|
|
|
test.capture [[
|
2012-03-27 22:33:15 +00:00
|
|
|
<File
|
|
|
|
RelativePath="so_long.cpp"
|
|
|
|
>
|
|
|
|
</File>
|
2012-01-20 00:14:18 +00:00
|
|
|
<Filter
|
|
|
|
Name="src"
|
|
|
|
Filter=""
|
|
|
|
>
|
|
|
|
<File
|
|
|
|
RelativePath="src\hello.cpp"
|
|
|
|
>
|
|
|
|
</File>
|
|
|
|
</Filter>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check the structure of a file contained in multiple folders.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.file_onMultipleFolderLevels()
|
2012-03-27 22:33:15 +00:00
|
|
|
files { "src/greetings/hello.cpp", "so_long.cpp" }
|
2012-01-20 00:14:18 +00:00
|
|
|
prepare()
|
|
|
|
test.capture [[
|
2012-03-27 22:33:15 +00:00
|
|
|
<File
|
|
|
|
RelativePath="so_long.cpp"
|
|
|
|
>
|
|
|
|
</File>
|
2012-01-20 00:14:18 +00:00
|
|
|
<Filter
|
|
|
|
Name="src"
|
|
|
|
Filter=""
|
|
|
|
>
|
|
|
|
<Filter
|
|
|
|
Name="greetings"
|
|
|
|
Filter=""
|
|
|
|
>
|
|
|
|
<File
|
|
|
|
RelativePath="src\greetings\hello.cpp"
|
|
|
|
>
|
|
|
|
</File>
|
|
|
|
</Filter>
|
|
|
|
</Filter>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-02-02 01:00:24 +00:00
|
|
|
--
|
|
|
|
-- Check the structure of a file with a virtual path.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.file_onVpath()
|
2012-03-27 22:33:15 +00:00
|
|
|
files { "src/hello.cpp", "so_long.h" }
|
2012-02-02 01:00:24 +00:00
|
|
|
vpaths { ["Source Files"] = "**.cpp" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<Filter
|
|
|
|
Name="Source Files"
|
|
|
|
Filter=""
|
|
|
|
>
|
|
|
|
<File
|
|
|
|
RelativePath="src\hello.cpp"
|
|
|
|
>
|
|
|
|
</File>
|
|
|
|
</Filter>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-01-20 00:14:18 +00:00
|
|
|
--
|
|
|
|
-- 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 [[
|
|
|
|
<File
|
|
|
|
RelativePath="hello.lua"
|
|
|
|
>
|
|
|
|
</File>
|
|
|
|
]]
|
|
|
|
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 [[
|
|
|
|
<File
|
|
|
|
RelativePath="hello.c"
|
|
|
|
>
|
|
|
|
<FileConfiguration
|
|
|
|
Name="Debug|Win32"
|
|
|
|
>
|
|
|
|
<Tool
|
|
|
|
Name="VCCLCompilerTool"
|
|
|
|
CompileAs="1"
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function suite.compileAsSet_onCppFileInCProject()
|
|
|
|
language "C"
|
|
|
|
files { "hello.cpp" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<File
|
|
|
|
RelativePath="hello.cpp"
|
|
|
|
>
|
|
|
|
<FileConfiguration
|
|
|
|
Name="Debug|Win32"
|
|
|
|
>
|
|
|
|
<Tool
|
|
|
|
Name="VCCLCompilerTool"
|
|
|
|
CompileAs="2"
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- A PCH source file should be marked as such.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.usePrecompiledHeadersSet_onPchSource()
|
|
|
|
files { "afxwin.cpp" }
|
|
|
|
pchsource "afxwin.cpp"
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<File
|
|
|
|
RelativePath="afxwin.cpp"
|
|
|
|
>
|
|
|
|
<FileConfiguration
|
|
|
|
Name="Debug|Win32"
|
|
|
|
>
|
|
|
|
<Tool
|
|
|
|
Name="VCCLCompilerTool"
|
|
|
|
UsePrecompiledHeader="1"
|
|
|
|
]]
|
2012-01-23 16:47:48 +00:00
|
|
|
end
|
2012-02-14 21:16:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- A file excluded from a specific configuration should be marked as such.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.excludedFromBuild_onExcludedFile()
|
|
|
|
files { "hello.cpp" }
|
|
|
|
configuration "Debug"
|
|
|
|
removefiles { "hello.cpp" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<File
|
|
|
|
RelativePath="hello.cpp"
|
|
|
|
>
|
|
|
|
<FileConfiguration
|
|
|
|
Name="Debug|Win32"
|
|
|
|
ExcludedFromBuild="true"
|
|
|
|
>
|
|
|
|
<Tool
|
|
|
|
Name="VCCLCompilerTool"
|
|
|
|
/>
|
|
|
|
</FileConfiguration>
|
|
|
|
</File>
|
|
|
|
]]
|
|
|
|
end
|
2012-03-14 22:20:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If a custom build rule is supplied, the custom build tool settings should be used.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.customBuildTool_onBuildRule()
|
|
|
|
files { "hello.x" }
|
|
|
|
configuration "**.x"
|
|
|
|
buildrule {
|
|
|
|
description = "Compiling $(InputFile)",
|
|
|
|
commands = {
|
|
|
|
'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"',
|
|
|
|
'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"'
|
|
|
|
},
|
2012-03-16 00:02:46 +00:00
|
|
|
outputs = { "$(IntDir)/$(InputName).obj" }
|
2012-03-14 22:20:01 +00:00
|
|
|
}
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<File
|
|
|
|
RelativePath="hello.x"
|
|
|
|
>
|
|
|
|
<FileConfiguration
|
|
|
|
Name="Debug|Win32"
|
|
|
|
>
|
|
|
|
<Tool
|
|
|
|
Name="VCCustomBuildTool"
|
2012-03-16 00:02:46 +00:00
|
|
|
CommandLine="cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"
c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj""
|
2012-03-14 22:20:01 +00:00
|
|
|
Outputs="$(IntDir)/$(InputName).obj"
|
|
|
|
/>
|
2012-03-16 00:02:46 +00:00
|
|
|
</FileConfiguration>
|
2012-03-14 22:20:01 +00:00
|
|
|
]]
|
|
|
|
end
|