removes invalid test in vs2010 filters

refactored moving more code in the function "if_config_and_platform" for vs2010
added write_file_compile_block which takes care of pre compiled headers and fixes Bug 3095274
Did lines ending changes in vs2010_vcxproj.lua and test_vs2010_vcxproj.lua which is why the changeset is bigger??
This commit is contained in:
liamDevine 2010-10-30 11:55:40 +01:00
parent 51abe69396
commit 3f0b545424
4 changed files with 714 additions and 655 deletions

View File

@ -27,7 +27,7 @@
* Bug 3016050: {"../Dir/file1.c","../../Dir/file2.c"} breaks Xcode (Stephane)
* Bug 3015312: Makefiles are not quoted correctly
* Bug 3097868: Patch 3076517 premake_rev465.patch. Removes relative paths from vs2010 filters (Robert Konrad)
* Bug 3095274: vs2010 PCH implemented and has the same behaviour as previous VS versions
-------
4.2.1

File diff suppressed because it is too large Load Diff

View File

@ -260,16 +260,6 @@
local buffer = get_buffer()
test.string_contains(buffer,'<None')
end
--function is no longer used in code
function vs10_filters.tableOfFileFilters_filterContainsDots_bufferContainsTheEntry()
t =
{
'bar\\baz\\foo.bar.h'
}
local result = vs10_helpers.table_of_filters(t)
test.isequal(2,#result)
end
function vs10_filters.tableOfFileFilters_filterContainsDots_resultsLengthIsThree()
t =

View File

@ -1,11 +1,15 @@
T.vs2010_vcxproj = { }
local vs10_vcxproj = T.vs2010_vcxproj
local include_directory = "bar/foo"
local include_directory2 = "baz/foo"
local debug_define = "I_AM_ALIVE_NUMBER_FIVE"
local vs10_helpers = premake.vstudio.vs10_helpers
local include_directory = "bar/foo"
local include_directory2 = "baz/foo"
local debug_define = "I_AM_ALIVE_NUMBER_FIVE"
local vs10_helpers = premake.vstudio.vs10_helpers
local sln, prj
function vs10_vcxproj.teardown()
sln = nil
prj = nil
end
function vs10_vcxproj.setup()
_ACTION = "vs2010"
@ -17,31 +21,30 @@
language "C++"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
includedirs
{
include_directory,
include_directory2
}
files
{
"foo/dummyHeader.h",
"foo/dummySource.cpp",
"../src/host/*h",
"../src/host/*.c",
"dummyResourceScript.rc"
}
configuration("Release")
flags {"Optimize"}
}
files
{
"foo/dummyHeader.h",
"foo/dummySource.cpp",
"../src/host/*h",
"../src/host/*.c",
"dummyResourceScript.rc"
}
configuration("Release")
flags {"Optimize"}
links{"foo","bar"}
configuration("Debug")
defines {debug_define}
configuration("Debug")
defines {debug_define}
links{"foo_d"}
end
end
local function get_buffer()
io.capture()
@ -138,7 +141,7 @@
test.string_contains(buffer,'<ClCompile>.*</ClCompile>')
end
function vs10_vcxproj.containsAdditionalOptions()
function vs10_vcxproj.containsAdditionalOptions()
buildoptions {"/Gm"}
local buffer = get_buffer()
test.string_contains(buffer,'<AdditionalOptions>/Gm %%%(AdditionalOptions%)</AdditionalOptions>')
@ -186,188 +189,221 @@
function vs10_vcxproj.releaseHasStringPoolingOn()
local buffer = get_buffer()
test.string_contains(buffer,cl_compile_string('Release')..'.*<StringPooling>true</StringPooling>')
end
function vs10_vcxproj.hasItemGroupSection()
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*</ItemGroup>')
end
function vs10_vcxproj.fileExtension_extEqualH()
local ext = vs10_helpers.get_file_extension('foo.h')
test.isequal('h', ext)
end
function vs10_vcxproj.fileExtension_containsTwoDots_extEqualH()
local ext = vs10_helpers.get_file_extension('foo.bar.h')
test.isequal('h', ext)
end
function vs10_vcxproj.fileExtension_alphaNumeric_extEqualOneH()
local ext = vs10_helpers.get_file_extension('foo.1h')
test.isequal('1h', ext)
end
function vs10_vcxproj.fileExtension_alphaNumericWithUnderscore_extEqualOne_H()
local ext = vs10_helpers.get_file_extension('foo.1_h')
test.isequal('1_h', ext)
end
function vs10_vcxproj.fileExtension_containsHyphen_extEqualHHyphenH()
local ext = vs10_helpers.get_file_extension('foo.h-h')
test.isequal('h-h', ext)
end
function vs10_vcxproj.fileExtension_containsMoreThanOneDot_extEqualOneH()
local ext = vs10_helpers.get_file_extension('foo.bar.h')
test.isequal('h', ext)
end
local function SortAndReturnSortedInputFiles(input)
local sorted =
{
ClInclude ={},
ClCompile ={},
None ={},
ResourceCompile ={}
}
vs10_helpers.sort_input_files(input,sorted)
return sorted
end
function vs10_vcxproj.sortFile_headerFile_SortedClIncludeEqualToFile()
local file = {"bar.h"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.ClInclude)
end
function vs10_vcxproj.sortFile_srcFile_SortedClCompileEqualToFile()
local file = {"b.cxx"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.ClCompile)
end
function vs10_vcxproj.sortFile_notRegistered_SortedNoneEqualToFile()
local file = {"foo.bar.00h"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.None)
end
function vs10_vcxproj.sortFile_resourceScript_resourceCompileEqualToFile()
local file = {"foo.rc"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.ResourceCompile)
end
function vs10_vcxproj.itemGroupSection_hasResourceCompileSection()
--for some reason this does not work here and it needs to be in
--the project setting at the top ?
--files{"dummyResourceScript.rc"}
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*<ResourceCompile.*</ItemGroup>')
end
function vs10_vcxproj.itemGroupSection_hasHeaderListed()
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*<ClInclude Include="foo\\dummyHeader%.h" />.*</ItemGroup>')
end
function vs10_vcxproj.checkProjectConfigurationOpeningTag_hasACloseingAngleBracket()
local buffer = get_buffer()
test.string_contains(buffer,'<ProjectConfiguration Include="Debug|Win32">')
end
function vs10_vcxproj.postBuildEvent_isPresent()
postbuildcommands { "doSomeThing" }
local buffer = get_buffer()
test.string_contains(buffer,'<PostBuildEvent>.*<Command>.*</Command>.*</PostBuildEvent>')
end
function vs10_vcxproj.postBuildEvent_containsCorrectInformationBetweenCommandTag()
postbuildcommands { "doSomeThing" }
local buffer = get_buffer()
test.string_contains(buffer,'<PostBuildEvent>.*<Command>doSomeThing</Command>.*</PostBuildEvent>')
end
function vs10_vcxproj.postBuildEvent_eventEncloseByQuotes_containsCorrectInformationBetweenCommandTag()
postbuildcommands { "\"doSomeThing\"" }
local buffer = get_buffer()
test.string_contains(buffer,'<PostBuildEvent>.*<Command>&quot;doSomeThing&quot;</Command>.*</PostBuildEvent>')
end
function vs10_vcxproj.outDir_directorySuppliedIsNotSlashPostFixed_bufferContainsOutDirSlashPostFixed()
targetdir("dir")
local buffer = get_buffer()
test.string_contains(buffer,'<OutDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\.*\'">dir\\</OutDir>')
end
--postfixed directory slashes are removed by default
--yet these following two tests are to ensure if this behaviour is changed they will fail
function vs10_vcxproj.outDir_directorySuppliedWhichIsForwardSlashPostFixed_bufferContainsOutDirSlashPostFixed()
targetdir("dir/")
local buffer = get_buffer()
test.string_contains(buffer,'<OutDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\.*\'">dir\\</OutDir>')
end
function vs10_vcxproj.outDir_directorySuppliedWhichIsWindowsSlashPostFixed_bufferContainsOutDirSlashPostFixed()
targetdir("dir\\")
local buffer = get_buffer()
test.string_contains(buffer,'<OutDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\.*\'">dir\\</OutDir>')
end
function vs10_vcxproj.objectDir_directorySuppliedIsNotSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed()
objdir ("dir")
local buffer = get_buffer()
test.string_contains(buffer,'<IntDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'.*\'">dir\\</IntDir>')
end
--postfixed directory slashes are removed by default
--yet these following two tests are to ensure if this behaviour is changed they will fail
function vs10_vcxproj.objectDir_directorySuppliedWhichIsSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed()
objdir ("dir/")
local buffer = get_buffer()
test.string_contains(buffer,'<IntDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'.*\'">dir\\</IntDir>')
end
function vs10_vcxproj.objectDir_directorySuppliedWhichIsWindowsSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed()
objdir ("dir\\")
local buffer = get_buffer()
test.string_contains(buffer,'<IntDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'.*\'">dir\\</IntDir>')
end
function vs10_vcxproj.targetName()
configuration("Debug")
targetname ("foo_d")
local buffer = get_buffer()
test.string_contains(buffer,'<TargetName Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'Debug|Win32\'">foo_d</TargetName>')
end
function vs10_vcxproj.noExtraWarnings_bufferDoesNotContainSmallerTypeCheck()
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<SmallerTypeCheck>')
end
function vs10_vcxproj.debugAndExtraWarnings_bufferContainsSmallerTypeCheck()
configuration("Debug")
flags {"ExtraWarnings"}
local buffer = get_buffer()
test.string_contains(buffer,'<SmallerTypeCheck>true</SmallerTypeCheck>')
end
function vs10_vcxproj.releaseAndExtraWarnings_bufferDoesNotContainSmallerTypeCheck()
configuration("Release")
flags {"ExtraWarnings"}
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<SmallerTypeCheck>')
end
function vs10_vcxproj.onlyOneProjectConfigurationBlockWhenMultipleConfigs()
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<ItemGroup Label="ProjectConfigurations">.*<ItemGroup Label="ProjectConfigurations">')
end
function vs10_vcxproj.languageC_bufferContainsCompileAsC()
language "C"
local buffer = get_buffer()
test.string_contains(buffer,'<CompileAs>CompileAsC</CompileAs>')
end
end
function vs10_vcxproj.hasItemGroupSection()
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*</ItemGroup>')
end
function vs10_vcxproj.fileExtension_extEqualH()
local ext = vs10_helpers.get_file_extension('foo.h')
test.isequal('h', ext)
end
function vs10_vcxproj.fileExtension_containsTwoDots_extEqualH()
local ext = vs10_helpers.get_file_extension('foo.bar.h')
test.isequal('h', ext)
end
function vs10_vcxproj.fileExtension_alphaNumeric_extEqualOneH()
local ext = vs10_helpers.get_file_extension('foo.1h')
test.isequal('1h', ext)
end
function vs10_vcxproj.fileExtension_alphaNumericWithUnderscore_extEqualOne_H()
local ext = vs10_helpers.get_file_extension('foo.1_h')
test.isequal('1_h', ext)
end
function vs10_vcxproj.fileExtension_containsHyphen_extEqualHHyphenH()
local ext = vs10_helpers.get_file_extension('foo.h-h')
test.isequal('h-h', ext)
end
function vs10_vcxproj.fileExtension_containsMoreThanOneDot_extEqualOneH()
local ext = vs10_helpers.get_file_extension('foo.bar.h')
test.isequal('h', ext)
end
local function SortAndReturnSortedInputFiles(input)
local sorted =
{
ClInclude ={},
ClCompile ={},
None ={},
ResourceCompile ={}
}
vs10_helpers.sort_input_files(input,sorted)
return sorted
end
function vs10_vcxproj.sortFile_headerFile_SortedClIncludeEqualToFile()
local file = {"bar.h"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.ClInclude)
end
function vs10_vcxproj.sortFile_srcFile_SortedClCompileEqualToFile()
local file = {"b.cxx"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.ClCompile)
end
function vs10_vcxproj.sortFile_notRegistered_SortedNoneEqualToFile()
local file = {"foo.bar.00h"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.None)
end
function vs10_vcxproj.sortFile_resourceScript_resourceCompileEqualToFile()
local file = {"foo.rc"}
local sorted = SortAndReturnSortedInputFiles(file)
test.isequal(file, sorted.ResourceCompile)
end
function vs10_vcxproj.itemGroupSection_hasResourceCompileSection()
--for some reason this does not work here and it needs to be in
--the project setting at the top ?
--files{"dummyResourceScript.rc"}
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*<ResourceCompile.*</ItemGroup>')
end
function vs10_vcxproj.itemGroupSection_hasHeaderListed()
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*<ClInclude Include="foo\\dummyHeader%.h" />.*</ItemGroup>')
end
function vs10_vcxproj.checkProjectConfigurationOpeningTag_hasACloseingAngleBracket()
local buffer = get_buffer()
test.string_contains(buffer,'<ProjectConfiguration Include="Debug|Win32">')
end
function vs10_vcxproj.postBuildEvent_isPresent()
postbuildcommands { "doSomeThing" }
local buffer = get_buffer()
test.string_contains(buffer,'<PostBuildEvent>.*<Command>.*</Command>.*</PostBuildEvent>')
end
function vs10_vcxproj.postBuildEvent_containsCorrectInformationBetweenCommandTag()
postbuildcommands { "doSomeThing" }
local buffer = get_buffer()
test.string_contains(buffer,'<PostBuildEvent>.*<Command>doSomeThing</Command>.*</PostBuildEvent>')
end
function vs10_vcxproj.postBuildEvent_eventEncloseByQuotes_containsCorrectInformationBetweenCommandTag()
postbuildcommands { "\"doSomeThing\"" }
local buffer = get_buffer()
test.string_contains(buffer,'<PostBuildEvent>.*<Command>&quot;doSomeThing&quot;</Command>.*</PostBuildEvent>')
end
function vs10_vcxproj.outDir_directorySuppliedIsNotSlashPostFixed_bufferContainsOutDirSlashPostFixed()
targetdir("dir")
local buffer = get_buffer()
test.string_contains(buffer,'<OutDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\.*\'">dir\\</OutDir>')
end
--postfixed directory slashes are removed by default
--yet these following two tests are to ensure if this behaviour is changed they will fail
function vs10_vcxproj.outDir_directorySuppliedWhichIsForwardSlashPostFixed_bufferContainsOutDirSlashPostFixed()
targetdir("dir/")
local buffer = get_buffer()
test.string_contains(buffer,'<OutDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\.*\'">dir\\</OutDir>')
end
function vs10_vcxproj.outDir_directorySuppliedWhichIsWindowsSlashPostFixed_bufferContainsOutDirSlashPostFixed()
targetdir("dir\\")
local buffer = get_buffer()
test.string_contains(buffer,'<OutDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\.*\'">dir\\</OutDir>')
end
function vs10_vcxproj.objectDir_directorySuppliedIsNotSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed()
objdir ("dir")
local buffer = get_buffer()
test.string_contains(buffer,'<IntDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'.*\'">dir\\</IntDir>')
end
--postfixed directory slashes are removed by default
--yet these following two tests are to ensure if this behaviour is changed they will fail
function vs10_vcxproj.objectDir_directorySuppliedWhichIsSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed()
objdir ("dir/")
local buffer = get_buffer()
test.string_contains(buffer,'<IntDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'.*\'">dir\\</IntDir>')
end
function vs10_vcxproj.objectDir_directorySuppliedWhichIsWindowsSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed()
objdir ("dir\\")
local buffer = get_buffer()
test.string_contains(buffer,'<IntDir Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'.*\'">dir\\</IntDir>')
end
function vs10_vcxproj.targetName()
configuration("Debug")
targetname ("foo_d")
local buffer = get_buffer()
test.string_contains(buffer,'<TargetName Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'Debug|Win32\'">foo_d</TargetName>')
end
function vs10_vcxproj.noExtraWarnings_bufferDoesNotContainSmallerTypeCheck()
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<SmallerTypeCheck>')
end
function vs10_vcxproj.debugAndExtraWarnings_bufferContainsSmallerTypeCheck()
configuration("Debug")
flags {"ExtraWarnings"}
local buffer = get_buffer()
test.string_contains(buffer,'<SmallerTypeCheck>true</SmallerTypeCheck>')
end
function vs10_vcxproj.releaseAndExtraWarnings_bufferDoesNotContainSmallerTypeCheck()
configuration("Release")
flags {"ExtraWarnings"}
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<SmallerTypeCheck>')
end
function vs10_vcxproj.onlyOneProjectConfigurationBlockWhenMultipleConfigs()
local buffer = get_buffer()
test.string_does_not_contain(buffer,'<ItemGroup Label="ProjectConfigurations">.*<ItemGroup Label="ProjectConfigurations">')
end
function vs10_vcxproj.languageC_bufferContainsCompileAsC()
language "C"
local buffer = get_buffer()
test.string_contains(buffer,'<CompileAs>CompileAsC</CompileAs>')
end
local debug_config_pch_string = '<PrecompiledHeader Condition="\'%$%(Configuration%)|%$%(Platform%)\'==\'Debug|Win32\'">Create</PrecompiledHeader>'
function vs10_vcxproj.noPchFlagSet_bufferDoesNotContainPchCreate()
configuration("Debug")
flags{"NoPCH"}
local buffer = get_buffer()
test.string_does_not_contain(buffer,debug_config_pch_string)
end
function vs10_vcxproj.pchHeaderSetYetPchSourceIsNot_bufferDoesNotContainPchCreate()
configuration("Debug")
pchheader "foo/dummyHeader.h"
local buffer = get_buffer()
test.string_does_not_contain(buffer,debug_config_pch_string)
end
function vs10_vcxproj.pchHeaderAndPchSourceSet_bufferContainPchCreate()
configuration("Debug")
pchheader "foo/dummyHeader.h"
pchsource "foo/dummySource.cpp"
local buffer = get_buffer()
test.string_contains(buffer,debug_config_pch_string)
end
function vs10_vcxproj.pchHeaderAndSourceSet_yetAlsoNoPch_bufferDoesNotContainpchCreate()
configuration('Debug')
pchheader "foo/dummyHeader.h"
pchsource "foo/dummySource.cpp"
flags{"NoPCH"}
local buffer = get_buffer()
test.string_does_not_contain(buffer,debug_config_pch_string)
end