Completed VS2010 port to new platforms API

This commit is contained in:
Jason Perkins 2012-02-01 19:05:13 -05:00
parent 935015b805
commit 7e5f16312a
14 changed files with 500 additions and 730 deletions

View File

@ -445,10 +445,11 @@
function vc2010.projectReferences_ng(prj)
local deps = project.getdependencies(prj)
if #deps > 0 then
local prjpath = project.getlocation(prj)
_p(1,'<ItemGroup>')
for _, dep in ipairs(deps) do
local slnpath = premake.solution.getlocation(prj.solution)
local relpath = path.getrelative(slnpath, vstudio.projectfile(dep))
local relpath = path.getrelative(prjpath, vstudio.projectfile_ng(dep))
_x(2,'<ProjectReference Include=\"%s\">', path.translate(relpath))
_p(3,'<Project>{%s}</Project>', dep.uuid)
_p(2,'</ProjectReference>')
@ -517,7 +518,7 @@
if cfg.flags.Symbols then
if cfg.debugformat == "c7" then
value = "OldStyle"
elseif cfg.platform == "x64" or
elseif cfg.architecture == "x64" or
cfg.flags.Managed or
premake.config.isoptimizedbuild(cfg) or
cfg.flags.NoEditAndContinue

View File

@ -5,21 +5,98 @@
--
local vc2010 = premake.vstudio.vc2010
local project = premake5.project
--
-- Generate a Visual Studio 2010 C++ project, with support for the new platforms API.
--
function vc2010.generate_filters_ng(prj)
print("C++ project filters generation isn't implemented yet!");
end
--
-- Generate a Visual Studio 2010 C++ project, with support for the new platforms API.
--
function vc2010.generate_filters_ng(prj)
io.eol = "\r\n"
io.indent = " "
vc2010.header_ng()
vc2010.filters_uniqueidentifiers(prj)
vc2010.filters_filegroup(prj, "None")
vc2010.filters_filegroup(prj, "ClInclude")
vc2010.filters_filegroup(prj, "ClCompile")
vc2010.filters_filegroup(prj, "ResourceCompile")
_p('</Project>')
end
-----------------------------------------------------------------------------
-- Everything below this point is a candidate for deprecation
-----------------------------------------------------------------------------
--
-- The first portion of the filters file assigns unique IDs to each
-- directory or virtual group. Would be cool if we could automatically
-- map vpaths like "**.h" to an <Extensions>h</Extensions> element.
--
function vc2010.filters_uniqueidentifiers(prj)
local filters = {}
local numFilters = 0
for file in project.eachfile(prj) do
local fullpath = ""
-- split the file's path into it's component parts
local folders = string.explode(file.fullpath, "/", true)
for i = 1, #folders - 1 do
if numFilters == 0 then
_p(1,'<ItemGroup>')
end
-- If this is a new folder, create a filter for it
fullpath = fullpath .. folders[i]
if not filters[fullpath] then
filters[fullpath] = true
_p(2, '<Filter Include="%s">', fullpath)
_p(3, '<UniqueIdentifier>{%s}</UniqueIdentifier>', os.uuid())
_p(2, '</Filter>')
end
fullpath = fullpath .. "\\"
numFilters = numFilters + 1
end
end
if numFilters > 0 then
_p(1,'</ItemGroup>')
end
end
--
-- The second portion of the filters file assigns filters to each source
-- code file, as needed. Section is one of "ClCompile", "ClInclude",
-- "ResourceCompile", or "None".
--
function vc2010.filters_filegroup(prj, group)
local files = vc2010.getfilegroup_ng(prj, group)
if #files > 0 then
_p(1,'<ItemGroup>')
for _, file in ipairs(files) do
local filter = path.getdirectory(file.fullpath)
if filter ~= "." then
_p(2,'<%s Include=\"%s\">', group, path.translate(file.fullpath))
_p(3,'<Filter>%s</Filter>', path.translate(filter))
_p(2,'</%s>', group)
else
_p(2,'<%s Include=\"%s\" />', group, path.translate(file.fullpath))
end
end
_p(1,'</ItemGroup>')
end
end
-----------------------------------------------------------------------------
-- Everything below this point is a candidate for deprecation
-----------------------------------------------------------------------------
--
-- The first portion of the filters file assigns unique IDs to each

View File

@ -14,5 +14,35 @@
--
function vc2010.generate_user_ng(prj)
print("C++ project user files are not yet implemented")
io.eol = "\r\n"
io.indent = " "
vc2010.header_ng()
for cfg in project.eachconfig(prj) do
_p(1,'<PropertyGroup %s>', vc2010.condition(cfg))
vc2010.debugsettings(cfg)
_p(1,'</PropertyGroup>')
end
_p('</Project>')
end
function vc2010.debugsettings(cfg)
if cfg.debugdir then
local dir = project.getrelative(cfg.project, cfg.debugdir)
_x(2,'<LocalDebuggerWorkingDirectory>%s</LocalDebuggerWorkingDirectory>', path.translate(dir))
_p(2,'<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>')
end
if #cfg.debugargs > 0 then
_x(2,'<LocalDebuggerCommandArguments>%s</LocalDebuggerCommandArguments>', table.concat(cfg.debugargs, " "))
end
if #cfg.debugenvs > 0 then
local envs = table.concat(cfg.debugenvs, "\n")
if cfg.flags.DebugEnvsInherit then
envs = envs .. "\n$(LocalDebuggerEnvironment)"
end
_p(2,'<LocalDebuggerEnvironment>%s</LocalDebuggerEnvironment>', envs)
if cfg.flags.DebugEnvsDontMerge then
_p(2,'<LocalDebuggerMergeEnvironment>false</LocalDebuggerMergeEnvironment>')
end
end
end

View File

@ -1,205 +0,0 @@
T.vs2010_flags = { }
local vs10_flags = T.vs2010_flags
local sln, prj
function vs10_flags.setup()
_ACTION = "vs2010"
sln = solution "MySolution"
configurations { "Debug" }
platforms {}
prj = project "MyProject"
language "C++"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
includedirs{"foo/bar"}
end
function vs10_flags.teardown()
sln = nil
prj = nil
end
local function get_buffer()
io.capture()
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
prj = premake.solution.getproject(sln, 1)
premake.vs2010_vcxproj(prj)
local buffer = io.endcapture()
return buffer
end
local debug_string = "Symbols"
local release_string = "Optimize"
--there is not an option for /Z7 OldStyle
--/ZI is not compatible with /clr or x64_64
--minimal Rebuild requires /Zi in x86_64
function vs10_flags.symbols_32BitBuild_DebugInformationFormat_setToEditAndContinue()
flags{"Symbols"}
platforms{'x32'}
local buffer = get_buffer()
test.string_contains(buffer,'<DebugInformationFormat>EditAndContinue</DebugInformationFormat>')
end
function vs10_flags.symbols_64BitBuild_DebugInformationFormat_setToProgramDatabase()
flags{"Symbols"}
platforms{"x64"}
local buffer = get_buffer()
test.string_contains(buffer,'<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>')
end
function vs10_flags.symbolsAndNoEditAndContinue_DebugInformationFormat_setToProgramDatabase()
flags{"Symbols","NoEditAndContinue"}
local buffer = get_buffer()
test.string_contains(buffer,'<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>')
end
function vs10_flags.symbolsAndRelease_DebugInformationFormat_setToProgramDatabase()
flags{"Symbols",release_string}
local buffer = get_buffer()
test.string_contains(buffer,'<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>')
end
function vs10_flags.symbolsManaged_DebugInformationFormat_setToProgramDatabase()
flags{"Symbols","Managed"}
local buffer = get_buffer()
test.string_contains(buffer,'<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>')
end
function vs10_flags.noSymbols_DebugInformationFormat_blockIsEmpty()
local buffer = get_buffer()
test.string_contains(buffer,'<DebugInformationFormat></DebugInformationFormat>')
end
function vs10_flags.noManifest_GenerateManifest_setToFalse()
flags{"NoManifest"}
local buffer = get_buffer()
test.string_contains(buffer,'<GenerateManifest Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'Debug|Win32\'">false</GenerateManifest>')
end
function vs10_flags.noSymbols_bufferDoesNotContainprogramDataBaseFile()
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<Link>.*<ProgramDataBaseFileName>.*</Link>')
end
function vs10_flags.symbols_bufferContainsprogramDataBaseFile()
flags{"Symbols"}
local buffer = get_buffer()
test.string_contains(buffer,'<ClCompile>.*<ProgramDataBaseFileName>%$%(OutDir%)MyProject%.pdb</ProgramDataBaseFileName>.*</ClCompile>')
end
function vs10_flags.WithOutManaged_bufferContainsKeywordWin32Proj()
local buffer = get_buffer()
test.string_contains(buffer,'<PropertyGroup Label="Globals">.*<Keyword>Win32Proj</Keyword>.*</PropertyGroup>')
end
function vs10_flags.WithOutManaged_bufferDoesNotContainKeywordManagedCProj()
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<PropertyGroup Label="Globals">.*<Keyword>ManagedCProj</Keyword>.*</PropertyGroup>')
end
T.vs2010_managedFlag = { }
local vs10_managedFlag = T.vs2010_managedFlag
local function vs10_managedFlag_setOnProject()
local sln = solution "Sol"
configurations { "Debug" }
language "C++"
kind "ConsoleApp"
local prj = project "Prj"
flags {"Managed"}
return sln,prj
end
local function get_managed_buffer(sln,prj)
io.capture()
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
prj = premake.solution.getproject(sln, 1)
premake.vs2010_vcxproj(prj)
local buffer = io.endcapture()
return buffer
end
function vs10_managedFlag.setup()
end
function vs10_managedFlag.managedSetOnProject_CLRSupport_setToTrue()
local sln, prj = vs10_managedFlag_setOnProject()
local buffer = get_managed_buffer(sln,prj)
test.string_contains(buffer,
'<PropertyGroup Condition=".*" Label="Configuration">'
..'.*<CLRSupport>true</CLRSupport>'
..'.*</PropertyGroup>')
end
function vs10_managedFlag.globals_bufferContainsKeywordManagedCProj()
local sln, prj = vs10_managedFlag_setOnProject()
local buffer = get_managed_buffer(sln,prj)
test.string_contains(buffer,'<PropertyGroup Label="Globals">.*<Keyword>ManagedCProj</Keyword>.*</PropertyGroup>')
end
function vs10_managedFlag.globals_bufferDoesNotContainKeywordWin32Proj()
local sln, prj = vs10_managedFlag_setOnProject()
local buffer = get_managed_buffer(sln,prj)
test.string_does_not_contain(buffer,'<PropertyGroup Label="Globals">.*<Keyword>Win32Proj</Keyword>.*</PropertyGroup>')
end
function vs10_managedFlag.globals_FrameworkVersion_setToV4()
local sln, prj = vs10_managedFlag_setOnProject()
local buffer = get_managed_buffer(sln,prj)
test.string_contains(buffer,'<PropertyGroup Label="Globals">.*<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>.*</PropertyGroup>')
end
function vs10_managedFlag.withFloatFast_FloatingPointModelNotFoundInBuffer()
local sln, prj = vs10_managedFlag_setOnProject()
flags {"FloatStrict"}
local buffer = get_managed_buffer(sln,prj)
test.string_does_not_contain(buffer,'<FloatingPointModel>.*</FloatingPointModel>')
end
function vs10_managedFlag.debugWithStaticRuntime_flagIgnoredAndRuntimeSetToMDd()
local sln, prj = vs10_managedFlag_setOnProject()
flags {"Symbols","StaticRuntime"}
local buffer = get_managed_buffer(sln,prj)
test.string_contains(buffer,'<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>')
end
function vs10_managedFlag.notDebugWithStaticRuntime_flagIgnoredAndRuntimeSetToMD()
local sln, prj = vs10_managedFlag_setOnProject()
flags {"StaticRuntime"}
local buffer = get_managed_buffer(sln,prj)
test.string_contains(buffer,'<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>')
end
function vs10_managedFlag.noOptimisationFlag_basicRuntimeChecksNotFoundInBuffer()
local sln, prj = vs10_managedFlag_setOnProject()
local buffer = get_managed_buffer(sln,prj)
test.string_does_not_contain(buffer,'<BasicRuntimeChecks>.*</BasicRuntimeChecks>')
end
function vs10_managedFlag.applictionWithOutWinMain_EntryPointSymbolNotFoundInBuffer()
local sln, prj = vs10_managedFlag_setOnProject()
local buffer = get_managed_buffer(sln,prj)
test.string_does_not_contain(buffer,'<EntryPointSymbol>.*</EntryPointSymbol>')
end

View File

@ -444,3 +444,82 @@
<RuntimeTypeInfo>false</RuntimeTypeInfo>
]]
end
--
-- On Win32 builds, use the Edit-and-Continue debug information format.
--
function suite.debugFormat_onWin32()
flags "Symbols"
architecture "x32"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
]]
end
--
-- Edit-and-Continue is not support on 64-bit builds.
--
function suite.debugFormat_onWin64()
flags "Symbols"
architecture "x64"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
]]
end
--
-- Check the handling of the NoEditAndContinue flag.
--
function suite.debugFormat_onNoEditAndContinue()
flags { "Symbols", "NoEditAndContinue" }
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
]]
end
--
-- Edit-and-Continue is not supported for optimized builds.
--
function suite.debugFormat_onOptimizedBuild()
flags { "Symbols", "Optimize" }
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
]]
end
--
-- Edit-and-Continue is not supported for Managed builds.
--
function suite.debugFormat_onManagedCode()
flags { "Symbols", "Managed" }
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
]]
end

View File

@ -0,0 +1,88 @@
--
-- tests/actions/vstudio/vc2010/test_debug_settings.lua
-- Validate handling of the working directory for debugging.
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
--
T.vstudio_vs2010_debug_settings = { }
local suite = T.vstudio_vs2010_debug_settings
local vc2010 = premake.vstudio.vc2010
local project = premake5.project
--
-- Setup
--
local sln, prj, cfg
function suite.setup()
sln, prj = test.createsolution()
end
local function prepare()
cfg = project.getconfig(prj, "Debug")
vc2010.debugsettings(cfg)
end
--
-- If no debug directory is set, nothing should be output.
--
function suite.noOutput_onNoDebugDir()
prepare()
test.capture [[
]]
end
--
-- The debug directory should specified relative to the project location.
--
function suite.debugDirectory_isProjectRelative()
debugdir "bin/debug"
prepare()
test.capture [[
<LocalDebuggerWorkingDirectory>bin\debug</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
]]
end
--
-- Verify handling of debug arguments.
--
function suite.debuggerCommandArgs_onDebugArgs()
debugargs { "arg1", "arg2" }
prepare()
test.capture [[
<LocalDebuggerCommandArguments>arg1 arg2</LocalDebuggerCommandArguments>
]]
end
--
-- Check the handling of debug environment variables.
--
function suite.localDebuggerEnv_onDebugEnv()
debugenvs { "key=value" }
prepare()
test.capture [[
<LocalDebuggerEnvironment>key=value</LocalDebuggerEnvironment>
]]
end
--
-- Multiple environment variables should be separated by a "\n" sequence.
--
function suite.localDebuggerEnv_onDebugEnv()
debugenvs { "key=value", "foo=bar" }
prepare()
test.capture [[
<LocalDebuggerEnvironment>key=value
foo=bar</LocalDebuggerEnvironment>
]]
end

View File

@ -1,96 +0,0 @@
--
-- tests/actions/vstudio/vc2010/test_debugdir.lua
-- Validate handling of the working directory for debugging.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.vstudio_vs2010_debugdir = { }
local suite = T.vstudio_vs2010_debugdir
local vc2010 = premake.vstudio.vc2010
--
-- Setup
--
local sln, prj
function suite.setup()
sln = test.createsolution()
end
local function prepare()
premake.bake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
vc2010.debugdir(prj)
end
--
-- Tests
--
function suite.PrintsNothing_OnDebugDirSet()
prepare()
test.capture [[
]]
end
function suite.IsFormattedCorrectly_OnRelativePath()
debugdir "bin/debug"
prepare()
test.capture [[
<LocalDebuggerWorkingDirectory>bin\debug</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
]]
end
function suite.Arguments()
debugargs { "arg1", "arg2" }
prepare()
test.capture [[
<LocalDebuggerCommandArguments>arg1 arg2</LocalDebuggerCommandArguments>
]]
end
T.vs2010_debug_environment = { }
local vs10_debug_environment = T.vs2010_debug_environment
local vs2010 = premake.vstudio.vc2010
function vs10_debug_environment.config_noDebugEnvsTable_bufferDoesNotContainLocalDebuggerEnvironment()
vs2010.debugenvs( {flags={}} )
test.string_does_not_contain(io.endcapture(),'<LocalDebuggerEnvironment>')
end
function vs10_debug_environment.config_NoneEmtpyDebugEnvTable_bufferContainsLocalDebuggerEnvironment()
vs2010.debugenvs({flags={},debugenvs ={'key=value'}} )
test.string_contains(io.endcapture(),'<LocalDebuggerEnvironment>')
end
function vs10_debug_environment.format_listContainsOneEntry_openTagKeyValuePairCloseTag()
vs2010.debugenvs({flags={},debugenvs ={'key=value'}} )
test.string_contains(io.endcapture(),'<LocalDebuggerEnvironment>key=value</LocalDebuggerEnvironment>')
end
function vs10_debug_environment.format_listContainsTwoEntries_openTagFirstPairNewLineSecondPairCloseTag()
vs2010.debugenvs({flags={},debugenvs ={'key=value','foo=bar'}} )
test.string_contains(io.endcapture(),'<LocalDebuggerEnvironment>key=value\nfoo=bar</LocalDebuggerEnvironment>')
end
function vs10_debug_environment.flags_withOutEnvironmentArgsInherit_doesNotContainLocalDebuggerEnvironmentArg()
vs2010.debugenvs({flags={},environmentargs ={'key=value'}} )
test.string_does_not_contain(io.endcapture(),'%$%(LocalDebuggerEnvironment%)')
end
function vs10_debug_environment.flags_withDebugEnvsInherit_endsWithNewLineLocalDebuggerEnvironmentFollowedByClosedTag()
vs2010.debugenvs({flags={DebugEnvsInherit=1},debugenvs ={'key=value'}} )
test.string_contains(io.endcapture(),'\n%$%(LocalDebuggerEnvironment%)</LocalDebuggerEnvironment>')
end
function vs10_debug_environment.flags_withDebugEnvsDontMerge_localDebuggerMergeEnvironmentSetToFalse()
vs2010.debugenvs({flags={DebugEnvsDontMerge=1},debugenvs ={'key=value'}} )
test.string_contains(io.endcapture(),'<LocalDebuggerMergeEnvironment>false</LocalDebuggerMergeEnvironment>')
end

View File

@ -0,0 +1,116 @@
--
-- tests/actions/vstudio/vc2010/test_filter_ids.lua
-- Validate generation of filter unique identifiers.
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
--
T.vs2010_filter_ids = { }
local suite = T.vs2010_filter_ids
local vc2010 = premake.vstudio.vc2010
--
-- Setup/teardown
--
local sln, prj
local os_uuid
function suite.setup()
os_uuid = os.uuid
os.uuid = function() return "00112233-4455-6677-8888-99AABBCCDDEE" end
_ACTION = "vs2010"
sln = test.createsolution()
end
function suite.teardown()
os.uuid = os_uuid
end
local function prepare()
prj = premake.solution.getproject_ng(sln, 1)
vc2010.filters_uniqueidentifiers(prj)
end
--
-- Files in the root folder (the same one as the project) don't get identifiers.
--
function suite.groupIsEmpty_onOnlyRootFiles()
files { "hello.c", "goodbye.c" }
prepare()
test.isemptycapture()
end
--
-- Folders shared between multiple files should be reduced to a single identifier.
--
function suite.singleIdentifier_onMultipleFilesInSameFolder()
files { "src/hello.c", "src/goodbye.c" }
prepare()
test.capture [[
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
--
-- Nested folders should each get their own unique identifier.
--
function suite.multipleIdentifiers_forNestedFolders()
files { "src/hello.c", "src/departures/goodbye.c" }
prepare()
test.capture [[
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
<Filter Include="src\departures">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
--
-- If a file has a virtual path, that should be used to build the filters.
--
function suite.filterUsesVpath_onVpath()
files { "hello.c", "goodbye.c" }
vpaths { ["Source Files"] = "**.c" }
prepare()
test.capture [[
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
function suite.filterUsesVpath_onMultipleVpaths()
files { "hello.h", "goodbye.c" }
vpaths { ["Source Files"] = "*.c", ["Header Files"] = "*.h" }
prepare()
test.capture [[
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end

View File

@ -1,7 +1,7 @@
--
-- tests/actions/vstudio/vc2010/test_filters.lua
-- Validate generation of filter blocks in Visual Studio 2010 C/C++ projects.
-- Copyright (c) 2011 Jason Perkins and the Premake project
-- Validate generation of file filter blocks in Visual Studio 2010 C/C++ projects.
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
--
T.vs2010_filters = { }
@ -14,111 +14,61 @@
--
local sln, prj
local os_uuid
function suite.setup()
os_uuid = os.uuid
os.uuid = function() return "00112233-4455-6677-8888-99AABBCCDDEE" end
_ACTION = "vs2010"
sln, prj = test.createsolution()
end
function suite.teardown()
os.uuid = os_uuid
sln = test.createsolution()
end
local function prepare()
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
local function prepare(group)
prj = premake.solution.getproject_ng(sln, 1)
vc2010.filters_filegroup(prj, group)
end
--
-- Filter identifiers sections
-- Check contents of the different file groups.
--
function suite.UniqueIdentifiers_IsEmpty_OnRootFilesOnly()
function suite.itemGroup_onClInclude()
files { "hello.c", "hello.h", "hello.rc", "hello.txt" }
prepare("ClInclude")
test.capture [[
<ItemGroup>
<ClInclude Include="hello.h" />
</ItemGroup>
]]
end
function suite.itemGroup_onResourceSection()
files { "hello.c", "hello.h", "hello.rc", "hello.txt" }
prepare("ResourceCompile")
test.capture [[
<ItemGroup>
<ResourceCompile Include="hello.rc" />
</ItemGroup>
]]
end
function suite.itemGroup_onNoneSection()
files { "hello.c", "hello.h", "hello.rc", "hello.txt" }
prepare("None")
test.capture [[
<ItemGroup>
<None Include="hello.txt" />
</ItemGroup>
]]
end
--
-- Files located at the root (in the same folder as the project) do not
-- need a filter identifier.
--
function suite.noFilter_onRootFiles()
files { "hello.c", "goodbye.c" }
prepare()
vc2010.filteridgroup(prj)
test.isemptycapture()
end
function suite.UniqueIdentifiers_MergeCommonSubfolders()
files { "src/hello.c", "src/goodbye.c" }
prepare()
vc2010.filteridgroup(prj)
test.capture [[
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
function suite.UniqueIdentifiers_ListAllSubfolders()
files { "src/hello.c", "src/departures/goodbye.c" }
prepare()
vc2010.filteridgroup(prj)
test.capture [[
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
<Filter Include="src\departures">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
function suite.UniqueIdentifiers_ListVpaths()
files { "hello.c", "goodbye.c" }
vpaths { ["Source Files"] = "**.c" }
prepare()
vc2010.filteridgroup(prj)
test.capture [[
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
function suite.UniqueIdentifiers_ListRealAndVpaths()
files { "hello.h", "goodbye.c" }
vpaths { ["Source Files"] = "*.c", ["Header Files"] = "*.h" }
prepare()
vc2010.filteridgroup(prj)
test.capture [[
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{00112233-4455-6677-8888-99AABBCCDDEE}</UniqueIdentifier>
</Filter>
</ItemGroup>
]]
end
--
-- File/filter assignment tests
--
function suite.FileFilters_NoFilter_OnRootFile()
files { "hello.c", "goodbye.c" }
prepare()
vc2010.filefiltergroup(prj, "ClCompile")
prepare("ClCompile")
test.capture [[
<ItemGroup>
<ClCompile Include="hello.c" />
@ -127,11 +77,13 @@
]]
end
--
-- Check the filter with a real path.
--
function suite.FileFilters_NoFilter_OnRealPath()
function suite.filter_onRealPath()
files { "src/hello.c" }
prepare()
vc2010.filefiltergroup(prj, "ClCompile")
prepare("ClCompile")
test.capture [[
<ItemGroup>
<ClCompile Include="src\hello.c">
@ -141,12 +93,14 @@
]]
end
--
-- Check the filter with a virtual path.
--
function suite.FileFilters_HasFilter_OnVpath()
function suite.filter_onVpath()
files { "src/hello.c" }
vpaths { ["Source Files"] = "**.c" }
prepare()
vc2010.filefiltergroup(prj, "ClCompile")
prepare("ClCompile")
test.capture [[
<ItemGroup>
<ClCompile Include="src\hello.c">
@ -155,39 +109,3 @@
</ItemGroup>
]]
end
function suite.FileFilters_OnIncludeSection()
files { "hello.c", "hello.h", "hello.rc", "hello.txt" }
prepare()
vc2010.filefiltergroup(prj, "ClInclude")
test.capture [[
<ItemGroup>
<ClInclude Include="hello.h" />
</ItemGroup>
]]
end
function suite.FileFilters_OnResourceSection()
files { "hello.c", "hello.h", "hello.rc", "hello.txt" }
prepare()
vc2010.filefiltergroup(prj, "ResourceCompile")
test.capture [[
<ItemGroup>
<ResourceCompile Include="hello.rc" />
</ItemGroup>
]]
end
function suite.FileFilters_OnNoneSection()
files { "hello.c", "hello.h", "hello.rc", "hello.txt" }
prepare()
vc2010.filefiltergroup(prj, "None")
test.capture [[
<ItemGroup>
<None Include="hello.txt" />
</ItemGroup>
]]
end

View File

@ -233,4 +233,19 @@
</Lib>
]]
end
--
-- Enable reference optimizing if Optimize flag is specified.
--
function suite.optimizeReferences_onOptimizeFlag()
flags { "Optimize" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
]]
end

View File

@ -1,210 +0,0 @@
--
-- tests/actions/vstudio/vc2010/test_link_settings.lua
-- Validate linker settings in Visual Studio 2010 C/C++ projects.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.vstudio_vs2010_link_settings = { }
local suite = T.vstudio_vs2010_link_settings
local vc2010 = premake.vstudio.vc2010
--
-- Setup
--
local sln, prj, cfg
function suite.setup()
_ACTION = "vs2010"
sln, prj = test.createsolution()
end
local function prepare(platform)
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
cfg = premake.getconfig(prj, "Debug", platform)
vc2010.link(cfg)
end
--
-- Check the basic element structure for a console application.
--
function suite.writesCorrectSubsystem_onConsoleApp()
kind "ConsoleApp"
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
]]
end
--
-- Check the basic element structure for a windowed application.
--
function suite.writesCorrectSubsystem_onWindowedApp()
kind "WindowedApp"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
]]
end
--
-- Check the basic element structure for a shared library.
--
function suite.writesCorrectSubsystem_onSharedLib()
kind "SharedLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.dll</OutputFile>
<ImportLibrary>MyProject.lib</ImportLibrary>
</Link>
]]
end
--
-- Check the basic element structure for a static library.
--
function suite.writesCorrectSubsystem_onStaticLib()
kind "StaticLib"
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
]]
end
--
-- Check the structure of the additional library directories element.
--
function suite.additionalLibraryDirectories()
libdirs { "include/GL", "include/lua" }
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<AdditionalLibraryDirectories>include\GL;include\lua;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
]]
end
--
-- Enable debug information if the Symbols flag is specified.
--
function suite.generateDebugInformation_onSymbolsFlag()
flags { "Symbols" }
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
]]
end
--
-- Enable reference optimizing if Optimize flag is specified.
--
function suite.optimizeReferences_onOptimizeFlag()
flags { "Optimize" }
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
]]
end
--
-- Skip the entry point override if the WinMain flag is specified.
--
function suite.noEntryPointElement_onWinMainFlag()
flags { "WinMain" }
prepare()
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
</Link>
]]
end
--
-- Use the x86 target for Premake's x32 platform.
--
function suite.writesCorrectTarget_onX32Platform()
platforms "x32"
prepare("x32")
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
<TargetMachine>MachineX86</TargetMachine>
</Link>
]]
end
--
-- Use the x64 target for Premake's x64 platform.
--
function suite.writesCorrectTarget_onX64Platform()
platforms { "x64" }
prepare("x64")
test.capture [[
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OutputFile>$(OutDir)MyProject.exe</OutputFile>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
<TargetMachine>MachineX64</TargetMachine>
</Link>
]]
end

View File

@ -1,60 +0,0 @@
--
-- tests/actions/vstudio/vc2010/test_mfc.lua
-- Validate MFC support in Visual Studio 2010 C/C++ projects.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
T.vstudio_vs2010_mfc = { }
local suite = T.vstudio_vs2010_mfc
local vc2010 = premake.vstudio.vc2010
--
-- Setup
--
local sln, prj, cfg
function suite.setup()
_ACTION = "vs2010"
sln, prj = test.createsolution()
end
local function prepare(platform)
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
cfg = premake.getconfig(prj, "Debug", platform)
vc2010.configurationPropertyGroup(cfg, sln.vstudio_configs[1])
end
--
-- When MFC is enabled, it should match the runtime library linking
-- method (static or dynamic).
--
function suite.useOfMfc_isDynamic_onSharedRuntime()
flags { "MFC" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
]]
end
function suite.useOfMfc_isStatic_onStaticRuntime()
flags { "MFC", "StaticRuntime" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
]]
end

View File

@ -7,7 +7,6 @@
T.vstudio_vs2010_project_refs = { }
local suite = T.vstudio_vs2010_project_refs
local vc2010 = premake.vstudio.vc2010
local project = premake5.project
--
@ -56,3 +55,23 @@
]]
end
--
-- Project references should always be specified relative to the
-- project doing the referencing.
--
function suite.referencesAreRelative_onDifferentProjectLocation()
links { "MyProject" }
location "build/MyProject2"
project("MyProject")
location "build/MyProject"
prepare()
test.capture [[
<ItemGroup>
<ProjectReference Include="..\MyProject\MyProject.vcxproj">
<Project>{00112233-4455-6677-8888-99AABBCCDDEE}</Project>
</ProjectReference>
</ItemGroup>
]]
end

View File

@ -1,7 +1,7 @@
--
-- tests/premake4.lua
-- Automated test suite for Premake 4.x
-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
-- Copyright (c) 2008-2012 Jason Perkins and the Premake project
--
dofile("testfx.lua")
@ -81,7 +81,6 @@
-- Visual Studio tests
dofile("test_vs2002_sln.lua")
dofile("test_vs2003_sln.lua")
dofile("actions/vstudio/test_vs2010_flags.lua")
-- Visual Studio 2002-2003 C# projects
dofile("actions/vstudio/cs2002/test_files.lua")
@ -116,14 +115,13 @@
-- Visual Studio 2010 C/C++ projects
dofile("actions/vstudio/vc2010/test_compile_settings.lua")
dofile("actions/vstudio/vc2010/test_config_props.lua")
dofile("actions/vstudio/vc2010/test_debugdir.lua")
dofile("actions/vstudio/vc2010/test_debug_settings.lua")
dofile("actions/vstudio/vc2010/test_globals.lua")
dofile("actions/vstudio/vc2010/test_header.lua")
dofile("actions/vstudio/vc2010/test_files.lua")
dofile("actions/vstudio/vc2010/test_filter_ids.lua")
dofile("actions/vstudio/vc2010/test_filters.lua")
dofile("actions/vstudio/vc2010/test_link_settings.lua")
dofile("actions/vstudio/vc2010/test_link.lua")
dofile("actions/vstudio/vc2010/test_mfc.lua")
dofile("actions/vstudio/vc2010/test_output_props.lua")
dofile("actions/vstudio/vc2010/test_project_configs.lua")
dofile("actions/vstudio/vc2010/test_project_refs.lua")