Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-07-13 00:55:27 +0400
committerJason Perkins <starkos@industriousone.com>2011-07-13 00:55:27 +0400
commita06602621f46f5f9e3f0144a7c73677c6872dbfa (patch)
treeaafb43b283453962b7273239b4134a62f4f274eb
parent8adaa03be719a893229f285deae1924d95e682ae (diff)
Removed a bunch of deprecated VC2010 code
-rw-r--r--src/actions/vstudio/vs2010_vcxproj.lua161
-rw-r--r--src/actions/vstudio/vs2010_vcxproj_filters.lua25
-rw-r--r--tests/actions/vstudio/test_vs2010_vcxproj.lua92
-rwxr-xr-xtests/actions/vstudio/vc2010/test_files.lua39
-rw-r--r--tests/actions/vstudio/vc2010/test_filters.lua143
-rw-r--r--tests/actions/vstudio/vc2010/test_pch.lua63
-rw-r--r--tests/base/test_path.lua13
-rw-r--r--tests/premake4.lua1
8 files changed, 155 insertions, 382 deletions
diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua
index 2032134..f9b4c60 100644
--- a/src/actions/vstudio/vs2010_vcxproj.lua
+++ b/src/actions/vstudio/vs2010_vcxproj.lua
@@ -6,31 +6,7 @@
premake.vstudio.vc2010 = { }
local vc2010 = premake.vstudio.vc2010
-
-
- function vc2010.remove_relative_path(file)
- file = file:gsub("%.%.\\",'')
- file = file:gsub("%.\\",'')
- return file
- end
- function vc2010.file_path(file)
- file = vc2010.remove_relative_path(file)
- local path = string.find(file,'\\[%w%.%_%-]+$')
- if path then
- return string.sub(file,1,path-1)
- else
- return nil
- end
- end
-
- function vc2010.get_file_extension(file)
- local ext_start,ext_end = string.find(file,"%.[%w_%-]+$")
- if ext_start then
- return string.sub(file,ext_start+1,ext_end)
- end
- end
-
local function vs2010_config(prj)
_p(1,'<ItemGroup Label="ProjectConfigurations">')
@@ -69,6 +45,8 @@
return t[config.kind]
end
+
+
local function if_config_and_platform()
return 'Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"'
end
@@ -465,90 +443,6 @@
--
--- Generate the source code file list.
---
-
-
- local function write_file_type_block(files, group_type)
- if #files > 0 then
- _p(1,'<ItemGroup>')
- for _, current_file in ipairs(files) do
- _p(2,'<%s Include=\"%s\" />', group_type,current_file)
- end
- _p(1,'</ItemGroup>')
- end
- end
-
-
- local function write_file_compile_block(files, prj,configs)
- if #files > 0 then
- local config_mappings = {}
- for _, cfginfo in ipairs(configs) do
- local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
- if cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then
- config_mappings[cfginfo] = path.translate(cfg.pchsource, "\\")
- end
- end
-
- _p(1,'<ItemGroup>')
- for _, current_file in ipairs(files) do
- _p(2,'<ClCompile Include=\"%s\">', current_file)
- for _, cfginfo in ipairs(configs) do
- if config_mappings[cfginfo] and current_file == config_mappings[cfginfo] then
- _p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>Create</PrecompiledHeader>'
- ,premake.esc(cfginfo.name))
- --only one source file per pch
- config_mappings[cfginfo] = nil
- end
- end
- _p(2,'</ClCompile>')
- end
- _p(1,'</ItemGroup>')
- end
- end
-
-
- -- TODO: remove files arg when everything is ported
- function vc2010.sort_input_files(files)
- local sorted =
- {
- ClCompile = {},
- ClInclude = {},
- None = {},
- ResourceCompile = {},
- }
-
- -- TODO: move this to path functions
- local types =
- {
- h = "ClInclude",
- hpp = "ClInclude",
- hxx = "ClInclude",
- c = "ClCompile",
- cpp = "ClCompile",
- cxx = "ClCompile",
- cc = "ClCompile",
- rc = "ResourceCompile"
- }
-
- for _, current_file in ipairs(files) do
- local translated_path = path.translate(current_file, '\\')
- local ext = vc2010.get_file_extension(translated_path)
- if ext then
- local type = types[ext]
- if type then
- table.insert(sorted[type], translated_path)
- else
- table.insert(sorted.None, translated_path)
- end
- end
- end
-
- return sorted
- end
-
-
---
-- Retrieve a list of files for a particular build group, one of
-- "ClInclude", "ClCompile", "ResourceCompile", and "None".
--
@@ -588,13 +482,50 @@
--
function vc2010.files(prj)
- -- TODO: I shouldn't need getconfig(), should already have root config
- cfg = premake.getconfig(prj)
- local sorted = vc2010.sort_input_files(cfg.files)
- write_file_type_block(sorted.ClInclude, "ClInclude")
- write_file_compile_block(sorted.ClCompile,prj, prj.solution.vstudio_configs)
- write_file_type_block(sorted.None, 'None')
- write_file_type_block(sorted.ResourceCompile, 'ResourceCompile')
+ vc2010.simplefilesgroup(prj, "ClInclude")
+ vc2010.compilerfilesgroup(prj)
+ vc2010.simplefilesgroup(prj, "None")
+ vc2010.simplefilesgroup(prj, "ResourceCompile")
+ end
+
+
+ function vc2010.simplefilesgroup(prj, section)
+ local files = vc2010.getfilegroup(prj, section)
+ if #files > 0 then
+ _p(1,'<ItemGroup>')
+ for _, file in ipairs(files) do
+ _p(2,'<%s Include=\"%s\" />', section, path.translate(file.name, "\\"))
+ end
+ _p(1,'</ItemGroup>')
+ end
+ end
+
+
+ function vc2010.compilerfilesgroup(prj)
+ local configs = prj.solution.vstudio_configs
+ local files = vc2010.getfilegroup(prj, "ClCompile")
+ if #files > 0 then
+ local config_mappings = {}
+ for _, cfginfo in ipairs(configs) do
+ local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)
+ if cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then
+ config_mappings[cfginfo] = path.translate(cfg.pchsource, "\\")
+ end
+ end
+
+ _p(1,'<ItemGroup>')
+ for _, file in ipairs(files) do
+ _p(2,'<ClCompile Include=\"%s\">', path.translate(file.name, "\\"))
+ for _, cfginfo in ipairs(configs) do
+ if config_mappings[cfginfo] and file.name == config_mappings[cfginfo] then
+ _p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>Create</PrecompiledHeader>', premake.esc(cfginfo.name))
+ config_mappings[cfginfo] = nil --only one source file per pch
+ end
+ end
+ _p(2,'</ClCompile>')
+ end
+ _p(1,'</ItemGroup>')
+ end
end
diff --git a/src/actions/vstudio/vs2010_vcxproj_filters.lua b/src/actions/vstudio/vs2010_vcxproj_filters.lua
index 63a1700..0744e08 100644
--- a/src/actions/vstudio/vs2010_vcxproj_filters.lua
+++ b/src/actions/vstudio/vs2010_vcxproj_filters.lua
@@ -7,27 +7,6 @@
local vc2010 = premake.vstudio.vc2010
local project = premake.project
---
--- Write filters
---
-
- local function write_file_filter_block(files,group_type)
- if #files > 0 then
- _p(1,'<ItemGroup>')
- for _, current_file in ipairs(files) do
- local path_to_file = vc2010.file_path(current_file)
- if path_to_file then
- _p(2,'<%s Include=\"%s\">', group_type,path.translate(current_file, "\\"))
- _p(3,'<Filter>%s</Filter>',path_to_file)
- _p(2,'</%s>',group_type)
- else
- _p(2,'<%s Include=\"%s\" />', group_type,path.translate(current_file, "\\"))
- end
- end
- _p(1,'</ItemGroup>')
- end
- end
-
--
-- The first portion of the filters file assigns unique IDs to each
@@ -108,10 +87,6 @@
function vc2010.generate_filters(prj)
io.indent = " "
-
- cfg = premake.getconfig(prj)
- local sorted = vc2010.sort_input_files(cfg.files)
-
vc2010.header()
vc2010.filteridgroup(prj)
vc2010.filefiltergroup(prj, "None")
diff --git a/tests/actions/vstudio/test_vs2010_vcxproj.lua b/tests/actions/vstudio/test_vs2010_vcxproj.lua
index 41b9d1c..c28402f 100644
--- a/tests/actions/vstudio/test_vs2010_vcxproj.lua
+++ b/tests/actions/vstudio/test_vs2010_vcxproj.lua
@@ -201,36 +201,6 @@
local buffer = get_buffer()
test.string_contains(buffer,'<ItemGroup>.*</ItemGroup>')
end
-
- function vs10_vcxproj.fileExtension_extEqualH()
- local ext = vc2010.get_file_extension('foo.h')
- test.isequal('h', ext)
- end
-
- function vs10_vcxproj.fileExtension_containsTwoDots_extEqualH()
- local ext = vc2010.get_file_extension('foo.bar.h')
- test.isequal('h', ext)
- end
-
- function vs10_vcxproj.fileExtension_alphaNumeric_extEqualOneH()
- local ext = vc2010.get_file_extension('foo.1h')
- test.isequal('1h', ext)
- end
-
- function vs10_vcxproj.fileExtension_alphaNumericWithUnderscore_extEqualOne_H()
- local ext = vc2010.get_file_extension('foo.1_h')
- test.isequal('1_h', ext)
- end
-
- function vs10_vcxproj.fileExtension_containsHyphen_extEqualHHyphenH()
- local ext = vc2010.get_file_extension('foo.h-h')
- test.isequal('h-h', ext)
- end
-
- function vs10_vcxproj.fileExtension_containsMoreThanOneDot_extEqualOneH()
- local ext = vc2010.get_file_extension('foo.bar.h')
- test.isequal('h', ext)
- end
function vs10_vcxproj.itemGroupSection_hasResourceCompileSection()
--for some reason this does not work here and it needs to be in
@@ -239,11 +209,6 @@
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()
@@ -360,15 +325,6 @@
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')
@@ -379,56 +335,8 @@
test.string_does_not_contain(buffer,debug_config_pch_string)
end
- function vs10_vcxproj.pchHeaderAndPchSourceSet_debugAndRelease_matchingClCompileBlocks()
- configuration("Debug")
- pchheader "foo/dummyHeader.h"
- pchsource "foo/dummySource.cpp"
- configuration("Release")
- pchheader "foo/dummyHeader.h"
- pchsource "foo/dummySource.cpp"
- local buffer = get_buffer()
-
- local expected = '<ClCompile Include="foo\\dummySource.cpp">%s+'
- ..debug_config_pch_string ..'%s+'
- ..release_config_pch_string ..'%s+</ClCompile>'
- test.string_contains(buffer,expected)
- end
function vs10_vcxproj.wholeProgramOptimizationIsNotSetByDefault_bufferDoesNotContainWholeProgramOptimization()
local buffer = get_buffer()
test.string_does_not_contain(buffer,"WholeProgramOptimization")
end
-
-
-
---
--- Test file sorting into build categories
---
-
- local function SortAndReturnSortedInputFiles(input)
- return vc2010.sort_input_files(input)
- 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
diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua
index 937adab..6cd1a16 100755
--- a/tests/actions/vstudio/vc2010/test_files.lua
+++ b/tests/actions/vstudio/vc2010/test_files.lua
@@ -28,9 +28,20 @@
--
--- Test grouping and nesting
+-- Test file groups
--
+ function suite.SimpleHeaderFile()
+ files { "include/hello.h" }
+ prepare()
+ test.capture [[
+ <ItemGroup>
+ <ClInclude Include="include\hello.h" />
+ </ItemGroup>
+ ]]
+ end
+
+
function suite.SimpleSourceFile()
files { "hello.c" }
prepare()
@@ -41,20 +52,34 @@
</ItemGroup>
]]
end
-
-
- function suite.SingleFolderLevel()
- files { "src/hello.c" }
+
+
+ function suite.SimpleNoneFile()
+ files { "docs/hello.txt" }
prepare()
test.capture [[
<ItemGroup>
- <ClCompile Include="src\hello.c">
- </ClCompile>
+ <None Include="docs\hello.txt" />
+ </ItemGroup>
+ ]]
+ end
+
+
+ function suite.SimpleResourceFile()
+ files { "resources/hello.rc" }
+ prepare()
+ test.capture [[
+ <ItemGroup>
+ <ResourceCompile Include="resources\hello.rc" />
</ItemGroup>
]]
end
+--
+-- Test path handling
+--
+
function suite.MultipleFolderLevels()
files { "src/greetings/hello.c" }
prepare()
diff --git a/tests/actions/vstudio/vc2010/test_filters.lua b/tests/actions/vstudio/vc2010/test_filters.lua
index b53955c..f603015 100644
--- a/tests/actions/vstudio/vc2010/test_filters.lua
+++ b/tests/actions/vstudio/vc2010/test_filters.lua
@@ -28,140 +28,12 @@
os.uuid = os_uuid
end
- local function get_buffer()
- premake.bake.buildconfigs()
- sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
- vc2010.generate_filters(prj)
- buffer = io.endcapture()
- return buffer
- end
-
local function prepare()
premake.bake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
end
---
--- Tests
---
-
- function suite.path_noPath_returnsNil()
- local result = vc2010.file_path("foo.h")
- test.isequal(nil,result)
- end
-
- function suite.path_hasOneDirectoryPath_returnsIsFoo()
- local path = "foo"
- local result = vc2010.file_path(path .."\\foo.h")
- test.isequal(path,result)
- end
-
- function suite.path_hasTwoDirectoryPath_returnsIsFooSlashBar()
- local path = "foo\\bar"
- local result = vc2010.file_path(path .."\\foo.h")
- test.isequal(path,result)
- end
-
- function suite.path_hasTwoDirectoryPath_returnsIsFooSlashBar_Baz()
- local path = "foo\\bar_baz"
- local result = vc2010.file_path(path .."\\foo.h")
- test.isequal(path,result)
- end
-
- function suite.path_extensionWithHyphen_returnsIsFoo()
- local path = "foo"
- local result = vc2010.file_path(path .."\\foo-bar.h")
- test.isequal(path,result)
- end
-
- function suite.path_extensionWithNumber_returnsIs2Foo()
- local path = "foo"
- local result = vc2010.file_path(path .."\\2foo.h")
- test.isequal(path,result)
- end
-
- function suite.path_hasThreeDirectoryPath_returnsIsFooSlashBarSlashBaz()
- local path = "foo\\bar\\baz"
- local result = vc2010.file_path(path .."\\foo.h")
- test.isequal(path,result)
- end
-
- function suite.path_hasDotDotSlashDirectoryPath_returnsNil()
- local path = ".."
- local result = vc2010.file_path(path .."\\foo.h")
- test.isequal(nil,result)
- end
-
- function suite.removeRelativePath_noRelativePath_returnsInput()
- local path = "foo.h"
- local result = vc2010.remove_relative_path(path)
- test.isequal("foo.h",result)
- end
-
- function suite.removeRelativePath_dotDotSlashFoo_returnsFoo()
- local path = "..\\foo"
- local result = vc2010.remove_relative_path(path)
- test.isequal("foo",result)
- end
-
- function suite.removeRelativePath_dotDotSlashDotDotSlashFoo_returnsFoo()
- local path = "..\\..\\foo"
- local result = vc2010.remove_relative_path(path)
- test.isequal("foo",result)
- end
-
- function suite.removeRelativePath_DotSlashFoo_returnsFoo()
- local path = ".\\foo"
- local result = vc2010.remove_relative_path(path)
- test.isequal("foo",result)
- end
-
- function suite.clIncludeFilter_oneInputFile_bufferContainsTagClInclude()
- files
- {
- "dontCare.h"
- }
- local buffer = get_buffer()
- test.string_contains(buffer,'<ClInclude')
- end
-
- function suite.clIncludeFilter_oneInputFileWithoutDirectory_bufferContainsTagClIncludeOnOneLine()
- files
- {
- "foo.h"
- }
- local buffer = get_buffer()
- test.string_contains(buffer,'<ClInclude Include="foo.h" />')
- end
-
- function suite.clCompileFilter_oneInputFile_bufferContainsTagClCompile()
- files
- {
- "dontCare.cpp"
- }
- local buffer = get_buffer()
- test.string_contains(buffer,'<ClCompile')
- end
-
- function suite.noneFilter_oneInputFile_bufferContainsTagNone()
- files
- {
- "dontCare.ext"
- }
- local buffer = get_buffer()
- test.string_contains(buffer,'<None')
- end
-
- function suite.resourceCompileFilter_oneInputFile_bufferContainsTagResourceCompile()
- files
- {
- "dontCare.rc"
- }
- local buffer = get_buffer()
- test.string_contains(buffer,'<ResourceCompile')
- end
-
--
-- Filter identifiers sections
@@ -319,18 +191,3 @@
</ItemGroup>
]]
end
-
-
- -- one file needs a filter, another doesn't
-
- -- assigns to real paths
-
- -- assigns to vpaths
-
- -- writes none filter
-
- -- writes include filter
-
- -- writes resource filter
- -- anything else?
- \ No newline at end of file
diff --git a/tests/actions/vstudio/vc2010/test_pch.lua b/tests/actions/vstudio/vc2010/test_pch.lua
new file mode 100644
index 0000000..fad5025
--- /dev/null
+++ b/tests/actions/vstudio/vc2010/test_pch.lua
@@ -0,0 +1,63 @@
+--
+-- tests/actions/vstudio/vc2010/test_pch.lua
+-- Validate generation of files block in Visual Studio 2010 C/C++ projects.
+-- Copyright (c) 2011 Jason Perkins and the Premake project
+--
+
+ T.vstudio_vs2010_pch = { }
+ local suite = T.vstudio_vs2010_pch
+ 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.files(prj)
+ end
+
+
+--
+-- Tests
+--
+
+ function suite.pch_OnProject()
+ files { "afxwin.cpp" }
+ pchheader "afxwin.h"
+ pchsource "afxwin.cpp"
+ prepare()
+ test.capture [[
+ <ItemGroup>
+ <ClCompile Include="afxwin.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ ]]
+ end
+
+
+ function suite.pch_OnSingleConfig()
+ files { "afxwin.cpp" }
+ configuration "Debug"
+ pchheader "afxwin.h"
+ pchsource "afxwin.cpp"
+ prepare()
+ test.capture [[
+ <ItemGroup>
+ <ClCompile Include="afxwin.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ ]]
+ end
diff --git a/tests/base/test_path.lua b/tests/base/test_path.lua
index 19b212c..c2b153f 100644
--- a/tests/base/test_path.lua
+++ b/tests/base/test_path.lua
@@ -104,6 +104,19 @@
function suite.getextension_OnMultipleDots()
test.isequal(".txt", path.getextension("filename.mod.txt"))
end
+
+ function suite.getextension_OnLeadingNumeric()
+ test.isequal(".7z", path.getextension("filename.7z"))
+ end
+
+ function suite.getextension_OnUnderscore()
+ test.isequal(".a_c", path.getextension("filename.a_c"))
+ end
+
+ function suite.getextension_OnHyphen()
+ test.isequal(".a-c", path.getextension("filename.a-c"))
+ end
+
--
diff --git a/tests/premake4.lua b/tests/premake4.lua
index 25fb029..8f4620c 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -105,6 +105,7 @@
dofile("actions/vstudio/vc2010/test_header.lua")
dofile("actions/vstudio/vc2010/test_files.lua")
dofile("actions/vstudio/vc2010/test_filters.lua")
+ dofile("actions/vstudio/vc2010/test_pch.lua")
-- Makefile tests
dofile("actions/make/test_make_escaping.lua")