diff options
-rw-r--r-- | src/_manifest.lua | 2 | ||||
-rw-r--r-- | src/actions/vstudio/vs2010_vcxproj.lua (renamed from src/actions/vstudio/vs2010_vcxproxj.lua) | 180 | ||||
-rw-r--r-- | tests/actions/vstudio/test_vs2010_vcxproj.lua | 11 | ||||
-rwxr-xr-x | tests/actions/vstudio/vc2010/files.lua | 67 | ||||
-rw-r--r-- | tests/premake4.lua | 1 |
5 files changed, 156 insertions, 105 deletions
diff --git a/src/_manifest.lua b/src/_manifest.lua index 18cec47..9748976 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -60,7 +60,7 @@ "actions/vstudio/vs2005_solution.lua", "actions/vstudio/vs2005_csproj.lua", "actions/vstudio/vs2005_csproj_user.lua", - "actions/vstudio/vs2010_vcxproxj.lua", + "actions/vstudio/vs2010_vcxproj.lua", -- Xcode action "actions/xcode/_xcode.lua", diff --git a/src/actions/vstudio/vs2010_vcxproxj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 4fd5c7b..90b2448 100644 --- a/src/actions/vstudio/vs2010_vcxproxj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -1,6 +1,6 @@ -- -- vs200x_vcproj.lua --- Generate a Visual Studio 2002-2008 C/C++ project. +-- Generate a Visual Studio 2010 C/C++ project. -- Copyright (c) 2009-2011 Jason Perkins and the Premake project -- @@ -64,37 +64,6 @@ end - - --also translates file paths from '/' to '\\' - function vc2010.sort_input_files(files,sorted_container) - 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_container[type],translated_path) - else - table.insert(sorted_container.None,translated_path) - end - end - end - end - - - local function vs2010_config(prj) _p(1,'<ItemGroup Label="ProjectConfigurations">') for _, cfginfo in ipairs(prj.solution.vstudio_configs) do @@ -106,19 +75,19 @@ _p(1,'</ItemGroup>') end - local function vs2010_globals(prj)
- _p(1,'<PropertyGroup Label="Globals">')
- _p(2,'<ProjectGuid>{%s}</ProjectGuid>',prj.uuid)
- _p(2,'<RootNamespace>%s</RootNamespace>',prj.name)
- --if prj.flags is required as it is not set at project level for tests???
- --vs200x generator seems to swap a config for the prj in test setup
- if prj.flags and prj.flags.Managed then
- _p(2,'<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>')
- _p(2,'<Keyword>ManagedCProj</Keyword>')
- else
- _p(2,'<Keyword>Win32Proj</Keyword>')
- end
- _p(1,'</PropertyGroup>')
+ local function vs2010_globals(prj) + _p(1,'<PropertyGroup Label="Globals">') + _p(2,'<ProjectGuid>{%s}</ProjectGuid>',prj.uuid) + _p(2,'<RootNamespace>%s</RootNamespace>',prj.name) + --if prj.flags is required as it is not set at project level for tests??? + --vs200x generator seems to swap a config for the prj in test setup + if prj.flags and prj.flags.Managed then + _p(2,'<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>') + _p(2,'<Keyword>ManagedCProj</Keyword>') + else + _p(2,'<Keyword>Win32Proj</Keyword>') + end + _p(1,'</PropertyGroup>') end function vc2010.config_type(config) @@ -164,8 +133,8 @@ _p(2,'<UseDebugLibraries>%s</UseDebugLibraries>' ,iif(optimisation(cfg) == "Disabled","true","false")) - if cfg.flags.Managed then
- _p(2,'<CLRSupport>true</CLRSupport>')
+ if cfg.flags.Managed then + _p(2,'<CLRSupport>true</CLRSupport>') end _p(1,'</PropertyGroup>') end @@ -225,15 +194,15 @@ _p(1,'</PropertyGroup>') end - local function runtime(cfg)
- local runtime
- local flags = cfg.flags
- if premake.config.isdebugbuild(cfg) then
- runtime = iif(flags.StaticRuntime and not flags.Managed, "MultiThreadedDebug", "MultiThreadedDebugDLL")
- else
- runtime = iif(flags.StaticRuntime and not flags.Managed, "MultiThreaded", "MultiThreadedDLL")
- end
- return runtime
+ local function runtime(cfg) + local runtime + local flags = cfg.flags + if premake.config.isdebugbuild(cfg) then + runtime = iif(flags.StaticRuntime and not flags.Managed, "MultiThreadedDebug", "MultiThreadedDebugDLL") + else + runtime = iif(flags.StaticRuntime and not flags.Managed, "MultiThreaded", "MultiThreadedDLL") + end + return runtime end local function precompiled_header(cfg) @@ -360,8 +329,8 @@ minimal_build(cfg) if not premake.config.isoptimizedbuild(cfg.flags) then - if not cfg.flags.Managed then
- _p(3,'<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>')
+ if not cfg.flags.Managed then + _p(3,'<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>') end if cfg.flags.ExtraWarnings then @@ -527,15 +496,12 @@ - -- - -- <ItemGroup> - -- <ProjectReference Include="zlibvc.vcxproj"> - -- <Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project> - -- </ProjectReference> - -- </ItemGroup> - -- +-- +-- Generate the source code file list. +-- + - local function write_file_type_block(files,group_type) + local function write_file_type_block(files, group_type) if #files > 0 then _p(1,'<ItemGroup>') for _, current_file in ipairs(files) do @@ -544,11 +510,10 @@ _p(1,'</ItemGroup>') end end - - local function write_file_compile_block(files,prj,configs) - + + + 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) @@ -556,7 +521,6 @@ config_mappings[cfginfo] = path.translate(cfg.pchsource, "\\") end end - _p(1,'<ItemGroup>') for _, current_file in ipairs(files) do @@ -575,25 +539,59 @@ end end - - local function vcxproj_files(prj) + + function vc2010.sort_input_files(files) local sorted = { - ClCompile ={}, - ClInclude ={}, - None ={}, - ResourceCompile ={} + ClCompile = {}, + ClInclude = {}, + None = {}, + ResourceCompile = {} } - - cfg = premake.getconfig(prj) - vc2010.sort_input_files(cfg.files,sorted) - 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') + 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 - + + + function vc2010.files(prj) + 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') + end + + +-- +-- Write filters +-- + local function write_filter_includes(sorted_table) local directories = vc2010.table_of_file_filters(sorted_table) --I am going to take a punt here that the ItemGroup is missing if no files!!!! @@ -631,16 +629,8 @@ local xml_version_and_encoding = '<?xml version="1.0" encoding="utf-8"?>' local function vcxproj_filter_files(prj) - local sorted = - { - ClCompile ={}, - ClInclude ={}, - None ={}, - ResourceCompile ={} - } - cfg = premake.getconfig(prj) - vc2010.sort_input_files(cfg.files,sorted) + local sorted = vc2010.sort_input_files(cfg.files) io.eol = "\r\n" _p(xml_version_and_encoding) @@ -680,7 +670,7 @@ item_definitions(prj) - vcxproj_files(prj) + vc2010.files(prj) _p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />') _p(1,'<ImportGroup Label="ExtensionTargets">') diff --git a/tests/actions/vstudio/test_vs2010_vcxproj.lua b/tests/actions/vstudio/test_vs2010_vcxproj.lua index 4f192f1..de48f3b 100644 --- a/tests/actions/vstudio/test_vs2010_vcxproj.lua +++ b/tests/actions/vstudio/test_vs2010_vcxproj.lua @@ -227,16 +227,9 @@ end local function SortAndReturnSortedInputFiles(input) - local sorted = - { - ClInclude ={}, - ClCompile ={}, - None ={}, - ResourceCompile ={} - } - vc2010.sort_input_files(input,sorted) - return sorted + return vc2010.sort_input_files(input) end + function vs10_vcxproj.sortFile_headerFile_SortedClIncludeEqualToFile() local file = {"bar.h"} local sorted = SortAndReturnSortedInputFiles(file) diff --git a/tests/actions/vstudio/vc2010/files.lua b/tests/actions/vstudio/vc2010/files.lua new file mode 100755 index 0000000..685f338 --- /dev/null +++ b/tests/actions/vstudio/vc2010/files.lua @@ -0,0 +1,67 @@ +-- +-- tests/actions/vstudio/vc2010/files.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_files = { } + local suite = T.vstudio_vs2010_files + local vc2010 = premake.vstudio.vc2010 + + +-- +-- Setup +-- + + local sln, prj + + function suite.setup() + sln = test.createsolution() + end + + local function prepare() + premake.buildconfigs() + prj = premake.solution.getproject(sln, 1) + sln.vstudio_configs = premake.vstudio.buildconfigs(sln) + vc2010.files(prj) + end + + +-- +-- Test grouping and nesting +-- + + function suite.SimpleSourceFile() + files { "hello.c" } + prepare() + test.capture [[ + <ItemGroup> + <ClCompile Include="hello.c"> + </ClCompile> + </ItemGroup> + ]] + end + + + function suite.SingleFolderLevel() + files { "src/hello.c" } + prepare() + test.capture [[ + <ItemGroup> + <ClCompile Include="src\hello.c"> + </ClCompile> + </ItemGroup> + ]] + end + + + function suite.MultipleFolderLevels() + files { "src/greetings/hello.c" } + prepare() + test.capture [[ + <ItemGroup> + <ClCompile Include="src\greetings\hello.c"> + </ClCompile> + </ItemGroup> + ]] + end diff --git a/tests/premake4.lua b/tests/premake4.lua index cf332c1..ae9c249 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -96,6 +96,7 @@ -- Visual Studio 2010 C/C++ projects dofile("actions/vstudio/vc2010/debugdir.lua") + dofile("actions/vstudio/vc2010/files.lua") -- Makefile tests dofile("actions/make/test_make_escaping.lua") |