diff --git a/modules/d/actions/vstudio.lua b/modules/d/actions/vstudio.lua index e2746ee6..b7d1ea2d 100644 --- a/modules/d/actions/vstudio.lua +++ b/modules/d/actions/vstudio.lua @@ -9,6 +9,8 @@ m.visuald = {} + require ("vstudio") + local vstudio = p.vstudio local workspace = p.workspace local project = p.project diff --git a/modules/vstudio/_manifest.lua b/modules/vstudio/_manifest.lua new file mode 100644 index 00000000..1cc7b193 --- /dev/null +++ b/modules/vstudio/_manifest.lua @@ -0,0 +1,23 @@ +return { + "_preload.lua", + "vstudio.lua", + "vs2005.lua", + "vs2008.lua", + "vs200x_vcproj.lua", + "vs200x_vcproj_user.lua", + "vs2005_solution.lua", + "vs2005_csproj.lua", + "vs2005_csproj_user.lua", + "vs2010.lua", + "vs2010_nuget.lua", + "vs2010_vcxproj.lua", + "vs2010_vcxproj_user.lua", + "vs2010_vcxproj_filters.lua", + "vs2010_rules_props.lua", + "vs2010_rules_targets.lua", + "vs2010_rules_xml.lua", + "vs2012.lua", + "vs2013.lua", + "vs2015.lua", + "vs2017.lua", +} diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua new file mode 100644 index 00000000..3e75e020 --- /dev/null +++ b/modules/vstudio/_preload.lua @@ -0,0 +1,37 @@ +-- +-- _preload.lua +-- Define the makefile action(s). +-- Copyright (c) 2002-2015 Jason Perkins and the Premake project +-- + + local p = premake + local project = p.project + + -- initialize module. + p.modules.vstudio = p.modules.vstudio or {} + p.modules.vstudio._VERSION = p._VERSION + p.vstudio = p.modules.vstudio + + -- load actions. + include("vs2005.lua") + include("vs2008.lua") + include("vs2010.lua") + include("vs2012.lua") + include("vs2013.lua") + include("vs2015.lua") + include("vs2017.lua") + +-- +-- Decide when the full module should be loaded. +-- + + return function(cfg) + return + _ACTION == "vs2005" or + _ACTION == "vs2008" or + _ACTION == "vs2010" or + _ACTION == "vs2012" or + _ACTION == "vs2013" or + _ACTION == "vs2015" or + _ACTION == "vs2017"; + end diff --git a/modules/vstudio/tests/_tests.lua b/modules/vstudio/tests/_tests.lua new file mode 100644 index 00000000..01b7654e --- /dev/null +++ b/modules/vstudio/tests/_tests.lua @@ -0,0 +1,86 @@ +require ("vstudio") + +return { + -- Visual Studio 2005-2013 C# projects + "cs2005/test_assembly_refs.lua", + "cs2005/test_build_events.lua", + "cs2005/test_common_props.lua", + "cs2005/test_compiler_props.lua", + "cs2005/test_debug_props.lua", + "cs2005/test_files.lua", + "cs2005/test_icon.lua", + "cs2005/test_nuget_config.lua", + "cs2005/test_nuget_packages_config.lua", + "cs2005/test_output_props.lua", + "cs2005/projectelement.lua", + "cs2005/test_platform_groups.lua", + "cs2005/test_project_refs.lua", + "cs2005/projectsettings.lua", + "cs2005/test_targets.lua", + "cs2005/test_user_file.lua", + + -- Visual Studio 2005-2013 solutions + "sln2005/test_dependencies.lua", + "sln2005/test_header.lua", + "sln2005/test_nested_projects.lua", + "sln2005/test_projects.lua", + "sln2005/test_platforms.lua", + "sln2005/test_sections.lua", + + -- Visual Studio 2002-2008 C/C++ projects + "vc200x/test_assembly_refs.lua", + "vc200x/test_build_steps.lua", + "vc200x/test_configuration.lua", + "vc200x/test_compiler_block.lua", + "vc200x/test_debug_settings.lua", + "vc200x/test_excluded_configs.lua", + "vc200x/test_files.lua", + "vc200x/test_linker_block.lua", + "vc200x/test_manifest_block.lua", + "vc200x/test_nmake_settings.lua", + "vc200x/test_platforms.lua", + "vc200x/test_project.lua", + "vc200x/test_project_refs.lua", + "vc200x/test_resource_compiler.lua", + "vc200x/test_user_file.lua", + + -- Visual Studio 2010-2013 C/C++ projects + "vc2010/test_assembly_refs.lua", + "vc2010/test_build_events.lua", + "vc2010/test_build_log.lua", + "vc2010/test_character_set.lua", + "vc2010/test_compile_settings.lua", + "vc2010/test_config_props.lua", + "vc2010/test_debug_settings.lua", + "vc2010/test_excluded_configs.lua", + "vc2010/test_extension_settings.lua", + "vc2010/test_extension_targets.lua", + "vc2010/test_language_settings.lua", + "vc2010/test_language_targets.lua", + "vc2010/test_floatingpoint.lua", + "vc2010/test_globals.lua", + "vc2010/test_header.lua", + "vc2010/test_files.lua", + "vc2010/test_filter_ids.lua", + "vc2010/test_filters.lua", + "vc2010/test_imagexex_settings.lua", + "vc2010/test_item_def_group.lua", + "vc2010/test_link.lua", + "vc2010/test_manifest.lua", + "vc2010/test_nmake_props.lua", + "vc2010/test_nuget_packages_config.lua", + "vc2010/test_output_props.lua", + "vc2010/test_platform_toolset.lua", + "vc2010/test_project_configs.lua", + "vc2010/test_project_refs.lua", + "vc2010/test_prop_sheet.lua", + "vc2010/test_resource_compile.lua", + "vc2010/test_rule_props.lua", + "vc2010/test_rule_targets.lua", + "vc2010/test_rule_vars.lua", + "vc2010/test_rule_xml.lua", + "vc2010/test_target_machine.lua", + "vc2010/test_user_file.lua", + "vc2010/test_vectorextensions.lua", + "vc2010/test_ensure_nuget_imports.lua", +} diff --git a/tests/actions/vstudio/cs2005/projectelement.lua b/modules/vstudio/tests/cs2005/projectelement.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/cs2005/projectelement.lua rename to modules/vstudio/tests/cs2005/projectelement.lua diff --git a/tests/actions/vstudio/cs2005/projectsettings.lua b/modules/vstudio/tests/cs2005/projectsettings.lua old mode 100755 new mode 100644 similarity index 96% rename from tests/actions/vstudio/cs2005/projectsettings.lua rename to modules/vstudio/tests/cs2005/projectsettings.lua index 25a4397b..a8f597f5 --- a/tests/actions/vstudio/cs2005/projectsettings.lua +++ b/modules/vstudio/tests/cs2005/projectsettings.lua @@ -1,207 +1,207 @@ --- --- tests/actions/vstudio/cs2005/projectsettings.lua --- Validate generation of root in Visual Studio 2005+ .csproj --- Copyright (c) 2009-2015 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_cs2005_projectsettings") - local cs2005 = p.vstudio.cs2005 - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2005") - wks = test.createWorkspace() - language "C#" - uuid "AE61726D-187C-E440-BD07-2556188A6565" - end - - local function prepare() - prj = test.getproject(wks, 1) - cs2005.projectProperties(prj) - end - - --- --- Version Tests --- - - function suite.OnVs2005() - prepare() - test.capture [[ - - Debug - AnyCPU - 8.0.50727 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - - ]] - end - - - function suite.OnVs2008() - p.action.set("vs2008") - prepare() - test.capture [[ - - Debug - AnyCPU - 9.0.30729 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - - ]] - end - - - function suite.OnVs2010() - p.action.set("vs2010") - prepare() - test.capture [[ - - Debug - AnyCPU - 8.0.30703 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - v4.0 - - - 512 - - ]] - end - - - function suite.onVs2012() - p.action.set("vs2012") - prepare() - test.capture [[ - - Debug - AnyCPU - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - v4.5 - 512 - - ]] - end - - --- --- Framework Tests --- - - function suite.OnFrameworkVersion() - framework "3.0" - prepare() - test.capture [[ - - Debug - AnyCPU - 8.0.50727 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - v3.0 - - ]] - end - - - function suite.OnDotNetFrameworkVersion() - dotnetframework "3.0" - prepare() - test.capture [[ - - Debug - AnyCPU - 8.0.50727 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - v3.0 - - ]] - end - - --- --- Make sure the root namespace can be overridden. --- - - function suite.canOverrideRootNamespace() - namespace "MyCompany.%{prj.name}" - prepare() - test.capture [[ - - Debug - AnyCPU - 8.0.50727 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyCompany.MyProject - MyProject - - ]] - end - - --- --- WPF adds an additional element. --- - - function suite.projectTypeGuids_onWPF() - p.action.set("vs2010") - flags { "WPF" } - prepare() - test.capture [[ - - Debug - AnyCPU - 8.0.30703 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - v4.0 - - - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - ]] - end +-- +-- tests/actions/vstudio/cs2005/projectsettings.lua +-- Validate generation of root in Visual Studio 2005+ .csproj +-- Copyright (c) 2009-2015 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_cs2005_projectsettings") + local cs2005 = p.vstudio.cs2005 + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2005") + wks = test.createWorkspace() + language "C#" + uuid "AE61726D-187C-E440-BD07-2556188A6565" + end + + local function prepare() + prj = test.getproject(wks, 1) + cs2005.projectProperties(prj) + end + + +-- +-- Version Tests +-- + + function suite.OnVs2005() + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + + ]] + end + + + function suite.OnVs2008() + p.action.set("vs2008") + prepare() + test.capture [[ + + Debug + AnyCPU + 9.0.30729 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + + ]] + end + + + function suite.OnVs2010() + p.action.set("vs2010") + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v4.0 + + + 512 + + ]] + end + + + function suite.onVs2012() + p.action.set("vs2012") + prepare() + test.capture [[ + + Debug + AnyCPU + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v4.5 + 512 + + ]] + end + + +-- +-- Framework Tests +-- + + function suite.OnFrameworkVersion() + framework "3.0" + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v3.0 + + ]] + end + + + function suite.OnDotNetFrameworkVersion() + dotnetframework "3.0" + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v3.0 + + ]] + end + + +-- +-- Make sure the root namespace can be overridden. +-- + + function suite.canOverrideRootNamespace() + namespace "MyCompany.%{prj.name}" + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyCompany.MyProject + MyProject + + ]] + end + + +-- +-- WPF adds an additional element. +-- + + function suite.projectTypeGuids_onWPF() + p.action.set("vs2010") + flags { "WPF" } + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v4.0 + + + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + ]] + end diff --git a/tests/actions/vstudio/cs2005/test_assembly_refs.lua b/modules/vstudio/tests/cs2005/test_assembly_refs.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_assembly_refs.lua rename to modules/vstudio/tests/cs2005/test_assembly_refs.lua diff --git a/tests/actions/vstudio/cs2005/test_build_events.lua b/modules/vstudio/tests/cs2005/test_build_events.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_build_events.lua rename to modules/vstudio/tests/cs2005/test_build_events.lua diff --git a/tests/actions/vstudio/cs2005/test_common_props.lua b/modules/vstudio/tests/cs2005/test_common_props.lua similarity index 95% rename from tests/actions/vstudio/cs2005/test_common_props.lua rename to modules/vstudio/tests/cs2005/test_common_props.lua index 1c5d9751..4cbf2c37 100644 --- a/tests/actions/vstudio/cs2005/test_common_props.lua +++ b/modules/vstudio/tests/cs2005/test_common_props.lua @@ -1,39 +1,39 @@ --- --- tests/actions/vstudio/cs2005/test_common_props.lua --- Check Visual Studio 2012 extensions to the project properties block. --- Copyright (c) 2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2012_csproj_common_props") - local cs2005 = p.vstudio.cs2005 - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2012") - wks = test.createWorkspace() - language "C#" - end - - local function prepare() - prj = test.getproject(wks, 1) - cs2005.commonProperties(prj) - end - - ---- --- Visual Studio 2012 omits and . ---- - - function suite.onDefaultCommonProps() - prepare() - test.capture [[ - - ]] - end +-- +-- tests/actions/vstudio/cs2005/test_common_props.lua +-- Check Visual Studio 2012 extensions to the project properties block. +-- Copyright (c) 2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2012_csproj_common_props") + local cs2005 = p.vstudio.cs2005 + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2012") + wks = test.createWorkspace() + language "C#" + end + + local function prepare() + prj = test.getproject(wks, 1) + cs2005.commonProperties(prj) + end + + +--- +-- Visual Studio 2012 omits and . +--- + + function suite.onDefaultCommonProps() + prepare() + test.capture [[ + + ]] + end diff --git a/tests/actions/vstudio/cs2005/test_compiler_props.lua b/modules/vstudio/tests/cs2005/test_compiler_props.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_compiler_props.lua rename to modules/vstudio/tests/cs2005/test_compiler_props.lua diff --git a/tests/actions/vstudio/cs2005/test_debug_props.lua b/modules/vstudio/tests/cs2005/test_debug_props.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_debug_props.lua rename to modules/vstudio/tests/cs2005/test_debug_props.lua diff --git a/tests/actions/vstudio/cs2005/test_files.lua b/modules/vstudio/tests/cs2005/test_files.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/cs2005/test_files.lua rename to modules/vstudio/tests/cs2005/test_files.lua diff --git a/tests/actions/vstudio/cs2005/test_icon.lua b/modules/vstudio/tests/cs2005/test_icon.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_icon.lua rename to modules/vstudio/tests/cs2005/test_icon.lua diff --git a/tests/actions/vstudio/cs2005/test_nuget_config.lua b/modules/vstudio/tests/cs2005/test_nuget_config.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_nuget_config.lua rename to modules/vstudio/tests/cs2005/test_nuget_config.lua diff --git a/tests/actions/vstudio/cs2005/test_nuget_packages_config.lua b/modules/vstudio/tests/cs2005/test_nuget_packages_config.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_nuget_packages_config.lua rename to modules/vstudio/tests/cs2005/test_nuget_packages_config.lua diff --git a/tests/actions/vstudio/cs2005/test_output_props.lua b/modules/vstudio/tests/cs2005/test_output_props.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_output_props.lua rename to modules/vstudio/tests/cs2005/test_output_props.lua diff --git a/tests/actions/vstudio/cs2005/test_platform_groups.lua b/modules/vstudio/tests/cs2005/test_platform_groups.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_platform_groups.lua rename to modules/vstudio/tests/cs2005/test_platform_groups.lua diff --git a/tests/actions/vstudio/cs2005/test_project_refs.lua b/modules/vstudio/tests/cs2005/test_project_refs.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_project_refs.lua rename to modules/vstudio/tests/cs2005/test_project_refs.lua diff --git a/tests/actions/vstudio/cs2005/test_targets.lua b/modules/vstudio/tests/cs2005/test_targets.lua similarity index 95% rename from tests/actions/vstudio/cs2005/test_targets.lua rename to modules/vstudio/tests/cs2005/test_targets.lua index 4e0b3300..bf76f311 100644 --- a/tests/actions/vstudio/cs2005/test_targets.lua +++ b/modules/vstudio/tests/cs2005/test_targets.lua @@ -1,46 +1,46 @@ --- --- tests/actions/vstudio/cs2005/test_targets.lua --- Check Visual Studio 2012 extensions to the targets block. --- Copyright (c) 2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2012_csproj_targets") - local cs2005 = p.vstudio.cs2005 - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2012") - wks = test.createWorkspace() - language "C#" - end - - local function prepare() - prj = test.getproject(wks, 1) - cs2005.targets(prj) - end - - ---- --- Visual Studio 2012 changes the MS Build path slightly. ---- - - function suite.on2012() - prepare() - test.capture [[ - - - ]] - end +-- +-- tests/actions/vstudio/cs2005/test_targets.lua +-- Check Visual Studio 2012 extensions to the targets block. +-- Copyright (c) 2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2012_csproj_targets") + local cs2005 = p.vstudio.cs2005 + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2012") + wks = test.createWorkspace() + language "C#" + end + + local function prepare() + prj = test.getproject(wks, 1) + cs2005.targets(prj) + end + + +--- +-- Visual Studio 2012 changes the MS Build path slightly. +--- + + function suite.on2012() + prepare() + test.capture [[ + + + ]] + end diff --git a/tests/actions/vstudio/cs2005/test_user_file.lua b/modules/vstudio/tests/cs2005/test_user_file.lua similarity index 100% rename from tests/actions/vstudio/cs2005/test_user_file.lua rename to modules/vstudio/tests/cs2005/test_user_file.lua diff --git a/tests/actions/vstudio/sln2005/test_dependencies.lua b/modules/vstudio/tests/sln2005/test_dependencies.lua old mode 100755 new mode 100644 similarity index 96% rename from tests/actions/vstudio/sln2005/test_dependencies.lua rename to modules/vstudio/tests/sln2005/test_dependencies.lua index 6d2e585f..583db6b6 --- a/tests/actions/vstudio/sln2005/test_dependencies.lua +++ b/modules/vstudio/tests/sln2005/test_dependencies.lua @@ -1,97 +1,97 @@ --- --- tests/actions/vstudio/sln2005/test_dependencies.lua --- Validate generation of Visual Studio 2005+ solution project dependencies. --- Copyright (c) 2009-2012 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_sln2005_dependencies") - local sln2005 = p.vstudio.sln2005 - - --- --- Setup --- - - local wks, prj1, prj2 - - function suite.setup() - p.action.set("vs2005") - wks, prj1 = test.createWorkspace() - uuid "AE61726D-187C-E440-BD07-2556188A6565" - prj2 = test.createproject(wks) - uuid "2151E83B-997F-4A9D-955D-380157E88C31" - prj3 = test.createproject(wks) - uuid "CAA68162-8B96-11E1-8D5E-5885BBE59B18" - links "MyProject" - dependson "MyProject2" - end - - local function prepare(language) - prj1.language = language - prj2.language = language - prj2 = test.getproject(wks, 2) - sln2005.projectdependencies(prj2) - prj3.language = language - prj3 = test.getproject(wks, 3) - sln2005.projectdependencies(prj3) - end - - --- --- Verify dependencies between C++ projects are listed. --- - function suite.dependency_onCppProjects() - prepare("C++") - test.capture [[ -ProjectSection(ProjectDependencies) = postProject - {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} -EndProjectSection - ]] - end - - --- --- Verify dependencies between C# projects are listed. --- - - function suite.dependency_onCSharpProjects() - prepare("C#") - test.capture [[ -ProjectSection(ProjectDependencies) = postProject - {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} -EndProjectSection - ]] - end - - --- --- Most C# references should go into the project rather than the solution, --- but until I know the conditions, put everything here to be safe. --- - - function suite.dependency_onCSharpProjectsVs2010() - p.action.set("vs2010") - prepare("C#") - test.capture [[ -ProjectSection(ProjectDependencies) = postProject - {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} -EndProjectSection - ]] - end - - - --- --- Verify dependencies between projects C# are listed for VS2012. --- - - function suite.dependency_onCSharpProjectsVs2012() - p.action.set("vs2012") - prepare("C#") - test.capture [[ -ProjectSection(ProjectDependencies) = postProject - {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} -EndProjectSection - ]] - end +-- +-- tests/actions/vstudio/sln2005/test_dependencies.lua +-- Validate generation of Visual Studio 2005+ solution project dependencies. +-- Copyright (c) 2009-2012 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_sln2005_dependencies") + local sln2005 = p.vstudio.sln2005 + + +-- +-- Setup +-- + + local wks, prj1, prj2 + + function suite.setup() + p.action.set("vs2005") + wks, prj1 = test.createWorkspace() + uuid "AE61726D-187C-E440-BD07-2556188A6565" + prj2 = test.createproject(wks) + uuid "2151E83B-997F-4A9D-955D-380157E88C31" + prj3 = test.createproject(wks) + uuid "CAA68162-8B96-11E1-8D5E-5885BBE59B18" + links "MyProject" + dependson "MyProject2" + end + + local function prepare(language) + prj1.language = language + prj2.language = language + prj2 = test.getproject(wks, 2) + sln2005.projectdependencies(prj2) + prj3.language = language + prj3 = test.getproject(wks, 3) + sln2005.projectdependencies(prj3) + end + + +-- +-- Verify dependencies between C++ projects are listed. +-- + function suite.dependency_onCppProjects() + prepare("C++") + test.capture [[ +ProjectSection(ProjectDependencies) = postProject + {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} +EndProjectSection + ]] + end + + +-- +-- Verify dependencies between C# projects are listed. +-- + + function suite.dependency_onCSharpProjects() + prepare("C#") + test.capture [[ +ProjectSection(ProjectDependencies) = postProject + {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} +EndProjectSection + ]] + end + + +-- +-- Most C# references should go into the project rather than the solution, +-- but until I know the conditions, put everything here to be safe. +-- + + function suite.dependency_onCSharpProjectsVs2010() + p.action.set("vs2010") + prepare("C#") + test.capture [[ +ProjectSection(ProjectDependencies) = postProject + {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} +EndProjectSection + ]] + end + + + +-- +-- Verify dependencies between projects C# are listed for VS2012. +-- + + function suite.dependency_onCSharpProjectsVs2012() + p.action.set("vs2012") + prepare("C#") + test.capture [[ +ProjectSection(ProjectDependencies) = postProject + {2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31} +EndProjectSection + ]] + end diff --git a/tests/actions/vstudio/sln2005/test_header.lua b/modules/vstudio/tests/sln2005/test_header.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/sln2005/test_header.lua rename to modules/vstudio/tests/sln2005/test_header.lua diff --git a/tests/actions/vstudio/sln2005/test_nested_projects.lua b/modules/vstudio/tests/sln2005/test_nested_projects.lua similarity index 100% rename from tests/actions/vstudio/sln2005/test_nested_projects.lua rename to modules/vstudio/tests/sln2005/test_nested_projects.lua diff --git a/tests/actions/vstudio/sln2005/test_platforms.lua b/modules/vstudio/tests/sln2005/test_platforms.lua similarity index 100% rename from tests/actions/vstudio/sln2005/test_platforms.lua rename to modules/vstudio/tests/sln2005/test_platforms.lua diff --git a/tests/actions/vstudio/sln2005/test_projects.lua b/modules/vstudio/tests/sln2005/test_projects.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/sln2005/test_projects.lua rename to modules/vstudio/tests/sln2005/test_projects.lua diff --git a/tests/actions/vstudio/sln2005/test_sections.lua b/modules/vstudio/tests/sln2005/test_sections.lua similarity index 100% rename from tests/actions/vstudio/sln2005/test_sections.lua rename to modules/vstudio/tests/sln2005/test_sections.lua diff --git a/tests/actions/vstudio/vc200x/test_assembly_refs.lua b/modules/vstudio/tests/vc200x/test_assembly_refs.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_assembly_refs.lua rename to modules/vstudio/tests/vc200x/test_assembly_refs.lua diff --git a/tests/actions/vstudio/vc200x/test_build_steps.lua b/modules/vstudio/tests/vc200x/test_build_steps.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_build_steps.lua rename to modules/vstudio/tests/vc200x/test_build_steps.lua diff --git a/tests/actions/vstudio/vc200x/test_compiler_block.lua b/modules/vstudio/tests/vc200x/test_compiler_block.lua similarity index 94% rename from tests/actions/vstudio/vc200x/test_compiler_block.lua rename to modules/vstudio/tests/vc200x/test_compiler_block.lua index e409f51b..2aaee360 100644 --- a/tests/actions/vstudio/vc200x/test_compiler_block.lua +++ b/modules/vstudio/tests/vc200x/test_compiler_block.lua @@ -1,681 +1,681 @@ --- --- tests/actions/vstudio/vc200x/test_compiler_block.lua --- Validate generation the VCCLCompiler element in Visual Studio 200x C/C++ projects. --- Copyright (c) 2011-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs200x_compiler_block") - local vc200x = p.vstudio.vc200x - - --- --- Setup/teardown --- - - local wks, prj - - function suite.setup() - p.action.set("vs2008") - wks, prj = test.createWorkspace() - end - - local function prepare() - local cfg = test.getconfig(prj, "Debug") - vc200x.VCCLCompilerTool(cfg) - end - - --- --- Verify the basic structure of the compiler block with no flags or settings. --- - - function suite.looksGood_onDefaultSettings() - prepare() - test.capture [[ - - ]] - end - - --- --- If include directories are specified, the should be added. --- - - - function suite.additionalIncludeDirs_onIncludeDirs() - includedirs { "include/lua", "include/zlib" } - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the handling of the Symbols in conjunction with the Optimize flag. --- The release runtime library must be used. --- - - function suite.looksGood_onSymbolsAndOptimizeFlags() - symbols "On" - optimize "On" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the handling of the C7 debug information format. --- - - function suite.looksGood_onC7DebugFormat() - symbols "On" - debugformat "C7" - prepare() - test.capture [[ - - ]] - end - - ---- --- Test precompiled header handling; the header should be treated as --- a plain string value, with no path manipulation applied, since it --- needs to match the value of the #include statement used in the --- project code. ---- - - function suite.compilerBlock_OnPCH() - location "build" - pchheader "include/common.h" - pchsource "source/common.cpp" - prepare() - test.capture [[ - - ]] - end - - --- --- Floating point flag tests --- - - function suite.compilerBlock_OnFpFast() - floatingpoint "Fast" - prepare() - test.capture [[ - - ]] - end - - function suite.compilerBlock_OnFpStrict() - floatingpoint "Strict" - prepare() - test.capture [[ - - ]] - end - - --- --- Check that the "minimal rebuild" flag is applied correctly. --- - - function suite.minimalRebuildFlagsSet_onMinimalRebuildAndSymbols() - flags { "NoMinimalRebuild" } - symbols "On" - prepare() - test.capture [[ - - ]] - end - --- --- Check that the "no buffer security check" flag is applied correctly. --- - - function suite.noBufferSecurityFlagSet_onBufferSecurityCheck() - flags { "NoBufferSecurityCheck" } - prepare() - test.capture [[ - - ]] - end - --- --- Check that the CompileAs value is set correctly for C language projects. --- - - function suite.compileAsSet_onC() - language "C" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the correct runtime library is used when symbols are enabled. --- - - function suite.runtimeLibraryIsDebug_onSymbolsNoOptimize() - symbols "On" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the correct warnings settings are used when extra warnings are enabled. --- - - function suite.runtimeLibraryIsDebug_onExtraWarnings() - warnings "Extra" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the correct warnings settings are used when FatalWarnings are enabled. --- - - function suite.runtimeLibraryIsDebug_onFatalWarnings() - flags { "FatalWarnings" } - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the correct warnings settings are used when no warnings are enabled. --- - - function suite.runtimeLibraryIsDebug_onNoWarnings_whichDisablesAllOtherWarningsFlags() - flags { "FatalWarnings" } - warnings "Off" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the correct Detect64BitPortabilityProblems settings are used when _ACTION < "VS2008". --- - - function suite._64BitPortabilityOn_onVS2005() - p.action.set("vs2005") - prepare() - test.capture [[ - - ]] - end - - function suite._64BitPortabilityOff_onVS2005_andCLR() - p.action.set("vs2005") - clr "On" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the correct warnings settings are used when no warnings are enabled. --- - - function suite.runtimeLibraryIsDebug_onVS2005_NoWarnings() - p.action.set("vs2005") - warnings "Off" - prepare() - test.capture [[ - - ]] - end - - --- --- Xbox 360 uses the same structure, but changes the element name. --- - - function suite.looksGood_onXbox360() - system "Xbox360" - prepare() - test.capture [[ - - ]] - end - - --- --- Check handling of forced includes. --- - - function suite.forcedIncludeFiles() - forceincludes { "stdafx.h", "include/sys.h" } - prepare() - test.capture [[ - + ]] + end + + +-- +-- If include directories are specified, the should be added. +-- + + + function suite.additionalIncludeDirs_onIncludeDirs() + includedirs { "include/lua", "include/zlib" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the handling of the Symbols in conjunction with the Optimize flag. +-- The release runtime library must be used. +-- + + function suite.looksGood_onSymbolsAndOptimizeFlags() + symbols "On" + optimize "On" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the handling of the C7 debug information format. +-- + + function suite.looksGood_onC7DebugFormat() + symbols "On" + debugformat "C7" + prepare() + test.capture [[ + + ]] + end + + +--- +-- Test precompiled header handling; the header should be treated as +-- a plain string value, with no path manipulation applied, since it +-- needs to match the value of the #include statement used in the +-- project code. +--- + + function suite.compilerBlock_OnPCH() + location "build" + pchheader "include/common.h" + pchsource "source/common.cpp" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Floating point flag tests +-- + + function suite.compilerBlock_OnFpFast() + floatingpoint "Fast" + prepare() + test.capture [[ + + ]] + end + + function suite.compilerBlock_OnFpStrict() + floatingpoint "Strict" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Check that the "minimal rebuild" flag is applied correctly. +-- + + function suite.minimalRebuildFlagsSet_onMinimalRebuildAndSymbols() + flags { "NoMinimalRebuild" } + symbols "On" + prepare() + test.capture [[ + + ]] + end + +-- +-- Check that the "no buffer security check" flag is applied correctly. +-- + + function suite.noBufferSecurityFlagSet_onBufferSecurityCheck() + flags { "NoBufferSecurityCheck" } + prepare() + test.capture [[ + + ]] + end + +-- +-- Check that the CompileAs value is set correctly for C language projects. +-- + + function suite.compileAsSet_onC() + language "C" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct runtime library is used when symbols are enabled. +-- + + function suite.runtimeLibraryIsDebug_onSymbolsNoOptimize() + symbols "On" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct warnings settings are used when extra warnings are enabled. +-- + + function suite.runtimeLibraryIsDebug_onExtraWarnings() + warnings "Extra" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct warnings settings are used when FatalWarnings are enabled. +-- + + function suite.runtimeLibraryIsDebug_onFatalWarnings() + flags { "FatalWarnings" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct warnings settings are used when no warnings are enabled. +-- + + function suite.runtimeLibraryIsDebug_onNoWarnings_whichDisablesAllOtherWarningsFlags() + flags { "FatalWarnings" } + warnings "Off" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct Detect64BitPortabilityProblems settings are used when _ACTION < "VS2008". +-- + + function suite._64BitPortabilityOn_onVS2005() + p.action.set("vs2005") + prepare() + test.capture [[ + + ]] + end + + function suite._64BitPortabilityOff_onVS2005_andCLR() + p.action.set("vs2005") + clr "On" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the correct warnings settings are used when no warnings are enabled. +-- + + function suite.runtimeLibraryIsDebug_onVS2005_NoWarnings() + p.action.set("vs2005") + warnings "Off" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Xbox 360 uses the same structure, but changes the element name. +-- + + function suite.looksGood_onXbox360() + system "Xbox360" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Check handling of forced includes. +-- + + function suite.forcedIncludeFiles() + forceincludes { "stdafx.h", "include/sys.h" } + prepare() + test.capture [[ + - ]] - end - - --- --- If a platform is specified, it should be included in the platform name. --- - - function suite.usesWin32_onX86() - workspace("MyWorkspace") - platforms { "x86" } - prepare() - test.capture [[ - - ]] - end - - function suite.defaultSettings_onNone() - kind "None" - prepare() - test.capture [[ - - ]] - end +-- +-- tests/actions/vstudio/vc200x/test_configuration.lua +-- Test the Visual Studio 2002-2008 project's Configuration block +-- Copyright (c) 2009-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vc200x_configuration") + local vstudio = p.vstudio + local vc200x = p.vstudio.vc200x + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2008") + wks, prj = test.createWorkspace() + end + + local function prepare() + local cfg = test.getconfig(prj, "Debug", (prj.platforms or wks.platforms or {})[1]) + vc200x.configuration(cfg, vstudio.projectConfig(cfg)) + end + + +-- +-- Check the results of generating with the default project settings +-- (C++ console application). +-- + + function suite.defaultSettings() + prepare() + test.capture [[ + + ]] + end + + +-- +-- If a platform is specified, it should be included in the platform name. +-- + + function suite.usesWin32_onX86() + workspace("MyWorkspace") + platforms { "x86" } + prepare() + test.capture [[ + + ]] + end + + function suite.defaultSettings_onNone() + kind "None" + prepare() + test.capture [[ + + ]] + end diff --git a/tests/actions/vstudio/vc200x/test_debug_settings.lua b/modules/vstudio/tests/vc200x/test_debug_settings.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_debug_settings.lua rename to modules/vstudio/tests/vc200x/test_debug_settings.lua diff --git a/tests/actions/vstudio/vc200x/test_excluded_configs.lua b/modules/vstudio/tests/vc200x/test_excluded_configs.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_excluded_configs.lua rename to modules/vstudio/tests/vc200x/test_excluded_configs.lua diff --git a/tests/actions/vstudio/vc200x/test_files.lua b/modules/vstudio/tests/vc200x/test_files.lua similarity index 94% rename from tests/actions/vstudio/vc200x/test_files.lua rename to modules/vstudio/tests/vc200x/test_files.lua index d503bcae..2fa1b17f 100644 --- a/tests/actions/vstudio/vc200x/test_files.lua +++ b/modules/vstudio/tests/vc200x/test_files.lua @@ -1,695 +1,695 @@ --- --- tests/actions/vstudio/vc200x/test_files.lua --- Validate generation of block in Visual Studio 200x projects. --- Copyright (c) 2009-2014 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vs200x_files") - local vc200x = p.vstudio.vc200x - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2008") - p.escaper(p.vstudio.vs2005.esc) - wks = test.createWorkspace() - end - - local function prepare() - prj = test.getproject(wks, 1) - vc200x.files(prj) - end - - --- --- Check the structure of an individual file element. --- - - function suite.file_onDefaults() - files { "hello.cpp" } - prepare() - test.capture [[ - - - - ]] - end - - --- --- Check the structure of a file contained in a folder. --- - - function suite.file_onSingleLevelFolder() - files { "src/hello.cpp", "so_long.cpp" } - prepare() - test.capture [[ - - - - - - - - ]] - end - - --- --- Check the structure of a file contained in multiple folders. --- - - function suite.file_onMultipleFolderLevels() - files { "src/greetings/hello.cpp", "so_long.cpp" } - prepare() - test.capture [[ - - - - - - - - - - ]] - end - - --- --- Check the structure of a file with a virtual path. --- - - function suite.file_onVpath() - files { "src/hello.cpp", "so_long.h" } - vpaths { ["Source Files"] = "**.cpp" } - prepare() - test.capture [[ - - - - - - ]] - end - - --- --- 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 [[ - - - - ]] - 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 [[ - - - - - - - - - - - - - - - - - - - ]] - end - - function suite.excludedFromBuild_onExcludeFlag() - files { "hello.cpp" } - filter "files:hello.cpp" - flags { "ExcludeFromBuild" } - prepare() - test.capture [[ - - - - - - - - - - ]] - end - - function suite.excludedFromBuild_onCustomBuildRule_excludedFile() - files { "hello.cg" } - filter "files:**.cg" - buildcommands { "cgc $(InputFile)" } - buildoutputs { "$(InputName).obj" } - filter "Debug" - removefiles { "hello.cg" } - prepare() - test.capture [[ - - - - - - - ]] - end - - function suite.excludedFromBuild_onCustomBuildRule_excludeFlag() - files { "hello.cg" } - filter "files:**.cg" - buildcommands { "cgc $(InputFile)" } - buildoutputs { "$(InputName).obj" } - flags { "ExcludeFromBuild" } - prepare() - test.capture [[ - - - - - - - ]] - end - - --- --- If a custom build rule is supplied, the custom build tool settings should be used. --- - - function suite.customBuildTool_onBuildRule() - files { "hello.x" } - filter "files:**.x" - buildmessage "Compiling $(InputFile)" - buildcommands { - 'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"', - 'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"' - } - buildoutputs { "$(IntDir)/$(InputName).obj" } - prepare() - test.capture [[ - - - - - - ]] - end - - function suite.customBuildTool_onBuildRuleMultipleBuildOutputs() - files { "hello.x" } - filter "files:**.x" - buildmessage "Compiling $(InputFile)" - buildcommands { - 'cp "$(InputFile)" "$(IntDir)/$(InputName).a"', - 'cp "$(InputFile)" "$(IntDir)/$(InputName).b"' - } - buildoutputs { "$(IntDir)/$(InputName).a", "$(IntDir)/$(InputName).b" } - prepare() - test.capture [[ - - - - - - ]] - end - - function suite.customBuildTool_onBuildRuleWithTokens() - files { "hello.x" } - objdir "../tmp/%{cfg.name}" - filter "files:**.x" - buildmessage "Compiling $(InputFile)" - buildcommands { - 'cxc -c %{file.relpath} -o %{cfg.objdir}/%{file.basename}.xo', - 'c2o -c %{cfg.objdir}/%{file.basename}.xo -o %{cfg.objdir}/%{file.basename}.obj' - } - buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" } - prepare() - test.capture [[ - - - - - - ]] - end - - function suite.customBuildTool_onBuildRuleWithAdditionalInputs() - files { "hello.x" } - filter "files:**.x" - buildmessage "Compiling $(InputFile)" - buildcommands { - 'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"', - 'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"' - } - buildoutputs { "$(IntDir)/$(InputName).obj" } - buildinputs { "common.x.inc", "common.x.inc2" } - prepare() - test.capture [[ - - - - - - ]] - end - - --- --- If two files at different folder levels have the same name, a different --- object file name should be used for each. --- - - function suite.uniqueObjectNames_onSourceNameCollision() - files { "hello.cpp", "greetings/hello.cpp" } - prepare() - test.capture [[ - - - - - - - - - - - - - - ]] - end - - --- --- Check handling of per-file forced includes. --- - - function suite.forcedIncludeFiles() - files { "hello.cpp" } - filter "files:**.cpp" - forceincludes { "../include/force1.h", "../include/force2.h" } - - prepare() - test.capture [[ - - - - - - - - - - - - - - - - - - - - - - - - - - - - block in Visual Studio 200x projects. +-- Copyright (c) 2009-2014 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vs200x_files") + local vc200x = p.vstudio.vc200x + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2008") + p.escaper(p.vstudio.vs2005.esc) + wks = test.createWorkspace() + end + + local function prepare() + prj = test.getproject(wks, 1) + vc200x.files(prj) + end + + +-- +-- Check the structure of an individual file element. +-- + + function suite.file_onDefaults() + files { "hello.cpp" } + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- Check the structure of a file contained in a folder. +-- + + function suite.file_onSingleLevelFolder() + files { "src/hello.cpp", "so_long.cpp" } + prepare() + test.capture [[ + + + + + + + + ]] + end + + +-- +-- Check the structure of a file contained in multiple folders. +-- + + function suite.file_onMultipleFolderLevels() + files { "src/greetings/hello.cpp", "so_long.cpp" } + prepare() + test.capture [[ + + + + + + + + + + ]] + end + + +-- +-- Check the structure of a file with a virtual path. +-- + + function suite.file_onVpath() + files { "src/hello.cpp", "so_long.h" } + vpaths { ["Source Files"] = "**.cpp" } + prepare() + test.capture [[ + + + + + + ]] + end + + +-- +-- 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 [[ + + + + ]] + 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 [[ + + + + + + + + + + + + + + + + + + + ]] + end + + function suite.excludedFromBuild_onExcludeFlag() + files { "hello.cpp" } + filter "files:hello.cpp" + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + + + + + + + + ]] + end + + function suite.excludedFromBuild_onCustomBuildRule_excludedFile() + files { "hello.cg" } + filter "files:**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + filter "Debug" + removefiles { "hello.cg" } + prepare() + test.capture [[ + + + + + + + ]] + end + + function suite.excludedFromBuild_onCustomBuildRule_excludeFlag() + files { "hello.cg" } + filter "files:**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + flags { "ExcludeFromBuild" } + prepare() + test.capture [[ + + + + + + + ]] + end + + +-- +-- If a custom build rule is supplied, the custom build tool settings should be used. +-- + + function suite.customBuildTool_onBuildRule() + files { "hello.x" } + filter "files:**.x" + buildmessage "Compiling $(InputFile)" + buildcommands { + 'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"', + 'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"' + } + buildoutputs { "$(IntDir)/$(InputName).obj" } + prepare() + test.capture [[ + + + + + + ]] + end + + function suite.customBuildTool_onBuildRuleMultipleBuildOutputs() + files { "hello.x" } + filter "files:**.x" + buildmessage "Compiling $(InputFile)" + buildcommands { + 'cp "$(InputFile)" "$(IntDir)/$(InputName).a"', + 'cp "$(InputFile)" "$(IntDir)/$(InputName).b"' + } + buildoutputs { "$(IntDir)/$(InputName).a", "$(IntDir)/$(InputName).b" } + prepare() + test.capture [[ + + + + + + ]] + end + + function suite.customBuildTool_onBuildRuleWithTokens() + files { "hello.x" } + objdir "../tmp/%{cfg.name}" + filter "files:**.x" + buildmessage "Compiling $(InputFile)" + buildcommands { + 'cxc -c %{file.relpath} -o %{cfg.objdir}/%{file.basename}.xo', + 'c2o -c %{cfg.objdir}/%{file.basename}.xo -o %{cfg.objdir}/%{file.basename}.obj' + } + buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" } + prepare() + test.capture [[ + + + + + + ]] + end + + function suite.customBuildTool_onBuildRuleWithAdditionalInputs() + files { "hello.x" } + filter "files:**.x" + buildmessage "Compiling $(InputFile)" + buildcommands { + 'cxc -c "$(InputFile)" -o "$(IntDir)/$(InputName).xo"', + 'c2o -c "$(IntDir)/$(InputName).xo" -o "$(IntDir)/$(InputName).obj"' + } + buildoutputs { "$(IntDir)/$(InputName).obj" } + buildinputs { "common.x.inc", "common.x.inc2" } + prepare() + test.capture [[ + + + + + + ]] + end + + +-- +-- If two files at different folder levels have the same name, a different +-- object file name should be used for each. +-- + + function suite.uniqueObjectNames_onSourceNameCollision() + files { "hello.cpp", "greetings/hello.cpp" } + prepare() + test.capture [[ + + + + + + + + + + + + + + ]] + end + + +-- +-- Check handling of per-file forced includes. +-- + + function suite.forcedIncludeFiles() + files { "hello.cpp" } + filter "files:**.cpp" + forceincludes { "../include/force1.h", "../include/force2.h" } + + prepare() + test.capture [[ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - ]] - end - - --- --- Verify the basic structure of windowed app linker block. --- - - function suite.onWindowedApp() - kind "WindowedApp" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the basic structure of shared library linker block. --- - - function suite.onSharedLib() - kind "SharedLib" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the basic structure of static library linker block. --- - - function suite.onStaticLib() - kind "StaticLib" - prepare() - test.capture [[ - - ]] - end - - --- --- Verify the handling of the Symbols flag. --- - - function suite.onSymbolsFlag() - symbols "On" - prepare() - test.capture [[ - - ]] - end - - --- --- If a module definition file is present, make sure it is specified. --- - - function suite.onModuleDefinitionFile() - files { "MyProject.def" } - prepare() - test.capture [[ - - ]] - end - - --- --- Links to system libraries should appear in the list, properly decorated. --- - - function suite.includesSystemLibs() - links { "GL", "GLU" } - prepare() - test.capture [[ - + ]] + end + + +-- +-- Verify the basic structure of windowed app linker block. +-- + + function suite.onWindowedApp() + kind "WindowedApp" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure of shared library linker block. +-- + + function suite.onSharedLib() + kind "SharedLib" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the basic structure of static library linker block. +-- + + function suite.onStaticLib() + kind "StaticLib" + prepare() + test.capture [[ + + ]] + end + + +-- +-- Verify the handling of the Symbols flag. +-- + + function suite.onSymbolsFlag() + symbols "On" + prepare() + test.capture [[ + + ]] + end + + +-- +-- If a module definition file is present, make sure it is specified. +-- + + function suite.onModuleDefinitionFile() + files { "MyProject.def" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- Links to system libraries should appear in the list, properly decorated. +-- + + function suite.includesSystemLibs() + links { "GL", "GLU" } + prepare() + test.capture [[ + - ]] - end - - --- --- If manifest file(s) are present, they should be listed. --- - - function suite.listsFiles_onManifests() - files { "hello.c", "project1.manifest", "goodbye.c", "project2.manifest" } - prepare() - test.capture [[ - - ]] - end +-- +-- tests/actions/vstudio/vc200x/test_manifest_block.lua +-- Validate generation of VCManifest elements Visual Studio 200x C/C++ projects. +-- Copyright (c) 2009-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs200x_manifest_block") + local vc200x = p.vstudio.vc200x + + +-- +-- Setup/teardown +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2008") + wks, prj = test.createWorkspace() + end + + local function prepare() + local cfg = test.getconfig(prj, "Debug") + vc200x.VCManifestTool(cfg) + end + + +-- +-- The manifest tool should empty if there are no manifest files. +-- + + function suite.isEmpty_onNoManifests() + files { "hello.c" } + prepare() + test.capture [[ + + ]] + end + + +-- +-- If manifest file(s) are present, they should be listed. +-- + + function suite.listsFiles_onManifests() + files { "hello.c", "project1.manifest", "goodbye.c", "project2.manifest" } + prepare() + test.capture [[ + + ]] + end diff --git a/tests/actions/vstudio/vc200x/test_nmake_settings.lua b/modules/vstudio/tests/vc200x/test_nmake_settings.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_nmake_settings.lua rename to modules/vstudio/tests/vc200x/test_nmake_settings.lua diff --git a/tests/actions/vstudio/vc200x/test_platforms.lua b/modules/vstudio/tests/vc200x/test_platforms.lua old mode 100755 new mode 100644 similarity index 94% rename from tests/actions/vstudio/vc200x/test_platforms.lua rename to modules/vstudio/tests/vc200x/test_platforms.lua index ab3782dc..3ad18271 --- a/tests/actions/vstudio/vc200x/test_platforms.lua +++ b/modules/vstudio/tests/vc200x/test_platforms.lua @@ -1,97 +1,97 @@ --- --- tests/actions/vstudio/vc200x/test_platforms.lua --- Test the Visual Studio 2002-2008 project's Platforms block --- Copyright (c) 2009-2012 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vc200x_platforms") - local vc200x = p.vstudio.vc200x - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2008") - wks = test.createWorkspace() - end - - local function prepare() - prj = test.getproject(wks, 1) - vc200x.platforms(prj) - end - - --- --- If no architectures are specified, Win32 should be the default. --- - - function suite.win32Listed_onNoPlatforms() - prepare() - test.capture [[ - - - - ]] - end - - --- --- If multiple configurations use the same architecture, it should --- still only be listed once. --- - - function suite.architectureListedOnlyOnce_onMultipleConfigurations() - platforms { "Static", "Dynamic" } - prepare() - test.capture [[ - - - - ]] - end - - --- --- If multiple architectures are used, they should all be listed. --- - - function suite.allArchitecturesListed_onMultipleArchitectures() - platforms { "x86", "x86_64" } - prepare() - test.capture [[ - - - - - ]] - end - - --- --- Verify the Xbox360 platform. --- - - function suite.platformIsCorrect_onXbox360() - platforms { "Xbox360" } - prepare() - test.capture [[ - - - - ]] - end +-- +-- tests/actions/vstudio/vc200x/test_platforms.lua +-- Test the Visual Studio 2002-2008 project's Platforms block +-- Copyright (c) 2009-2012 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vc200x_platforms") + local vc200x = p.vstudio.vc200x + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2008") + wks = test.createWorkspace() + end + + local function prepare() + prj = test.getproject(wks, 1) + vc200x.platforms(prj) + end + + +-- +-- If no architectures are specified, Win32 should be the default. +-- + + function suite.win32Listed_onNoPlatforms() + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- If multiple configurations use the same architecture, it should +-- still only be listed once. +-- + + function suite.architectureListedOnlyOnce_onMultipleConfigurations() + platforms { "Static", "Dynamic" } + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- If multiple architectures are used, they should all be listed. +-- + + function suite.allArchitecturesListed_onMultipleArchitectures() + platforms { "x86", "x86_64" } + prepare() + test.capture [[ + + + + + ]] + end + + +-- +-- Verify the Xbox360 platform. +-- + + function suite.platformIsCorrect_onXbox360() + platforms { "Xbox360" } + prepare() + test.capture [[ + + + + ]] + end diff --git a/tests/actions/vstudio/vc200x/test_project.lua b/modules/vstudio/tests/vc200x/test_project.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_project.lua rename to modules/vstudio/tests/vc200x/test_project.lua diff --git a/tests/actions/vstudio/vc200x/test_project_refs.lua b/modules/vstudio/tests/vc200x/test_project_refs.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_project_refs.lua rename to modules/vstudio/tests/vc200x/test_project_refs.lua diff --git a/tests/actions/vstudio/vc200x/test_resource_compiler.lua b/modules/vstudio/tests/vc200x/test_resource_compiler.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_resource_compiler.lua rename to modules/vstudio/tests/vc200x/test_resource_compiler.lua diff --git a/tests/actions/vstudio/vc200x/test_user_file.lua b/modules/vstudio/tests/vc200x/test_user_file.lua similarity index 100% rename from tests/actions/vstudio/vc200x/test_user_file.lua rename to modules/vstudio/tests/vc200x/test_user_file.lua diff --git a/tests/actions/vstudio/vc2010/test_assembly_refs.lua b/modules/vstudio/tests/vc2010/test_assembly_refs.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_assembly_refs.lua rename to modules/vstudio/tests/vc2010/test_assembly_refs.lua diff --git a/tests/actions/vstudio/vc2010/test_build_events.lua b/modules/vstudio/tests/vc2010/test_build_events.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_build_events.lua rename to modules/vstudio/tests/vc2010/test_build_events.lua diff --git a/tests/actions/vstudio/vc2010/test_build_log.lua b/modules/vstudio/tests/vc2010/test_build_log.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_build_log.lua rename to modules/vstudio/tests/vc2010/test_build_log.lua diff --git a/tests/actions/vstudio/vc2010/test_character_set.lua b/modules/vstudio/tests/vc2010/test_character_set.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_character_set.lua rename to modules/vstudio/tests/vc2010/test_character_set.lua diff --git a/tests/actions/vstudio/vc2010/test_compile_settings.lua b/modules/vstudio/tests/vc2010/test_compile_settings.lua similarity index 95% rename from tests/actions/vstudio/vc2010/test_compile_settings.lua rename to modules/vstudio/tests/vc2010/test_compile_settings.lua index 563f6bd2..420cc68f 100644 --- a/tests/actions/vstudio/vc2010/test_compile_settings.lua +++ b/modules/vstudio/tests/vc2010/test_compile_settings.lua @@ -1,1159 +1,1159 @@ --- --- tests/actions/vstudio/vc2010/test_compile_settings.lua --- Validate compiler settings in Visual Studio 2010 C/C++ projects. --- Copyright (c) 2011-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vs2010_compile_settings") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks, prj = test.createWorkspace() - end - - local function prepare(platform) - local cfg = test.getconfig(prj, "Debug", platform) - vc2010.clCompile(cfg) - end - - --- --- Check the basic element structure with default settings. ---- - - function suite.defaultSettings() - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - ---- --- Test precompiled header handling; the header should be treated as --- a plain string value, with no path manipulation applied, since it --- needs to match the value of the #include statement used in the --- project code. ---- - - function suite.usePrecompiledHeaders_onPrecompiledHeaders() - location "build" - pchheader "include/afxwin.h" - prepare() - test.capture [[ - - Use - include/afxwin.h - ]] - end - - ---- --- The NoPCH flag should override any other PCH settings. ---- - - function suite.noPrecompiledHeaders_onNoPCH() - pchheader "afxwin.h" - flags "NoPCH" - prepare() - test.capture [[ - - NotUsing - ]] - end - - --- --- If extra warnings is specified, pump up the volume. --- - - function suite.warningLevel_onExtraWarnings() - warnings "Extra" - prepare() - test.capture [[ - - NotUsing - Level4 - ]] - end - --- --- If the warnings are disabled, mute all warnings. --- - - function suite.warningLevel_onNoWarnings() - warnings "Off" - prepare() - test.capture [[ - - NotUsing - TurnOffAllWarnings - ]] - end - --- --- If warnings are turned off, the fatal warnings flags should --- not be generated. --- - - function suite.warningLevel_onNoWarningsOverOtherWarningsFlags() - flags { "FatalWarnings" } - warnings "Off" - prepare() - test.capture [[ - - NotUsing - TurnOffAllWarnings - ]] - end - --- --- Disable specific warnings. --- - - function suite.disableSpecificWarnings() - disablewarnings { "disable" } - prepare() - test.capture [[ - - NotUsing - Level3 - disable;%(DisableSpecificWarnings) - ]] - end - --- --- Specific warnings as errors. --- - - function suite.specificWarningsAsErrors() - fatalwarnings { "fatal" } - prepare() - test.capture [[ - - NotUsing - Level3 - fatal;%(TreatSpecificWarningsAsErrors) - ]] - end - --- --- Check the optimization flags. --- - - function suite.optimization_onOptimize() - optimize "On" - prepare() - test.capture [[ - - NotUsing - Level3 - Full - true - true - false - true - ]] - end - - function suite.optimization_onOptimizeSize() - optimize "Size" - prepare() - test.capture [[ - - NotUsing - Level3 - MinSpace - true - true - false - true - ]] - end - - function suite.optimization_onOptimizeSpeed() - optimize "Speed" - prepare() - test.capture [[ - - NotUsing - Level3 - MaxSpeed - true - true - false - true - ]] - end - - function suite.optimization_onOptimizeFull() - optimize "Full" - prepare() - test.capture [[ - - NotUsing - Level3 - Full - true - true - false - true - ]] - end - - function suite.optimization_onOptimizeOff() - optimize "Off" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - function suite.optimization_onOptimizeDebug() - optimize "Debug" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - function suite.omitFrames_onNoFramePointer() - flags "NoFramePointer" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - --- --- If defines are specified, the element should be added. --- - - function suite.preprocessorDefinitions_onDefines() - defines { "DEBUG", "_DEBUG" } - prepare() - test.capture [[ - - NotUsing - Level3 - DEBUG;_DEBUG;%(PreprocessorDefinitions) - ]] - end - - --- --- If defines are specified with escapable characters, they should be escaped. --- - - function suite.preprocessorDefinitions_onDefines() - p.escaper(p.vstudio.vs2010.esc) - defines { "&", "<", ">" } - prepare() - test.capture [[ - - NotUsing - Level3 - &;<;>;%(PreprocessorDefinitions) - ]] - p.escaper(nil) - end - - --- --- If undefines are specified, the element should be added. --- - - function suite.preprocessorDefinitions_onUnDefines() - undefines { "DEBUG", "_DEBUG" } - prepare() - test.capture [[ - - NotUsing - Level3 - DEBUG;_DEBUG;%(UndefinePreprocessorDefinitions) - ]] - end - - --- --- If build options are specified, the element should be specified. --- - - function suite.additionalOptions_onBuildOptions() - buildoptions { "/xyz", "/abc" } - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - /xyz /abc %(AdditionalOptions) - ]] - end - - --- --- If include directories are specified, the should be added. --- - - function suite.additionalIncludeDirs_onIncludeDirs() - includedirs { "include/lua", "include/zlib" } - prepare() - test.capture [[ - - NotUsing - Level3 - include\lua;include\zlib;%(AdditionalIncludeDirectories) - ]] - end - - - --- --- Ensure macros are not truncated (see issue #63) --- - - - function suite.additionalIncludeDirs_onIncludeDirs_with_vs_macros() - includedirs { "$(Macro1)/foo/bar/$(Macro2)/baz" } - prepare() - test.capture [[ - - NotUsing - Level3 - $(Macro1)\foo\bar\$(Macro2)\baz;%(AdditionalIncludeDirectories) - ]] - end - - --- --- If include directories are specified, the should be added. --- - - function suite.additionalUsingDirs_onUsingDirs() - usingdirs { "include/lua", "include/zlib" } - prepare() - test.capture [[ - - NotUsing - Level3 - include\lua;include\zlib;%(AdditionalUsingDirectories) - ]] - end - --- --- Turn off minimal rebuilds if the NoMinimalRebuild flag is set. --- - - function suite.minimalRebuild_onNoMinimalRebuild() - flags "NoMinimalRebuild" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - --- --- Can't minimal rebuild with the C7 debugging format. --- - - function suite.minimalRebuild_onC7() - debugformat "C7" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - --- --- If the StaticRuntime flag is specified, add the element. --- - - function suite.runtimeLibrary_onStaticRuntime() - flags { "StaticRuntime" } - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - MultiThreaded - ]] - end - - function suite.runtimeLibrary_onStaticRuntimeAndSymbols() - flags { "StaticRuntime" } - symbols "On" - prepare() - test.capture [[ - - NotUsing - Level3 - EditAndContinue - Disabled - MultiThreadedDebug - ]] - end - - --- --- Add if FatalWarnings flag is set. --- - - function suite.treatWarningsAsError_onFatalWarnings() - flags { "FatalCompileWarnings" } - prepare() - test.capture [[ - - NotUsing - Level3 - true - ]] - end - - --- --- Check the handling of the Symbols flag. --- - - function suite.onDefaultSymbols() - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - function suite.onNoSymbols() - symbols "Off" - prepare() - test.capture [[ - - NotUsing - Level3 - None - Disabled - - ]] - end - - function suite.onSymbols() - symbols "On" - prepare() - test.capture [[ - - NotUsing - Level3 - EditAndContinue - Disabled - - ]] - end - - --- --- Check the handling of the C7 debug information format. --- - - function suite.onC7DebugFormat() - symbols "On" - debugformat "c7" - prepare() - test.capture [[ - - NotUsing - Level3 - OldStyle - Disabled - ]] - end - - --- --- Verify character handling. --- - - function suite.wchar_onNative() - flags "NativeWChar" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - function suite.wchar_onNoNative() - flags "NoNativeWChar" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - --- --- Check exception handling and RTTI. --- - - function suite.exceptions_onNoExceptions() - exceptionhandling "Off" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - - function suite.exceptions_onNoExceptionsVS2013() - exceptionhandling "Off" - p.action.set("vs2013") - prepare() - test.capture [[ - - NotUsing - Level3 - _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) - Disabled - false - ]] - end - - - function suite.exceptions_onSEH() - exceptionhandling "SEH" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - Async - ]] - end - - function suite.runtimeTypeInfo_onNoRTTI() - rtti "Off" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - function suite.runtimeTypeInfo_onNoBufferSecurityCheck() - flags "NoBufferSecurityCheck" - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - --- --- On Win32 builds, use the Edit-and-Continue debug information format. --- - - function suite.debugFormat_onWin32() - symbols "On" - architecture "x86" - prepare() - test.capture [[ - - NotUsing - Level3 - EditAndContinue - ]] - end - - --- --- Edit-and-Continue is not support on 64-bit builds. --- - - function suite.debugFormat_onWin64() - symbols "On" - architecture "x86_64" - prepare() - test.capture [[ - - NotUsing - Level3 - ProgramDatabase - ]] - end - - --- --- Check the handling of the editandcontinue flag. --- - - function suite.debugFormat_onEditAndContinueOff() - symbols "On" - editandcontinue "Off" - prepare() - test.capture [[ - - NotUsing - Level3 - ProgramDatabase - ]] - end - --- --- Check the handling of the editandcontinue flag. --- - - function suite.debugFormat_onFastLinkBuild() - symbols "FastLink" - editandcontinue "Off" - prepare() - test.capture [[ - - NotUsing - Level3 - ProgramDatabase - ]] - end - - --- --- Edit-and-Continue is not supported for optimized builds. --- - - function suite.debugFormat_onOptimizedBuild() - symbols "On" - optimize "On" - prepare() - test.capture [[ - - NotUsing - Level3 - ProgramDatabase - ]] - end - - - --- --- Edit-and-Continue is not supported for Managed builds. --- - - function suite.debugFormat_onManagedCode() - symbols "On" - clr "On" - prepare() - test.capture [[ - - NotUsing - Level3 - ProgramDatabase - ]] - end - - --- --- Check handling of forced includes. --- - - function suite.forcedIncludeFiles() - forceincludes { "stdafx.h", "include/sys.h" } - prepare() - test.capture [[ - - NotUsing - Level3 - stdafx.h;include\sys.h - ]] - end - - function suite.forcedUsingFiles() - forceusings { "stdafx.h", "include/sys.h" } - prepare() - test.capture [[ - - NotUsing - Level3 - stdafx.h;include\sys.h - ]] - end - - --- --- Check handling of the NoRuntimeChecks flag. --- - - function suite.onNoRuntimeChecks() - flags { "NoRuntimeChecks" } - prepare() - test.capture [[ - - NotUsing - Level3 - Default - ]] - end - - --- --- Check handling of the EnableMultiProcessorCompile flag. --- - - function suite.onMultiProcessorCompile() - flags { "MultiProcessorCompile" } - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - true - ]] - end - - --- --- Check handling of the ReleaseRuntime flag; should override the --- default behavior of linking the debug runtime when symbols are --- enabled with no optimizations. --- - - function suite.releaseRuntime_onStaticAndReleaseRuntime() - flags { "ReleaseRuntime", "StaticRuntime" } - symbols "On" - prepare() - test.capture [[ - - NotUsing - Level3 - EditAndContinue - Disabled - MultiThreaded - ]] - end - - --- --- Check handling of the OmitDefaultLibrary flag. --- - - function suite.onOmitDefaultLibrary() - flags { "OmitDefaultLibrary" } - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - --- --- Check handling of the explicitly disabling symbols. --- Note: VS2013 and older have a bug with setting --- DebugInformationFormat to None. The workaround --- is to leave the field blank. --- - function suite.onNoSymbols() - symbols 'Off' - prepare() - test.capture [[ - - NotUsing - Level3 - - Disabled - ]] - end - - --- --- VS2015 and newer can use DebugInformationFormat None. --- - function suite.onNoSymbolsVS2015() - symbols 'Off' - p.action.set("vs2015") - prepare() - test.capture [[ - - NotUsing - Level3 - None - Disabled - ]] - end - - --- --- Check handling of the stringpooling api --- - function suite.onStringPoolingOff() - stringpooling 'Off' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - function suite.onStringPoolingOn() - stringpooling 'On' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - function suite.onStringPoolingNotSpecified() - optimize "On" - prepare() - test.capture [[ - - NotUsing - Level3 - Full - true - true - false - true - ]] - end - - - --- --- Check handling of the floatingpointexceptions api --- - function suite.onFloatingPointExceptionsOff() - floatingpointexceptions 'Off' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - function suite.onFloatingPointExceptionsOn() - floatingpointexceptions 'On' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - function suite.onFloatingPointExceptionsNotSpecified() - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - - --- --- Check handling of the functionlevellinking api --- - function suite.onFunctionLevelLinkingOff() - functionlevellinking 'Off' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - function suite.onFunctionLevelLinkingOn() - functionlevellinking 'On' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - function suite.onFunctionLevelLinkingNotSpecified() - optimize "On" - prepare() - test.capture [[ - - NotUsing - Level3 - Full - true - ]] - end - - - --- --- Check handling of the intrinsics api --- - function suite.onIntrinsicsOff() - intrinsics 'Off' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - false - ]] - end - - function suite.onIntrinsicsOn() - intrinsics 'On' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - true - ]] - end - - function suite.onIntrinsicsNotSpecified() - optimize "On" - prepare() - test.capture [[ - - NotUsing - Level3 - Full - true - true - false - true - ]] - end - - - --- --- Check handling of the language api --- - function suite.onLanguageC() - language 'C' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - function suite.onLanguageCpp() - language 'C++' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - --- --- Check handling of the compileAs api --- - function suite.onCompileAsC() - compileas 'C' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - CompileAsC - - ]] - end - - function suite.onCompileAsCpp() - compileas 'C++' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - CompileAsCpp - - ]] - end - - --- --- Check handling of the C++14 & C++17 api --- - - function suite.onLanguage_Cpp14_VS2010() - cppdialect 'C++14' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - function suite.onLanguage_Cpp14_VS2015() - p.action.set("vs2015") - - cppdialect 'C++14' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - /std:c++14 %(AdditionalOptions) - - ]] - end - - function suite.onLanguage_Cpp14_VS2017() - p.action.set("vs2017") - - cppdialect 'C++14' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - stdcpp14 - - ]] - end - - function suite.onLanguage_Cpp17_VS2010() - cppdialect 'C++17' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - - ]] - end - - function suite.onLanguage_Cpp17_VS2015() - p.action.set("vs2015") - - cppdialect 'C++17' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - /std:c++latest %(AdditionalOptions) - - ]] - end - - function suite.onLanguage_Cpp17_VS2017() - p.action.set("vs2017") - - cppdialect 'C++17' - prepare() - test.capture [[ - - NotUsing - Level3 - Disabled - stdcpplatest - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_compile_settings.lua +-- Validate compiler settings in Visual Studio 2010 C/C++ projects. +-- Copyright (c) 2011-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vs2010_compile_settings") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks, prj = test.createWorkspace() + end + + local function prepare(platform) + local cfg = test.getconfig(prj, "Debug", platform) + vc2010.clCompile(cfg) + end + + +-- +-- Check the basic element structure with default settings. +--- + + function suite.defaultSettings() + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + +--- +-- Test precompiled header handling; the header should be treated as +-- a plain string value, with no path manipulation applied, since it +-- needs to match the value of the #include statement used in the +-- project code. +--- + + function suite.usePrecompiledHeaders_onPrecompiledHeaders() + location "build" + pchheader "include/afxwin.h" + prepare() + test.capture [[ + + Use + include/afxwin.h + ]] + end + + +--- +-- The NoPCH flag should override any other PCH settings. +--- + + function suite.noPrecompiledHeaders_onNoPCH() + pchheader "afxwin.h" + flags "NoPCH" + prepare() + test.capture [[ + + NotUsing + ]] + end + + +-- +-- If extra warnings is specified, pump up the volume. +-- + + function suite.warningLevel_onExtraWarnings() + warnings "Extra" + prepare() + test.capture [[ + + NotUsing + Level4 + ]] + end + +-- +-- If the warnings are disabled, mute all warnings. +-- + + function suite.warningLevel_onNoWarnings() + warnings "Off" + prepare() + test.capture [[ + + NotUsing + TurnOffAllWarnings + ]] + end + +-- +-- If warnings are turned off, the fatal warnings flags should +-- not be generated. +-- + + function suite.warningLevel_onNoWarningsOverOtherWarningsFlags() + flags { "FatalWarnings" } + warnings "Off" + prepare() + test.capture [[ + + NotUsing + TurnOffAllWarnings + ]] + end + +-- +-- Disable specific warnings. +-- + + function suite.disableSpecificWarnings() + disablewarnings { "disable" } + prepare() + test.capture [[ + + NotUsing + Level3 + disable;%(DisableSpecificWarnings) + ]] + end + +-- +-- Specific warnings as errors. +-- + + function suite.specificWarningsAsErrors() + fatalwarnings { "fatal" } + prepare() + test.capture [[ + + NotUsing + Level3 + fatal;%(TreatSpecificWarningsAsErrors) + ]] + end + +-- +-- Check the optimization flags. +-- + + function suite.optimization_onOptimize() + optimize "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Full + true + true + false + true + ]] + end + + function suite.optimization_onOptimizeSize() + optimize "Size" + prepare() + test.capture [[ + + NotUsing + Level3 + MinSpace + true + true + false + true + ]] + end + + function suite.optimization_onOptimizeSpeed() + optimize "Speed" + prepare() + test.capture [[ + + NotUsing + Level3 + MaxSpeed + true + true + false + true + ]] + end + + function suite.optimization_onOptimizeFull() + optimize "Full" + prepare() + test.capture [[ + + NotUsing + Level3 + Full + true + true + false + true + ]] + end + + function suite.optimization_onOptimizeOff() + optimize "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + function suite.optimization_onOptimizeDebug() + optimize "Debug" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + function suite.omitFrames_onNoFramePointer() + flags "NoFramePointer" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + +-- +-- If defines are specified, the element should be added. +-- + + function suite.preprocessorDefinitions_onDefines() + defines { "DEBUG", "_DEBUG" } + prepare() + test.capture [[ + + NotUsing + Level3 + DEBUG;_DEBUG;%(PreprocessorDefinitions) + ]] + end + + +-- +-- If defines are specified with escapable characters, they should be escaped. +-- + + function suite.preprocessorDefinitions_onDefines() + p.escaper(p.vstudio.vs2010.esc) + defines { "&", "<", ">" } + prepare() + test.capture [[ + + NotUsing + Level3 + &;<;>;%(PreprocessorDefinitions) + ]] + p.escaper(nil) + end + + +-- +-- If undefines are specified, the element should be added. +-- + + function suite.preprocessorDefinitions_onUnDefines() + undefines { "DEBUG", "_DEBUG" } + prepare() + test.capture [[ + + NotUsing + Level3 + DEBUG;_DEBUG;%(UndefinePreprocessorDefinitions) + ]] + end + + +-- +-- If build options are specified, the element should be specified. +-- + + function suite.additionalOptions_onBuildOptions() + buildoptions { "/xyz", "/abc" } + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + /xyz /abc %(AdditionalOptions) + ]] + end + + +-- +-- If include directories are specified, the should be added. +-- + + function suite.additionalIncludeDirs_onIncludeDirs() + includedirs { "include/lua", "include/zlib" } + prepare() + test.capture [[ + + NotUsing + Level3 + include\lua;include\zlib;%(AdditionalIncludeDirectories) + ]] + end + + + +-- +-- Ensure macros are not truncated (see issue #63) +-- + + + function suite.additionalIncludeDirs_onIncludeDirs_with_vs_macros() + includedirs { "$(Macro1)/foo/bar/$(Macro2)/baz" } + prepare() + test.capture [[ + + NotUsing + Level3 + $(Macro1)\foo\bar\$(Macro2)\baz;%(AdditionalIncludeDirectories) + ]] + end + + +-- +-- If include directories are specified, the should be added. +-- + + function suite.additionalUsingDirs_onUsingDirs() + usingdirs { "include/lua", "include/zlib" } + prepare() + test.capture [[ + + NotUsing + Level3 + include\lua;include\zlib;%(AdditionalUsingDirectories) + ]] + end + +-- +-- Turn off minimal rebuilds if the NoMinimalRebuild flag is set. +-- + + function suite.minimalRebuild_onNoMinimalRebuild() + flags "NoMinimalRebuild" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + +-- +-- Can't minimal rebuild with the C7 debugging format. +-- + + function suite.minimalRebuild_onC7() + debugformat "C7" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + +-- +-- If the StaticRuntime flag is specified, add the element. +-- + + function suite.runtimeLibrary_onStaticRuntime() + flags { "StaticRuntime" } + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + MultiThreaded + ]] + end + + function suite.runtimeLibrary_onStaticRuntimeAndSymbols() + flags { "StaticRuntime" } + symbols "On" + prepare() + test.capture [[ + + NotUsing + Level3 + EditAndContinue + Disabled + MultiThreadedDebug + ]] + end + + +-- +-- Add if FatalWarnings flag is set. +-- + + function suite.treatWarningsAsError_onFatalWarnings() + flags { "FatalCompileWarnings" } + prepare() + test.capture [[ + + NotUsing + Level3 + true + ]] + end + + +-- +-- Check the handling of the Symbols flag. +-- + + function suite.onDefaultSymbols() + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + function suite.onNoSymbols() + symbols "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + None + Disabled + + ]] + end + + function suite.onSymbols() + symbols "On" + prepare() + test.capture [[ + + NotUsing + Level3 + EditAndContinue + Disabled + + ]] + end + + +-- +-- Check the handling of the C7 debug information format. +-- + + function suite.onC7DebugFormat() + symbols "On" + debugformat "c7" + prepare() + test.capture [[ + + NotUsing + Level3 + OldStyle + Disabled + ]] + end + + +-- +-- Verify character handling. +-- + + function suite.wchar_onNative() + flags "NativeWChar" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + function suite.wchar_onNoNative() + flags "NoNativeWChar" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + +-- +-- Check exception handling and RTTI. +-- + + function suite.exceptions_onNoExceptions() + exceptionhandling "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + + function suite.exceptions_onNoExceptionsVS2013() + exceptionhandling "Off" + p.action.set("vs2013") + prepare() + test.capture [[ + + NotUsing + Level3 + _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) + Disabled + false + ]] + end + + + function suite.exceptions_onSEH() + exceptionhandling "SEH" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + Async + ]] + end + + function suite.runtimeTypeInfo_onNoRTTI() + rtti "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + function suite.runtimeTypeInfo_onNoBufferSecurityCheck() + flags "NoBufferSecurityCheck" + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + +-- +-- On Win32 builds, use the Edit-and-Continue debug information format. +-- + + function suite.debugFormat_onWin32() + symbols "On" + architecture "x86" + prepare() + test.capture [[ + + NotUsing + Level3 + EditAndContinue + ]] + end + + +-- +-- Edit-and-Continue is not support on 64-bit builds. +-- + + function suite.debugFormat_onWin64() + symbols "On" + architecture "x86_64" + prepare() + test.capture [[ + + NotUsing + Level3 + ProgramDatabase + ]] + end + + +-- +-- Check the handling of the editandcontinue flag. +-- + + function suite.debugFormat_onEditAndContinueOff() + symbols "On" + editandcontinue "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + ProgramDatabase + ]] + end + +-- +-- Check the handling of the editandcontinue flag. +-- + + function suite.debugFormat_onFastLinkBuild() + symbols "FastLink" + editandcontinue "Off" + prepare() + test.capture [[ + + NotUsing + Level3 + ProgramDatabase + ]] + end + + +-- +-- Edit-and-Continue is not supported for optimized builds. +-- + + function suite.debugFormat_onOptimizedBuild() + symbols "On" + optimize "On" + prepare() + test.capture [[ + + NotUsing + Level3 + ProgramDatabase + ]] + end + + + +-- +-- Edit-and-Continue is not supported for Managed builds. +-- + + function suite.debugFormat_onManagedCode() + symbols "On" + clr "On" + prepare() + test.capture [[ + + NotUsing + Level3 + ProgramDatabase + ]] + end + + +-- +-- Check handling of forced includes. +-- + + function suite.forcedIncludeFiles() + forceincludes { "stdafx.h", "include/sys.h" } + prepare() + test.capture [[ + + NotUsing + Level3 + stdafx.h;include\sys.h + ]] + end + + function suite.forcedUsingFiles() + forceusings { "stdafx.h", "include/sys.h" } + prepare() + test.capture [[ + + NotUsing + Level3 + stdafx.h;include\sys.h + ]] + end + + +-- +-- Check handling of the NoRuntimeChecks flag. +-- + + function suite.onNoRuntimeChecks() + flags { "NoRuntimeChecks" } + prepare() + test.capture [[ + + NotUsing + Level3 + Default + ]] + end + + +-- +-- Check handling of the EnableMultiProcessorCompile flag. +-- + + function suite.onMultiProcessorCompile() + flags { "MultiProcessorCompile" } + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + true + ]] + end + + +-- +-- Check handling of the ReleaseRuntime flag; should override the +-- default behavior of linking the debug runtime when symbols are +-- enabled with no optimizations. +-- + + function suite.releaseRuntime_onStaticAndReleaseRuntime() + flags { "ReleaseRuntime", "StaticRuntime" } + symbols "On" + prepare() + test.capture [[ + + NotUsing + Level3 + EditAndContinue + Disabled + MultiThreaded + ]] + end + + +-- +-- Check handling of the OmitDefaultLibrary flag. +-- + + function suite.onOmitDefaultLibrary() + flags { "OmitDefaultLibrary" } + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + +-- +-- Check handling of the explicitly disabling symbols. +-- Note: VS2013 and older have a bug with setting +-- DebugInformationFormat to None. The workaround +-- is to leave the field blank. +-- + function suite.onNoSymbols() + symbols 'Off' + prepare() + test.capture [[ + + NotUsing + Level3 + + Disabled + ]] + end + + +-- +-- VS2015 and newer can use DebugInformationFormat None. +-- + function suite.onNoSymbolsVS2015() + symbols 'Off' + p.action.set("vs2015") + prepare() + test.capture [[ + + NotUsing + Level3 + None + Disabled + ]] + end + + +-- +-- Check handling of the stringpooling api +-- + function suite.onStringPoolingOff() + stringpooling 'Off' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + function suite.onStringPoolingOn() + stringpooling 'On' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + function suite.onStringPoolingNotSpecified() + optimize "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Full + true + true + false + true + ]] + end + + + +-- +-- Check handling of the floatingpointexceptions api +-- + function suite.onFloatingPointExceptionsOff() + floatingpointexceptions 'Off' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + function suite.onFloatingPointExceptionsOn() + floatingpointexceptions 'On' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + function suite.onFloatingPointExceptionsNotSpecified() + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + + +-- +-- Check handling of the functionlevellinking api +-- + function suite.onFunctionLevelLinkingOff() + functionlevellinking 'Off' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + function suite.onFunctionLevelLinkingOn() + functionlevellinking 'On' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + function suite.onFunctionLevelLinkingNotSpecified() + optimize "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Full + true + ]] + end + + + +-- +-- Check handling of the intrinsics api +-- + function suite.onIntrinsicsOff() + intrinsics 'Off' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + false + ]] + end + + function suite.onIntrinsicsOn() + intrinsics 'On' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + true + ]] + end + + function suite.onIntrinsicsNotSpecified() + optimize "On" + prepare() + test.capture [[ + + NotUsing + Level3 + Full + true + true + false + true + ]] + end + + + +-- +-- Check handling of the language api +-- + function suite.onLanguageC() + language 'C' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + function suite.onLanguageCpp() + language 'C++' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + +-- +-- Check handling of the compileAs api +-- + function suite.onCompileAsC() + compileas 'C' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + CompileAsC + + ]] + end + + function suite.onCompileAsCpp() + compileas 'C++' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + CompileAsCpp + + ]] + end + + +-- +-- Check handling of the C++14 & C++17 api +-- + + function suite.onLanguage_Cpp14_VS2010() + cppdialect 'C++14' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + function suite.onLanguage_Cpp14_VS2015() + p.action.set("vs2015") + + cppdialect 'C++14' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + /std:c++14 %(AdditionalOptions) + + ]] + end + + function suite.onLanguage_Cpp14_VS2017() + p.action.set("vs2017") + + cppdialect 'C++14' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + stdcpp14 + + ]] + end + + function suite.onLanguage_Cpp17_VS2010() + cppdialect 'C++17' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + + ]] + end + + function suite.onLanguage_Cpp17_VS2015() + p.action.set("vs2015") + + cppdialect 'C++17' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + /std:c++latest %(AdditionalOptions) + + ]] + end + + function suite.onLanguage_Cpp17_VS2017() + p.action.set("vs2017") + + cppdialect 'C++17' + prepare() + test.capture [[ + + NotUsing + Level3 + Disabled + stdcpplatest + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_config_props.lua b/modules/vstudio/tests/vc2010/test_config_props.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/vc2010/test_config_props.lua rename to modules/vstudio/tests/vc2010/test_config_props.lua diff --git a/tests/actions/vstudio/vc2010/test_debug_settings.lua b/modules/vstudio/tests/vc2010/test_debug_settings.lua old mode 100755 new mode 100644 similarity index 95% rename from tests/actions/vstudio/vc2010/test_debug_settings.lua rename to modules/vstudio/tests/vc2010/test_debug_settings.lua index e43c09ff..ff384ab1 --- a/tests/actions/vstudio/vc2010/test_debug_settings.lua +++ b/modules/vstudio/tests/vc2010/test_debug_settings.lua @@ -1,103 +1,103 @@ --- --- tests/actions/vstudio/vc2010/test_debug_settings.lua --- Validate handling of the working directory for debugging. --- Copyright (c) 2011-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vs2010_debug_settings") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks, prj = test.createWorkspace() - end - - local function prepare() - local cfg = test.getconfig(prj, "Debug") - vc2010.debugSettings(cfg) - end - - --- --- If no debug directory is set, nothing should be output. --- - - function suite.noOutput_onNoDebugDir() - prepare() - test.isemptycapture() - end - --- --- The debug command should specified relative to the project location. --- - - function suite.debugCommand_isProjectRelative() - debugcommand "bin/emulator.exe" - prepare() - - expectedPath = path.translate(path.getabsolute(os.getcwd())) .. "\\bin\\emulator.exe" - expected = "" .. expectedPath .. "" - expected = expected .. "\nWindowsLocalDebugger" - test.capture (expected) - end - - --- --- The debug directory should specified relative to the project location. --- - - function suite.debugDirectory_isProjectRelative() - debugdir "bin/debug" - prepare() - test.capture [[ -bin\debug -WindowsLocalDebugger - ]] - end - --- --- Verify handling of debug arguments. --- - - function suite.debuggerCommandArgs_onDebugArgs() - debugargs { "arg1", "arg2", "arg1" } - prepare() - test.capture [[ -arg1 arg2 arg1 - ]] - end - --- --- Check the handling of debug environment variables. --- - - function suite.localDebuggerEnv_onDebugEnv() - debugenvs { "key=value" } - prepare() - test.capture [[ -key=value - ]] - end - --- --- Multiple environment variables should be separated by a "\n" sequence. --- - - function suite.localDebuggerEnv_onDebugEnv() - debugenvs { "key=value", "foo=bar" } - prepare() - test.capture [[ -key=value -foo=bar - ]] - end - +-- +-- tests/actions/vstudio/vc2010/test_debug_settings.lua +-- Validate handling of the working directory for debugging. +-- Copyright (c) 2011-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vs2010_debug_settings") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks, prj = test.createWorkspace() + end + + local function prepare() + local cfg = test.getconfig(prj, "Debug") + vc2010.debugSettings(cfg) + end + + +-- +-- If no debug directory is set, nothing should be output. +-- + + function suite.noOutput_onNoDebugDir() + prepare() + test.isemptycapture() + end + +-- +-- The debug command should specified relative to the project location. +-- + + function suite.debugCommand_isProjectRelative() + debugcommand "bin/emulator.exe" + prepare() + + expectedPath = path.translate(path.getabsolute(os.getcwd())) .. "\\bin\\emulator.exe" + expected = "" .. expectedPath .. "" + expected = expected .. "\nWindowsLocalDebugger" + test.capture (expected) + end + + +-- +-- The debug directory should specified relative to the project location. +-- + + function suite.debugDirectory_isProjectRelative() + debugdir "bin/debug" + prepare() + test.capture [[ +bin\debug +WindowsLocalDebugger + ]] + end + +-- +-- Verify handling of debug arguments. +-- + + function suite.debuggerCommandArgs_onDebugArgs() + debugargs { "arg1", "arg2", "arg1" } + prepare() + test.capture [[ +arg1 arg2 arg1 + ]] + end + +-- +-- Check the handling of debug environment variables. +-- + + function suite.localDebuggerEnv_onDebugEnv() + debugenvs { "key=value" } + prepare() + test.capture [[ +key=value + ]] + end + +-- +-- Multiple environment variables should be separated by a "\n" sequence. +-- + + function suite.localDebuggerEnv_onDebugEnv() + debugenvs { "key=value", "foo=bar" } + prepare() + test.capture [[ +key=value +foo=bar + ]] + end + diff --git a/tests/actions/vstudio/vc2010/test_ensure_nuget_imports.lua b/modules/vstudio/tests/vc2010/test_ensure_nuget_imports.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_ensure_nuget_imports.lua rename to modules/vstudio/tests/vc2010/test_ensure_nuget_imports.lua diff --git a/tests/actions/vstudio/vc2010/test_excluded_configs.lua b/modules/vstudio/tests/vc2010/test_excluded_configs.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_excluded_configs.lua rename to modules/vstudio/tests/vc2010/test_excluded_configs.lua diff --git a/tests/actions/vstudio/vc2010/test_extension_settings.lua b/modules/vstudio/tests/vc2010/test_extension_settings.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_extension_settings.lua rename to modules/vstudio/tests/vc2010/test_extension_settings.lua diff --git a/tests/actions/vstudio/vc2010/test_extension_targets.lua b/modules/vstudio/tests/vc2010/test_extension_targets.lua similarity index 95% rename from tests/actions/vstudio/vc2010/test_extension_targets.lua rename to modules/vstudio/tests/vc2010/test_extension_targets.lua index 1503cf40..71b12c9d 100644 --- a/tests/actions/vstudio/vc2010/test_extension_targets.lua +++ b/modules/vstudio/tests/vc2010/test_extension_targets.lua @@ -1,108 +1,108 @@ --- --- tests/actions/vstudio/vc2010/test_extension_targets.lua --- Check the import extension targets block of a VS 2010 project. --- Copyright (c) 2014 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2010_extension_targets") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks - - function suite.setup() - p.action.set("vs2010") - rule "MyRules" - rule "MyOtherRules" - wks = test.createWorkspace() - end - - local function prepare() - local prj = test.getproject(wks) - vc2010.importExtensionTargets(prj) - end - - --- --- Writes an empty element when no custom rules are specified. --- - - function suite.structureIsCorrect_onDefaultValues() - prepare() - test.capture [[ - - - ]] - end - - - --- --- Writes entries for each project scoped custom rules path. --- - - function suite.addsImport_onEachRulesFile() - rules { "MyRules", "MyOtherRules" } - prepare() - test.capture [[ - - - - - ]] - end - - --- --- Writes entries for NuGet packages. --- - - function suite.addsImport_onEachNuGetPackage() - nuget { "boost:1.59.0-b1", "sdl2.v140:2.0.3", "sdl2.v140.redist:2.0.3" } - prepare() - test.capture [[ - - - - - - ]] - end - - --- --- Rule files use a project relative path. --- - - function suite.usesProjectRelativePaths() - rules { "MyRules" } - location "build" - prepare() - test.capture [[ - - - - ]] - end - - --- --- the asm 'file category' should add the right target. --- - - function suite.hasAssemblyFiles() - files { "test.asm" } - location "build" - prepare() - test.capture [[ - - - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_extension_targets.lua +-- Check the import extension targets block of a VS 2010 project. +-- Copyright (c) 2014 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2010_extension_targets") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks + + function suite.setup() + p.action.set("vs2010") + rule "MyRules" + rule "MyOtherRules" + wks = test.createWorkspace() + end + + local function prepare() + local prj = test.getproject(wks) + vc2010.importExtensionTargets(prj) + end + + +-- +-- Writes an empty element when no custom rules are specified. +-- + + function suite.structureIsCorrect_onDefaultValues() + prepare() + test.capture [[ + + + ]] + end + + + +-- +-- Writes entries for each project scoped custom rules path. +-- + + function suite.addsImport_onEachRulesFile() + rules { "MyRules", "MyOtherRules" } + prepare() + test.capture [[ + + + + + ]] + end + + +-- +-- Writes entries for NuGet packages. +-- + + function suite.addsImport_onEachNuGetPackage() + nuget { "boost:1.59.0-b1", "sdl2.v140:2.0.3", "sdl2.v140.redist:2.0.3" } + prepare() + test.capture [[ + + + + + + ]] + end + + +-- +-- Rule files use a project relative path. +-- + + function suite.usesProjectRelativePaths() + rules { "MyRules" } + location "build" + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- the asm 'file category' should add the right target. +-- + + function suite.hasAssemblyFiles() + files { "test.asm" } + location "build" + prepare() + test.capture [[ + + + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/modules/vstudio/tests/vc2010/test_files.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/vc2010/test_files.lua rename to modules/vstudio/tests/vc2010/test_files.lua diff --git a/tests/actions/vstudio/vc2010/test_filter_ids.lua b/modules/vstudio/tests/vc2010/test_filter_ids.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_filter_ids.lua rename to modules/vstudio/tests/vc2010/test_filter_ids.lua diff --git a/tests/actions/vstudio/vc2010/test_filters.lua b/modules/vstudio/tests/vc2010/test_filters.lua similarity index 94% rename from tests/actions/vstudio/vc2010/test_filters.lua rename to modules/vstudio/tests/vc2010/test_filters.lua index d895412c..62a26f49 100644 --- a/tests/actions/vstudio/vc2010/test_filters.lua +++ b/modules/vstudio/tests/vc2010/test_filters.lua @@ -1,201 +1,201 @@ --- --- tests/actions/vstudio/vc2010/test_filters.lua --- Validate generation of file filter blocks in Visual Studio 2010 C/C++ projects. --- Copyright (c) 2011-2014 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2010_filters") - local vc2010 = p.vstudio.vc2010 - - --- --- Setup/teardown --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks = test.createWorkspace() - end - - local function prepare(group) - prj = test.getproject(wks) - vc2010.filterGroups(prj) - end - - --- --- Check contents of the different file groups. --- - - function suite.itemGroup_onClInclude() - files { "hello.h" } - prepare() - test.capture [[ - - - - ]] - end - - function suite.itemGroup_onResourceSection() - files { "hello.rc" } - prepare() - test.capture [[ - - - - ]] - end - - function suite.itemGroup_onNoneSection() - files { "hello.txt" } - prepare() - test.capture [[ - - - - ]] - end - - function suite.itemGroup_onMixed() - files { "hello.c", "hello.h", "hello.rc", "hello.txt" } - prepare() - test.capture [[ - - - - - - - - - - - - - ]] - end - - --- --- Files with a build rule go into a custom build section. --- - - function suite.itemGroup_onBuildRule() - files { "hello.cg" } - filter "files:**.cg" - buildcommands { "cgc $(InputFile)" } - buildoutputs { "$(InputName).obj" } - prepare("CustomBuild") - test.capture [[ - - - - ]] - end - - function suite.itemGroup_onSingleConfigBuildRule() - files { "hello.cg" } - filter { "Release", "files:**.cg" } - buildcommands { "cgc $(InputFile)" } - buildoutputs { "$(InputName).obj" } - prepare("CustomBuild") - test.capture [[ - - - - ]] - 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() - test.capture [[ - - - - - ]] - end - --- --- Check the filter with a real path. --- - - function suite.filter_onRealPath() - files { "src/hello.c", "hello.h" } - prepare() - test.capture [[ - - - - - - src - - - ]] - end - --- --- Check the filter with a virtual path. --- - - function suite.filter_onVpath() - files { "src/hello.c", "hello.h" } - vpaths { ["Source Files"] = "**.c" } - prepare() - test.capture [[ - - - - - - Source Files - - - ]] - end - - --- --- Check handling of files using custom rules. --- - - function suite.filter_onCustomRule() - rules "Animation" - files { "hello.dae" } - - rule "Animation" - fileextension ".dae" - - prepare() - test.capture [[ - - - - ]] - end - - --- --- Check handling of .asm files --- - function suite.itemGroup_onNoneSection() - files { "hello.asm" } - prepare() - test.capture [[ - - - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_filters.lua +-- Validate generation of file filter blocks in Visual Studio 2010 C/C++ projects. +-- Copyright (c) 2011-2014 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2010_filters") + local vc2010 = p.vstudio.vc2010 + + +-- +-- Setup/teardown +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks = test.createWorkspace() + end + + local function prepare(group) + prj = test.getproject(wks) + vc2010.filterGroups(prj) + end + + +-- +-- Check contents of the different file groups. +-- + + function suite.itemGroup_onClInclude() + files { "hello.h" } + prepare() + test.capture [[ + + + + ]] + end + + function suite.itemGroup_onResourceSection() + files { "hello.rc" } + prepare() + test.capture [[ + + + + ]] + end + + function suite.itemGroup_onNoneSection() + files { "hello.txt" } + prepare() + test.capture [[ + + + + ]] + end + + function suite.itemGroup_onMixed() + files { "hello.c", "hello.h", "hello.rc", "hello.txt" } + prepare() + test.capture [[ + + + + + + + + + + + + + ]] + end + + +-- +-- Files with a build rule go into a custom build section. +-- + + function suite.itemGroup_onBuildRule() + files { "hello.cg" } + filter "files:**.cg" + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + prepare("CustomBuild") + test.capture [[ + + + + ]] + end + + function suite.itemGroup_onSingleConfigBuildRule() + files { "hello.cg" } + filter { "Release", "files:**.cg" } + buildcommands { "cgc $(InputFile)" } + buildoutputs { "$(InputName).obj" } + prepare("CustomBuild") + test.capture [[ + + + + ]] + 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() + test.capture [[ + + + + + ]] + end + +-- +-- Check the filter with a real path. +-- + + function suite.filter_onRealPath() + files { "src/hello.c", "hello.h" } + prepare() + test.capture [[ + + + + + + src + + + ]] + end + +-- +-- Check the filter with a virtual path. +-- + + function suite.filter_onVpath() + files { "src/hello.c", "hello.h" } + vpaths { ["Source Files"] = "**.c" } + prepare() + test.capture [[ + + + + + + Source Files + + + ]] + end + + +-- +-- Check handling of files using custom rules. +-- + + function suite.filter_onCustomRule() + rules "Animation" + files { "hello.dae" } + + rule "Animation" + fileextension ".dae" + + prepare() + test.capture [[ + + + + ]] + end + + +-- +-- Check handling of .asm files +-- + function suite.itemGroup_onNoneSection() + files { "hello.asm" } + prepare() + test.capture [[ + + + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_floatingpoint.lua b/modules/vstudio/tests/vc2010/test_floatingpoint.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_floatingpoint.lua rename to modules/vstudio/tests/vc2010/test_floatingpoint.lua diff --git a/tests/actions/vstudio/vc2010/test_globals.lua b/modules/vstudio/tests/vc2010/test_globals.lua old mode 100755 new mode 100644 similarity index 96% rename from tests/actions/vstudio/vc2010/test_globals.lua rename to modules/vstudio/tests/vc2010/test_globals.lua index 898a15a6..7c9c8070 --- a/tests/actions/vstudio/vc2010/test_globals.lua +++ b/modules/vstudio/tests/vc2010/test_globals.lua @@ -1,255 +1,255 @@ --- --- tests/actions/vstudio/vc2010/test_globals.lua --- Validate generation of the Globals property group. --- Copyright (c) 2011-2014 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vs2010_globals") - local vc2010 = p.vstudio.vc2010 - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks = test.createWorkspace() - end - - local function prepare() - prj = test.getproject(wks, 1) - vc2010.globals(prj) - end - - --- --- Check the structure with the default project values. --- - - function suite.structureIsCorrect_onDefaultValues() - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - Win32Proj - MyProject - - ]] - end - - --- --- Ensure CLR support gets enabled for Managed C++ projects. --- - - function suite.keywordIsCorrect_onManagedC() - clr "On" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - v4.0 - ManagedCProj - MyProject - - ]] - end - - --- --- Ensure custom target framework version correct for Managed C++ projects. --- - - function suite.frameworkVersionIsCorrect_onSpecificVersion() - clr "On" - dotnetframework "4.5" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - v4.5 - ManagedCProj - MyProject - - ]] - end - - function suite.frameworkVersionIsCorrect_on2013() - p.action.set("vs2013") - clr "On" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - true - v4.5 - ManagedCProj - MyProject - - ]] - end - --- --- Omit Keyword and RootNamespace for non-Windows projects. --- - - function suite.noKeyword_onNotWindows() - system "Linux" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - - ]] - end - - --- --- Include Keyword and RootNamespace for mixed system projects. --- - - function suite.includeKeyword_onMixedConfigs() - filter "Debug" - system "Windows" - filter "Release" - system "Linux" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - Win32Proj - MyProject - - ]] - end - - --- --- Makefile projects set new keyword and drop the root namespace. --- - - function suite.keywordIsCorrect_onMakefile() - kind "Makefile" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - MakeFileProj - - ]] - end - - function suite.keywordIsCorrect_onNone() - kind "None" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - MakeFileProj - - ]] - end - - ---- --- If the project name differs from the project filename, output a --- element to indicate that. ---- - - function suite.addsFilename_onDifferentFilename() - filename "MyProject_2012" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - Win32Proj - MyProject - MyProject - - ]] - end - - --- --- VS 2013 adds the to get rid --- of spurious warnings when the same filename is present in different --- configurations. --- - - function suite.structureIsCorrect_on2013() - p.action.set("vs2013") - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - true - Win32Proj - MyProject - - ]] - end - - --- --- VS 2015 adds the to allow developers --- to target different versions of the Windows SDK. --- - - function suite.windowsTargetPlatformVersionMissing_on2013Default() - _ACTION = "vs2013" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - true - Win32Proj - MyProject - - ]] - end - - function suite.windowsTargetPlatformVersionMissing_on2013() - _ACTION = "vs2013" - systemversion "10.0.10240.0" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - true - Win32Proj - MyProject - - ]] - end - - function suite.windowsTargetPlatformVersionMissing_on2015Default() - _ACTION = "vs2015" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - true - Win32Proj - MyProject - - ]] - end - - function suite.windowsTargetPlatformVersion_on2015() - _ACTION = "vs2015" - systemversion "10.0.10240.0" - prepare() - test.capture [[ - - {42B5DBC6-AE1F-903D-F75D-41E363076E92} - true - Win32Proj - MyProject - 10.0.10240.0 - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_globals.lua +-- Validate generation of the Globals property group. +-- Copyright (c) 2011-2014 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vs2010_globals") + local vc2010 = p.vstudio.vc2010 + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks = test.createWorkspace() + end + + local function prepare() + prj = test.getproject(wks, 1) + vc2010.globals(prj) + end + + +-- +-- Check the structure with the default project values. +-- + + function suite.structureIsCorrect_onDefaultValues() + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + Win32Proj + MyProject + + ]] + end + + +-- +-- Ensure CLR support gets enabled for Managed C++ projects. +-- + + function suite.keywordIsCorrect_onManagedC() + clr "On" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + v4.0 + ManagedCProj + MyProject + + ]] + end + + +-- +-- Ensure custom target framework version correct for Managed C++ projects. +-- + + function suite.frameworkVersionIsCorrect_onSpecificVersion() + clr "On" + dotnetframework "4.5" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + v4.5 + ManagedCProj + MyProject + + ]] + end + + function suite.frameworkVersionIsCorrect_on2013() + p.action.set("vs2013") + clr "On" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + v4.5 + ManagedCProj + MyProject + + ]] + end + +-- +-- Omit Keyword and RootNamespace for non-Windows projects. +-- + + function suite.noKeyword_onNotWindows() + system "Linux" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + + ]] + end + + +-- +-- Include Keyword and RootNamespace for mixed system projects. +-- + + function suite.includeKeyword_onMixedConfigs() + filter "Debug" + system "Windows" + filter "Release" + system "Linux" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + Win32Proj + MyProject + + ]] + end + + +-- +-- Makefile projects set new keyword and drop the root namespace. +-- + + function suite.keywordIsCorrect_onMakefile() + kind "Makefile" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + MakeFileProj + + ]] + end + + function suite.keywordIsCorrect_onNone() + kind "None" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + MakeFileProj + + ]] + end + + +--- +-- If the project name differs from the project filename, output a +-- element to indicate that. +--- + + function suite.addsFilename_onDifferentFilename() + filename "MyProject_2012" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + Win32Proj + MyProject + MyProject + + ]] + end + + +-- +-- VS 2013 adds the to get rid +-- of spurious warnings when the same filename is present in different +-- configurations. +-- + + function suite.structureIsCorrect_on2013() + p.action.set("vs2013") + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + +-- +-- VS 2015 adds the to allow developers +-- to target different versions of the Windows SDK. +-- + + function suite.windowsTargetPlatformVersionMissing_on2013Default() + _ACTION = "vs2013" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + function suite.windowsTargetPlatformVersionMissing_on2013() + _ACTION = "vs2013" + systemversion "10.0.10240.0" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + function suite.windowsTargetPlatformVersionMissing_on2015Default() + _ACTION = "vs2015" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + function suite.windowsTargetPlatformVersion_on2015() + _ACTION = "vs2015" + systemversion "10.0.10240.0" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + 10.0.10240.0 + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_header.lua b/modules/vstudio/tests/vc2010/test_header.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_header.lua rename to modules/vstudio/tests/vc2010/test_header.lua diff --git a/tests/actions/vstudio/vc2010/test_imagexex_settings.lua b/modules/vstudio/tests/vc2010/test_imagexex_settings.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_imagexex_settings.lua rename to modules/vstudio/tests/vc2010/test_imagexex_settings.lua diff --git a/tests/actions/vstudio/vc2010/test_item_def_group.lua b/modules/vstudio/tests/vc2010/test_item_def_group.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_item_def_group.lua rename to modules/vstudio/tests/vc2010/test_item_def_group.lua diff --git a/tests/actions/vstudio/vc2010/test_language_settings.lua b/modules/vstudio/tests/vc2010/test_language_settings.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_language_settings.lua rename to modules/vstudio/tests/vc2010/test_language_settings.lua diff --git a/tests/actions/vstudio/vc2010/test_language_targets.lua b/modules/vstudio/tests/vc2010/test_language_targets.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_language_targets.lua rename to modules/vstudio/tests/vc2010/test_language_targets.lua diff --git a/tests/actions/vstudio/vc2010/test_link.lua b/modules/vstudio/tests/vc2010/test_link.lua similarity index 95% rename from tests/actions/vstudio/vc2010/test_link.lua rename to modules/vstudio/tests/vc2010/test_link.lua index 2a40533f..7f28ad7e 100644 --- a/tests/actions/vstudio/vc2010/test_link.lua +++ b/modules/vstudio/tests/vc2010/test_link.lua @@ -1,590 +1,590 @@ --- --- tests/actions/vstudio/vc2010/test_link.lua --- Validate linking and project references in Visual Studio 2010 C/C++ projects. --- Copyright (c) 2011-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2010_link") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks, prj = test.createWorkspace() - kind "SharedLib" - end - - local function prepare(platform) - local cfg = test.getconfig(prj, "Debug", platform) - vc2010.linker(cfg) - end - - --- --- Check the basic element structure with default settings. --- - - function suite.defaultSettings() - kind "SharedLib" - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - - ]] - end - - --- --- Check the basic element structure with a release build. --- - - function suite.defaultSettings_onOptimize() - optimize "On" - prepare() - test.capture [[ - - Windows - true - true - bin\Debug\MyProject.lib - - ]] - end - - --- --- Check subsystem values with each project kind. --- - - function suite.subsystem_onConsoleApp() - kind "ConsoleApp" - prepare() - test.capture [[ - - Console - ]] - end - - function suite.subsystem_onWindowedApp() - kind "WindowedApp" - prepare() - test.capture [[ - - Windows - ]] - end - - function suite.subsystem_onSharedLib() - kind "SharedLib" - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - - ]] - end - - function suite.subsystem_onStaticLib() - kind "StaticLib" - prepare() - test.capture [[ - - Windows - - ]] - end - - --- --- Test the handling of the entrypoint API. --- - function suite.onEntryPoint() - kind "ConsoleApp" - entrypoint "foobar" - prepare() - test.capture [[ - - Console - foobar - - ]] - end - - --- --- Test the handling of the NoImplicitLink flag. --- - - function suite.linkDependencies_onNoImplicitLink() - flags "NoImplicitLink" - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - - - false - - ]] - end - --- --- Test the handling of the Symbols flag. --- - - function suite.generateDebugInfo_onSymbolsOn_on2010() - p.action.set("vs2010") - symbols "On" - prepare() - test.capture [[ - - Windows - true - ]] - end - - function suite.generateDebugInfo_onSymbolsFastLink_on2010() - p.action.set("vs2010") - symbols "FastLink" - prepare() - test.capture [[ - - Windows - true - ]] - end - - function suite.generateDebugInfo_onSymbolsFull_on2010() - p.action.set("vs2010") - symbols "Full" - prepare() - test.capture [[ - - Windows - true - ]] - end - - function suite.generateDebugInfo_onSymbolsOn_on2015() - p.action.set("vs2015") - symbols "On" - prepare() - test.capture [[ - - Windows - true - ]] - end - - function suite.generateDebugInfo_onSymbolsFastLink_on2015() - p.action.set("vs2015") - symbols "FastLink" - prepare() - test.capture [[ - - Windows - true - DebugFastLink - ]] - end - - function suite.generateDebugInfo_onSymbolsFull_on2015() - p.action.set("vs2015") - symbols "Full" - prepare() - test.capture [[ - - Windows - true - ]] - end - - function suite.generateDebugInfo_onSymbolsFull_on2017() - p.action.set("vs2017") - symbols "Full" - prepare() - test.capture [[ - - Windows - DebugFull - ]] - end - --- --- Any system libraries specified in links() should be listed as --- additional dependencies. --- - - function suite.additionalDependencies_onSystemLinks() - links { "lua", "zlib" } - prepare() - test.capture [[ - - Windows - lua.lib;zlib.lib;%(AdditionalDependencies) - ]] - end - - function suite.additionalDependencies_onSystemLinksStatic() - kind "StaticLib" - links { "lua", "zlib" } - prepare() - test.capture [[ - - Windows - - - lua.lib;zlib.lib;%(AdditionalDependencies) - - ]] - end - - --- --- Any system libraries specified in links() with valid extensions should --- be listed with those extensions. --- - - function suite.additionalDependencies_onSystemLinksExtensions() - links { "lua.obj", "zlib.lib" } - prepare() - test.capture [[ - - Windows - lua.obj;zlib.lib;%(AdditionalDependencies) - ]] - end - - function suite.additionalDependencies_onSystemLinksExtensionsStatic() - kind "StaticLib" - links { "lua.obj", "zlib.lib" } - prepare() - test.capture [[ - - Windows - - - lua.obj;zlib.lib;%(AdditionalDependencies) - - ]] - end - - --- --- Any system libraries specified in links() with multiple dots should --- only have .lib appended to the end when no valid extension is found --- - - function suite.additionalDependencies_onSystemLinksExtensionsMultipleDots() - links { "lua.5.3.lib", "lua.5.4" } - prepare() - test.capture [[ - - Windows - lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies) - ]] - end - - function suite.additionalDependencies_onSystemLinksExtensionsMultipleDotsStatic() - kind "StaticLib" - links { "lua.5.3.lib", "lua.5.4" } - prepare() - test.capture [[ - - Windows - - - lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies) - - ]] - end - - --- --- Additional library directories should be specified, relative to the project. --- - - function suite.additionalLibraryDirectories_onLibDirs() - libdirs { "../lib", "../lib64" } - prepare() - test.capture [[ - - Windows - ..\lib;..\lib64;%(AdditionalLibraryDirectories) - ]] - end - - --- --- Sibling projects do not need to be listed in additional dependencies, as Visual --- Studio will link them implicitly. --- - - function suite.excludeSiblings() - links { "MyProject2" } - test.createproject(wks) - kind "SharedLib" - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - - ]] - end - - --- --- If the NoImplicitLink flag is set, all dependencies should be listed explicitly. --- - - function suite.includeSiblings_onNoImplicitLink() - flags { "NoImplicitLink" } - links { "MyProject2" } - test.createproject(wks) - kind "SharedLib" - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject2.lib;%(AdditionalDependencies) - bin\Debug\MyProject.lib - - - false - - ]] - end - - --- --- Static libraries do not link dependencies directly, to maintain --- compatibility with GCC and others. --- - - function suite.additionalDependencies_onSystemLinksAndStaticLib() - kind "StaticLib" - links { "lua", "zlib" } - libdirs { "../lib", "../lib64" } - prepare() - test.capture [[ - - Windows - - ]] - end - - --- --- Check handling of the import library settings. --- - - function suite.importLibrary_onImpLibDir() - implibdir "../lib" - prepare() - test.capture [[ - - Windows - ..\lib\MyProject.lib - - ]] - end - - - --- --- Check handling of additional options. --- - - function suite.additionalOptions_onNonStaticLib() - kind "SharedLib" - linkoptions { "/kupo" } - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - /kupo %(AdditionalOptions) - ]] - end - - function suite.additionalOptions_onStaticLib() - kind "StaticLib" - linkoptions { "/kupo" } - prepare() - test.capture [[ - - Windows - - - /kupo %(AdditionalOptions) - - ]] - end - - --- --- Enable reference optimizing if Optimize flag is specified. --- - - function suite.optimizeReferences_onOptimizeFlag() - optimize "On" - prepare() - test.capture [[ - - Windows - true - true - ]] - end - - --- --- Correctly handle module definition (.def) files. --- - - function suite.recognizesModuleDefinitionFile() - files { "hello.cpp", "hello.def" } - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - hello.def - - ]] - end - - --- --- Managed assembly references should not be listed in additional dependencies. --- - - function suite.ignoresAssemblyReferences() - links { "kernel32", "System.dll", "System.Data.dll" } - prepare() - test.capture [[ - - Windows - kernel32.lib;%(AdditionalDependencies) - ]] - end - - --- --- Xbox 360 doesn't list a subsystem or entry point. --- - - function suite.onXbox360() - kind "ConsoleApp" - system "Xbox360" - prepare() - test.capture [[ - ]] - end - --- --- Xbox 360 uses .lib for library extensions --- - function suite.libAdded_onXbox360SystemLibs() - kind "ConsoleApp" - system "Xbox360" - links { "user32" } - prepare() - test.capture [[ - - user32.lib;%(AdditionalDependencies) - - ]] - end - - --- --- Check handling of warning flags. --- - - function suite.fatalWarnings_onDynamicLink() - kind "ConsoleApp" - flags { "FatalLinkWarnings" } - prepare() - test.capture [[ - - Console - true - ]] - end - - function suite.fatalWarnings_onStaticLink() - kind "StaticLib" - flags { "FatalLinkWarnings" } - prepare() - test.capture [[ - - Windows - - - true - - ]] - end - - --- --- Test generating .map files. --- - - function suite.generateMapFile_onMapsFlag() - flags { "Maps" } - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - true - - ]] - end - --- --- Test ignoring default libraries with extensions specified. --- - - function suite.ignoreDefaultLibraries_WithExtensions() - ignoredefaultlibraries { "lib1.lib", "lib2.obj" } - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - lib1.lib;lib2.obj - - ]] - end - --- --- Test ignoring default libraries without extensions specified. --- - - function suite.ignoreDefaultLibraries_WithExtensions() - ignoredefaultlibraries { "lib1", "lib2.obj" } - prepare() - test.capture [[ - - Windows - bin\Debug\MyProject.lib - lib1.lib;lib2.obj - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_link.lua +-- Validate linking and project references in Visual Studio 2010 C/C++ projects. +-- Copyright (c) 2011-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2010_link") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks, prj = test.createWorkspace() + kind "SharedLib" + end + + local function prepare(platform) + local cfg = test.getconfig(prj, "Debug", platform) + vc2010.linker(cfg) + end + + +-- +-- Check the basic element structure with default settings. +-- + + function suite.defaultSettings() + kind "SharedLib" + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + + ]] + end + + +-- +-- Check the basic element structure with a release build. +-- + + function suite.defaultSettings_onOptimize() + optimize "On" + prepare() + test.capture [[ + + Windows + true + true + bin\Debug\MyProject.lib + + ]] + end + + +-- +-- Check subsystem values with each project kind. +-- + + function suite.subsystem_onConsoleApp() + kind "ConsoleApp" + prepare() + test.capture [[ + + Console + ]] + end + + function suite.subsystem_onWindowedApp() + kind "WindowedApp" + prepare() + test.capture [[ + + Windows + ]] + end + + function suite.subsystem_onSharedLib() + kind "SharedLib" + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + + ]] + end + + function suite.subsystem_onStaticLib() + kind "StaticLib" + prepare() + test.capture [[ + + Windows + + ]] + end + + +-- +-- Test the handling of the entrypoint API. +-- + function suite.onEntryPoint() + kind "ConsoleApp" + entrypoint "foobar" + prepare() + test.capture [[ + + Console + foobar + + ]] + end + + +-- +-- Test the handling of the NoImplicitLink flag. +-- + + function suite.linkDependencies_onNoImplicitLink() + flags "NoImplicitLink" + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + + + false + + ]] + end + +-- +-- Test the handling of the Symbols flag. +-- + + function suite.generateDebugInfo_onSymbolsOn_on2010() + p.action.set("vs2010") + symbols "On" + prepare() + test.capture [[ + + Windows + true + ]] + end + + function suite.generateDebugInfo_onSymbolsFastLink_on2010() + p.action.set("vs2010") + symbols "FastLink" + prepare() + test.capture [[ + + Windows + true + ]] + end + + function suite.generateDebugInfo_onSymbolsFull_on2010() + p.action.set("vs2010") + symbols "Full" + prepare() + test.capture [[ + + Windows + true + ]] + end + + function suite.generateDebugInfo_onSymbolsOn_on2015() + p.action.set("vs2015") + symbols "On" + prepare() + test.capture [[ + + Windows + true + ]] + end + + function suite.generateDebugInfo_onSymbolsFastLink_on2015() + p.action.set("vs2015") + symbols "FastLink" + prepare() + test.capture [[ + + Windows + true + DebugFastLink + ]] + end + + function suite.generateDebugInfo_onSymbolsFull_on2015() + p.action.set("vs2015") + symbols "Full" + prepare() + test.capture [[ + + Windows + true + ]] + end + + function suite.generateDebugInfo_onSymbolsFull_on2017() + p.action.set("vs2017") + symbols "Full" + prepare() + test.capture [[ + + Windows + DebugFull + ]] + end + +-- +-- Any system libraries specified in links() should be listed as +-- additional dependencies. +-- + + function suite.additionalDependencies_onSystemLinks() + links { "lua", "zlib" } + prepare() + test.capture [[ + + Windows + lua.lib;zlib.lib;%(AdditionalDependencies) + ]] + end + + function suite.additionalDependencies_onSystemLinksStatic() + kind "StaticLib" + links { "lua", "zlib" } + prepare() + test.capture [[ + + Windows + + + lua.lib;zlib.lib;%(AdditionalDependencies) + + ]] + end + + +-- +-- Any system libraries specified in links() with valid extensions should +-- be listed with those extensions. +-- + + function suite.additionalDependencies_onSystemLinksExtensions() + links { "lua.obj", "zlib.lib" } + prepare() + test.capture [[ + + Windows + lua.obj;zlib.lib;%(AdditionalDependencies) + ]] + end + + function suite.additionalDependencies_onSystemLinksExtensionsStatic() + kind "StaticLib" + links { "lua.obj", "zlib.lib" } + prepare() + test.capture [[ + + Windows + + + lua.obj;zlib.lib;%(AdditionalDependencies) + + ]] + end + + +-- +-- Any system libraries specified in links() with multiple dots should +-- only have .lib appended to the end when no valid extension is found +-- + + function suite.additionalDependencies_onSystemLinksExtensionsMultipleDots() + links { "lua.5.3.lib", "lua.5.4" } + prepare() + test.capture [[ + + Windows + lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies) + ]] + end + + function suite.additionalDependencies_onSystemLinksExtensionsMultipleDotsStatic() + kind "StaticLib" + links { "lua.5.3.lib", "lua.5.4" } + prepare() + test.capture [[ + + Windows + + + lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies) + + ]] + end + + +-- +-- Additional library directories should be specified, relative to the project. +-- + + function suite.additionalLibraryDirectories_onLibDirs() + libdirs { "../lib", "../lib64" } + prepare() + test.capture [[ + + Windows + ..\lib;..\lib64;%(AdditionalLibraryDirectories) + ]] + end + + +-- +-- Sibling projects do not need to be listed in additional dependencies, as Visual +-- Studio will link them implicitly. +-- + + function suite.excludeSiblings() + links { "MyProject2" } + test.createproject(wks) + kind "SharedLib" + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + + ]] + end + + +-- +-- If the NoImplicitLink flag is set, all dependencies should be listed explicitly. +-- + + function suite.includeSiblings_onNoImplicitLink() + flags { "NoImplicitLink" } + links { "MyProject2" } + test.createproject(wks) + kind "SharedLib" + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject2.lib;%(AdditionalDependencies) + bin\Debug\MyProject.lib + + + false + + ]] + end + + +-- +-- Static libraries do not link dependencies directly, to maintain +-- compatibility with GCC and others. +-- + + function suite.additionalDependencies_onSystemLinksAndStaticLib() + kind "StaticLib" + links { "lua", "zlib" } + libdirs { "../lib", "../lib64" } + prepare() + test.capture [[ + + Windows + + ]] + end + + +-- +-- Check handling of the import library settings. +-- + + function suite.importLibrary_onImpLibDir() + implibdir "../lib" + prepare() + test.capture [[ + + Windows + ..\lib\MyProject.lib + + ]] + end + + + +-- +-- Check handling of additional options. +-- + + function suite.additionalOptions_onNonStaticLib() + kind "SharedLib" + linkoptions { "/kupo" } + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + /kupo %(AdditionalOptions) + ]] + end + + function suite.additionalOptions_onStaticLib() + kind "StaticLib" + linkoptions { "/kupo" } + prepare() + test.capture [[ + + Windows + + + /kupo %(AdditionalOptions) + + ]] + end + + +-- +-- Enable reference optimizing if Optimize flag is specified. +-- + + function suite.optimizeReferences_onOptimizeFlag() + optimize "On" + prepare() + test.capture [[ + + Windows + true + true + ]] + end + + +-- +-- Correctly handle module definition (.def) files. +-- + + function suite.recognizesModuleDefinitionFile() + files { "hello.cpp", "hello.def" } + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + hello.def + + ]] + end + + +-- +-- Managed assembly references should not be listed in additional dependencies. +-- + + function suite.ignoresAssemblyReferences() + links { "kernel32", "System.dll", "System.Data.dll" } + prepare() + test.capture [[ + + Windows + kernel32.lib;%(AdditionalDependencies) + ]] + end + + +-- +-- Xbox 360 doesn't list a subsystem or entry point. +-- + + function suite.onXbox360() + kind "ConsoleApp" + system "Xbox360" + prepare() + test.capture [[ + ]] + end + +-- +-- Xbox 360 uses .lib for library extensions +-- + function suite.libAdded_onXbox360SystemLibs() + kind "ConsoleApp" + system "Xbox360" + links { "user32" } + prepare() + test.capture [[ + + user32.lib;%(AdditionalDependencies) + + ]] + end + + +-- +-- Check handling of warning flags. +-- + + function suite.fatalWarnings_onDynamicLink() + kind "ConsoleApp" + flags { "FatalLinkWarnings" } + prepare() + test.capture [[ + + Console + true + ]] + end + + function suite.fatalWarnings_onStaticLink() + kind "StaticLib" + flags { "FatalLinkWarnings" } + prepare() + test.capture [[ + + Windows + + + true + + ]] + end + + +-- +-- Test generating .map files. +-- + + function suite.generateMapFile_onMapsFlag() + flags { "Maps" } + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + true + + ]] + end + +-- +-- Test ignoring default libraries with extensions specified. +-- + + function suite.ignoreDefaultLibraries_WithExtensions() + ignoredefaultlibraries { "lib1.lib", "lib2.obj" } + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + lib1.lib;lib2.obj + + ]] + end + +-- +-- Test ignoring default libraries without extensions specified. +-- + + function suite.ignoreDefaultLibraries_WithExtensions() + ignoredefaultlibraries { "lib1", "lib2.obj" } + prepare() + test.capture [[ + + Windows + bin\Debug\MyProject.lib + lib1.lib;lib2.obj + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_manifest.lua b/modules/vstudio/tests/vc2010/test_manifest.lua similarity index 95% rename from tests/actions/vstudio/vc2010/test_manifest.lua rename to modules/vstudio/tests/vc2010/test_manifest.lua index 1cb1907f..0cc34e8f 100644 --- a/tests/actions/vstudio/vc2010/test_manifest.lua +++ b/modules/vstudio/tests/vc2010/test_manifest.lua @@ -1,54 +1,54 @@ --- --- tests/actions/vstudio/vc2010/test_manifest.lua --- Validate generation of Manifest block in Visual Studio 201x C/C++ projects. --- Copyright (c) 2009-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2010_manifest") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks, prj = test.createWorkspace() - kind "ConsoleApp" - end - - local function prepare(platform) - local cfg = test.getconfig(prj, "Debug", platform) - vc2010.manifest(cfg) - end - - --- --- Check the basic element structure with default settings. --- - - function suite.defaultSettings() - files { "source/test.manifest" } - prepare() - test.capture [[ - - source/test.manifest %(AdditionalManifestFiles) - - ]] - end - --- --- Check that there is no manifest when using static lib --- - - function suite.staticLib() - kind "StaticLib" - files { "test.manifest" } - prepare() - test.isemptycapture() - end +-- +-- tests/actions/vstudio/vc2010/test_manifest.lua +-- Validate generation of Manifest block in Visual Studio 201x C/C++ projects. +-- Copyright (c) 2009-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2010_manifest") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks, prj = test.createWorkspace() + kind "ConsoleApp" + end + + local function prepare(platform) + local cfg = test.getconfig(prj, "Debug", platform) + vc2010.manifest(cfg) + end + + +-- +-- Check the basic element structure with default settings. +-- + + function suite.defaultSettings() + files { "source/test.manifest" } + prepare() + test.capture [[ + + source/test.manifest %(AdditionalManifestFiles) + + ]] + end + +-- +-- Check that there is no manifest when using static lib +-- + + function suite.staticLib() + kind "StaticLib" + files { "test.manifest" } + prepare() + test.isemptycapture() + end diff --git a/tests/actions/vstudio/vc2010/test_nmake_props.lua b/modules/vstudio/tests/vc2010/test_nmake_props.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_nmake_props.lua rename to modules/vstudio/tests/vc2010/test_nmake_props.lua diff --git a/tests/actions/vstudio/vc2010/test_nuget_packages_config.lua b/modules/vstudio/tests/vc2010/test_nuget_packages_config.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_nuget_packages_config.lua rename to modules/vstudio/tests/vc2010/test_nuget_packages_config.lua diff --git a/tests/actions/vstudio/vc2010/test_output_props.lua b/modules/vstudio/tests/vc2010/test_output_props.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/vc2010/test_output_props.lua rename to modules/vstudio/tests/vc2010/test_output_props.lua diff --git a/tests/actions/vstudio/vc2010/test_platform_toolset.lua b/modules/vstudio/tests/vc2010/test_platform_toolset.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_platform_toolset.lua rename to modules/vstudio/tests/vc2010/test_platform_toolset.lua diff --git a/tests/actions/vstudio/vc2010/test_project_configs.lua b/modules/vstudio/tests/vc2010/test_project_configs.lua old mode 100755 new mode 100644 similarity index 96% rename from tests/actions/vstudio/vc2010/test_project_configs.lua rename to modules/vstudio/tests/vc2010/test_project_configs.lua index 989b9e04..3068f64c --- a/tests/actions/vstudio/vc2010/test_project_configs.lua +++ b/modules/vstudio/tests/vc2010/test_project_configs.lua @@ -1,106 +1,106 @@ --- --- tests/actions/vstudio/vc2010/test_project_configs.lua --- Test the Visual Studio 2010 project configurations item group. --- Copyright (c) 2009-2014 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vc2010_project_configs") - local vc2010 = p.vstudio.vc2010 - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - wks = test.createWorkspace() - end - - local function prepare() - prj = test.getproject(wks, 1) - vc2010.projectConfigurations(prj) - end - - --- --- If no architectures are specified, Win32 should be the default. --- - - function suite.win32Listed_onNoPlatforms() - prepare() - test.capture [[ - - - Debug - Win32 - - - Release - Win32 - - - ]] - end - - --- --- Visual Studio requires that all combinations of configurations and --- architectures be listed (even if some pairings would make no sense --- for our build, i.e. Win32 DLL DCRT|PS3). --- - - function suite.allArchitecturesListed_onMultipleArchitectures() - platforms { "32b", "64b" } - filter "platforms:32b" - architecture "x86" - filter "platforms:64b" - architecture "x86_64" - prepare() - test.capture [[ - - - Debug 32b - Win32 - - - Debug 32b - x64 - - - Debug 64b - Win32 - - - Debug 64b - x64 - - - ]] - end - - --- --- Sometimes unrolling the configuration-architecture combinations --- can cause duplicates. Make sure those get removed. --- - - function suite.allArchitecturesListed_onImplicitArchitectures() - platforms { "x86", "x86_64" } - prepare() - test.capture [[ - - - Debug - Win32 - - - Debug - x64 - - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_project_configs.lua +-- Test the Visual Studio 2010 project configurations item group. +-- Copyright (c) 2009-2014 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vc2010_project_configs") + local vc2010 = p.vstudio.vc2010 + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + wks = test.createWorkspace() + end + + local function prepare() + prj = test.getproject(wks, 1) + vc2010.projectConfigurations(prj) + end + + +-- +-- If no architectures are specified, Win32 should be the default. +-- + + function suite.win32Listed_onNoPlatforms() + prepare() + test.capture [[ + + + Debug + Win32 + + + Release + Win32 + + + ]] + end + + +-- +-- Visual Studio requires that all combinations of configurations and +-- architectures be listed (even if some pairings would make no sense +-- for our build, i.e. Win32 DLL DCRT|PS3). +-- + + function suite.allArchitecturesListed_onMultipleArchitectures() + platforms { "32b", "64b" } + filter "platforms:32b" + architecture "x86" + filter "platforms:64b" + architecture "x86_64" + prepare() + test.capture [[ + + + Debug 32b + Win32 + + + Debug 32b + x64 + + + Debug 64b + Win32 + + + Debug 64b + x64 + + + ]] + end + + +-- +-- Sometimes unrolling the configuration-architecture combinations +-- can cause duplicates. Make sure those get removed. +-- + + function suite.allArchitecturesListed_onImplicitArchitectures() + platforms { "x86", "x86_64" } + prepare() + test.capture [[ + + + Debug + Win32 + + + Debug + x64 + + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_project_refs.lua b/modules/vstudio/tests/vc2010/test_project_refs.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_project_refs.lua rename to modules/vstudio/tests/vc2010/test_project_refs.lua diff --git a/tests/actions/vstudio/vc2010/test_prop_sheet.lua b/modules/vstudio/tests/vc2010/test_prop_sheet.lua old mode 100755 new mode 100644 similarity index 100% rename from tests/actions/vstudio/vc2010/test_prop_sheet.lua rename to modules/vstudio/tests/vc2010/test_prop_sheet.lua diff --git a/tests/actions/vstudio/vc2010/test_resource_compile.lua b/modules/vstudio/tests/vc2010/test_resource_compile.lua old mode 100755 new mode 100644 similarity index 95% rename from tests/actions/vstudio/vc2010/test_resource_compile.lua rename to modules/vstudio/tests/vc2010/test_resource_compile.lua index 8135d557..95622840 --- a/tests/actions/vstudio/vc2010/test_resource_compile.lua +++ b/modules/vstudio/tests/vc2010/test_resource_compile.lua @@ -1,114 +1,114 @@ --- --- tests/actions/vstudio/vc2010/test_resource_compile.lua --- Validate resource compiler settings in Visual Studio 2010 C/C++ projects. --- Copyright (c) 2011-2013 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vs2010_resource_compiler") - local vc2010 = p.vstudio.vc2010 - local project = p.project - - --- --- Setup --- - - local wks, prj - - function suite.setup() - p.action.set("vs2010") - p.escaper(p.vstudio.vs2010.esc) - wks, prj = test.createWorkspace() - end - - local function prepare() - local cfg = test.getconfig(prj, "Debug") - vc2010.resourceCompile(cfg) - end - - --- --- Should only write the element if it is needed. --- - - function suite.excluded_onNoResourceFiles() - prepare() - test.isemptycapture() - end - - function suite.excluded_onNoSettings() - files { "hello.rc" } - prepare() - test.isemptycapture() - end - - function suite.skips_onXbox360() - files { "hello.rc" } - defines { "DEBUG" } - system "Xbox360" - prepare() - test.isemptycapture() - end - - --- --- If defines are specified, the element should be added. --- - - function suite.preprocessorDefinitions_onDefines() - files { "hello.rc" } - defines { "DEBUG" } - resdefines { "RESOURCES" } - prepare() - test.capture [[ - - DEBUG;RESOURCES;%(PreprocessorDefinitions) - ]] - end - - --- --- If include directories are specified, the should be added. --- - - function suite.additionalIncludeDirs_onIncludeDirs() - files { "hello.rc" } - includedirs { "include/lua" } - resincludedirs { "include/zlib" } - prepare() - test.capture [[ - - include\lua;include\zlib;%(AdditionalIncludeDirectories) - ]] - end - - --- --- Test special escaping for preprocessor definition with quotes. --- - - function suite.preprocessorDefinitions_onDefinesEscaping() - files { "hello.rc" } - defines { 'VERSION_STRING="1.0.0 (testing)"' } - prepare() - test.capture [[ - - VERSION_STRING=\"1.0.0 (testing)\";%(PreprocessorDefinitions) - ]] - end - - --- --- Test locale conversion to culture codes. --- - - function suite.culture_en_US() - files { "hello.rc" } - locale "en-US" - prepare() - test.capture [[ - - 0x0409 - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_resource_compile.lua +-- Validate resource compiler settings in Visual Studio 2010 C/C++ projects. +-- Copyright (c) 2011-2013 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vs2010_resource_compiler") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2010") + p.escaper(p.vstudio.vs2010.esc) + wks, prj = test.createWorkspace() + end + + local function prepare() + local cfg = test.getconfig(prj, "Debug") + vc2010.resourceCompile(cfg) + end + + +-- +-- Should only write the element if it is needed. +-- + + function suite.excluded_onNoResourceFiles() + prepare() + test.isemptycapture() + end + + function suite.excluded_onNoSettings() + files { "hello.rc" } + prepare() + test.isemptycapture() + end + + function suite.skips_onXbox360() + files { "hello.rc" } + defines { "DEBUG" } + system "Xbox360" + prepare() + test.isemptycapture() + end + + +-- +-- If defines are specified, the element should be added. +-- + + function suite.preprocessorDefinitions_onDefines() + files { "hello.rc" } + defines { "DEBUG" } + resdefines { "RESOURCES" } + prepare() + test.capture [[ + + DEBUG;RESOURCES;%(PreprocessorDefinitions) + ]] + end + + +-- +-- If include directories are specified, the should be added. +-- + + function suite.additionalIncludeDirs_onIncludeDirs() + files { "hello.rc" } + includedirs { "include/lua" } + resincludedirs { "include/zlib" } + prepare() + test.capture [[ + + include\lua;include\zlib;%(AdditionalIncludeDirectories) + ]] + end + + +-- +-- Test special escaping for preprocessor definition with quotes. +-- + + function suite.preprocessorDefinitions_onDefinesEscaping() + files { "hello.rc" } + defines { 'VERSION_STRING="1.0.0 (testing)"' } + prepare() + test.capture [[ + + VERSION_STRING=\"1.0.0 (testing)\";%(PreprocessorDefinitions) + ]] + end + + +-- +-- Test locale conversion to culture codes. +-- + + function suite.culture_en_US() + files { "hello.rc" } + locale "en-US" + prepare() + test.capture [[ + + 0x0409 + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_rule_props.lua b/modules/vstudio/tests/vc2010/test_rule_props.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_rule_props.lua rename to modules/vstudio/tests/vc2010/test_rule_props.lua diff --git a/tests/actions/vstudio/vc2010/test_rule_targets.lua b/modules/vstudio/tests/vc2010/test_rule_targets.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_rule_targets.lua rename to modules/vstudio/tests/vc2010/test_rule_targets.lua diff --git a/tests/actions/vstudio/vc2010/test_rule_vars.lua b/modules/vstudio/tests/vc2010/test_rule_vars.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_rule_vars.lua rename to modules/vstudio/tests/vc2010/test_rule_vars.lua diff --git a/tests/actions/vstudio/vc2010/test_rule_xml.lua b/modules/vstudio/tests/vc2010/test_rule_xml.lua similarity index 94% rename from tests/actions/vstudio/vc2010/test_rule_xml.lua rename to modules/vstudio/tests/vc2010/test_rule_xml.lua index a18fb07b..56ccadfd 100644 --- a/tests/actions/vstudio/vc2010/test_rule_xml.lua +++ b/modules/vstudio/tests/vc2010/test_rule_xml.lua @@ -1,181 +1,181 @@ --- --- tests/actions/vstudio/vc2010/test_rule_xml.lua --- Validate generation of custom rules --- Author Jason Perkins --- Copyright (c) 2016 Jason Perkins and the Premake project --- - - local p = premake - local suite = test.declare("vstudio_vs2010_rule_xml") - local vc2010 = p.vstudio.vc2010 - local m = p.vstudio.vs2010.rules.xml - - --- --- Setup --- - - function suite.setup() - p.action.set("vs2010") - rule "MyRule" - wks, prj = test.createWorkspace() - rules { "MyRule" } - end - - local function createVar(def) - rule "MyRule" - propertydefinition(def) - project "MyProject" - end - - - ---- --- Property definitions ---- - - function suite.properties_onStringNoSwitch() - createVar { name="MyVar", kind="string" } - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - ]] - end - - function suite.properties_onString() - createVar { name="MyVar", kind="string", switch="[value]" } - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - ]] - end - - function suite.properties_onStringWithNoKind() - createVar { name="MyVar" } - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - ]] - end - - - function suite.properties_onBooleanNoSwitch() - createVar { name="MyVar", kind="boolean" } - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - ]] - end - - function suite.properties_onBoolean() - createVar { name="MyVar", kind="boolean", switch="[value]" } - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - ]] - end - - function suite.properties_onEnum() - createVar { - name = "OptimizationLevel", - display = "Optimization Level", - values = { - [0] = "None", - [1] = "Size", - [2] = "Speed", - }, - switch = { - [0] = "-O0", - [1] = "-O1", - [2] = "-O3", - }, - value = 2, - } - - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - - - - - ]] - end - - function suite.properties_onEnumNoSwitches() - createVar { - name = "OptimizationLevel", - display = "Optimization Level", - values = { - [0] = "None", - [1] = "Size", - [2] = "Speed", - }, - value = 2, - } - - local r = test.getRule("MyRule") - m.properties(r) - test.capture [[ - - - - - - ]] - end +-- +-- tests/actions/vstudio/vc2010/test_rule_xml.lua +-- Validate generation of custom rules +-- Author Jason Perkins +-- Copyright (c) 2016 Jason Perkins and the Premake project +-- + + local p = premake + local suite = test.declare("vstudio_vs2010_rule_xml") + local vc2010 = p.vstudio.vc2010 + local m = p.vstudio.vs2010.rules.xml + + +-- +-- Setup +-- + + function suite.setup() + p.action.set("vs2010") + rule "MyRule" + wks, prj = test.createWorkspace() + rules { "MyRule" } + end + + local function createVar(def) + rule "MyRule" + propertydefinition(def) + project "MyProject" + end + + + +--- +-- Property definitions +--- + + function suite.properties_onStringNoSwitch() + createVar { name="MyVar", kind="string" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + function suite.properties_onString() + createVar { name="MyVar", kind="string", switch="[value]" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + function suite.properties_onStringWithNoKind() + createVar { name="MyVar" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + + function suite.properties_onBooleanNoSwitch() + createVar { name="MyVar", kind="boolean" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + function suite.properties_onBoolean() + createVar { name="MyVar", kind="boolean", switch="[value]" } + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + ]] + end + + function suite.properties_onEnum() + createVar { + name = "OptimizationLevel", + display = "Optimization Level", + values = { + [0] = "None", + [1] = "Size", + [2] = "Speed", + }, + switch = { + [0] = "-O0", + [1] = "-O1", + [2] = "-O3", + }, + value = 2, + } + + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + + + + + ]] + end + + function suite.properties_onEnumNoSwitches() + createVar { + name = "OptimizationLevel", + display = "Optimization Level", + values = { + [0] = "None", + [1] = "Size", + [2] = "Speed", + }, + value = 2, + } + + local r = test.getRule("MyRule") + m.properties(r) + test.capture [[ + + + + + + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_target_machine.lua b/modules/vstudio/tests/vc2010/test_target_machine.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_target_machine.lua rename to modules/vstudio/tests/vc2010/test_target_machine.lua diff --git a/tests/actions/vstudio/vc2010/test_user_file.lua b/modules/vstudio/tests/vc2010/test_user_file.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_user_file.lua rename to modules/vstudio/tests/vc2010/test_user_file.lua diff --git a/tests/actions/vstudio/vc2010/test_vectorextensions.lua b/modules/vstudio/tests/vc2010/test_vectorextensions.lua similarity index 100% rename from tests/actions/vstudio/vc2010/test_vectorextensions.lua rename to modules/vstudio/tests/vc2010/test_vectorextensions.lua diff --git a/src/actions/vstudio/vs2005.lua b/modules/vstudio/vs2005.lua similarity index 100% rename from src/actions/vstudio/vs2005.lua rename to modules/vstudio/vs2005.lua diff --git a/src/actions/vstudio/vs2005_csproj.lua b/modules/vstudio/vs2005_csproj.lua similarity index 100% rename from src/actions/vstudio/vs2005_csproj.lua rename to modules/vstudio/vs2005_csproj.lua diff --git a/src/actions/vstudio/vs2005_csproj_user.lua b/modules/vstudio/vs2005_csproj_user.lua similarity index 100% rename from src/actions/vstudio/vs2005_csproj_user.lua rename to modules/vstudio/vs2005_csproj_user.lua diff --git a/src/actions/vstudio/vs2005_solution.lua b/modules/vstudio/vs2005_solution.lua similarity index 100% rename from src/actions/vstudio/vs2005_solution.lua rename to modules/vstudio/vs2005_solution.lua diff --git a/src/actions/vstudio/vs2008.lua b/modules/vstudio/vs2008.lua similarity index 100% rename from src/actions/vstudio/vs2008.lua rename to modules/vstudio/vs2008.lua diff --git a/src/actions/vstudio/vs200x_vcproj.lua b/modules/vstudio/vs200x_vcproj.lua similarity index 100% rename from src/actions/vstudio/vs200x_vcproj.lua rename to modules/vstudio/vs200x_vcproj.lua diff --git a/src/actions/vstudio/vs200x_vcproj_user.lua b/modules/vstudio/vs200x_vcproj_user.lua similarity index 94% rename from src/actions/vstudio/vs200x_vcproj_user.lua rename to modules/vstudio/vs200x_vcproj_user.lua index 04bd7103..55444748 100644 --- a/src/actions/vstudio/vs200x_vcproj_user.lua +++ b/modules/vstudio/vs200x_vcproj_user.lua @@ -1,131 +1,131 @@ --- --- vs200x_vcproj_user.lua --- Generate a Visual Studio 2002-2008 C/C++ project .user file --- Copyright (c) 2011-2015 Jason Perkins and the Premake project --- - - local p = premake - local m = p.vstudio.vc200x - - - --- --- Generate a Visual Studio 200x C++ user file, with support for the new platforms API. --- - - m.elements.user = function(cfg) - return { - m.debugSettings, - } - end - - function m.generateUser(prj) - p.indent("\t") - - -- Only want output if there is something to configure - local contents = {} - local size = 0 - - for cfg in p.project.eachconfig(prj) do - contents[cfg] = p.capture(function() - p.push(4) - p.callArray(m.elements.user, cfg) - p.pop(4) - end) - size = size + #contents[cfg] - end - - if size > 0 then - m.xmlElement() - m.visualStudioUserFile() - p.push('') - for cfg in p.project.eachconfig(prj) do - m.userConfiguration(cfg) - p.push(' 0 then - p.outln(contents[cfg]) - end - p.pop('/>') - p.pop('') - end - p.pop('') - p.pop('') - end - end - - - ---- --- Output the opening project tag. ---- - - function m.visualStudioUserFile() - p.push('') - end - - - --- --- Write out the element, describing a specific Premake --- build configuration/platform pairing. --- - - function m.userConfiguration(cfg) - p.push('') - end - - - --- --- Write out the debug settings for this project. --- - - m.elements.debugSettings = function(cfg) - return { - m.debugCommand, - m.debugDir, - m.debugArgs, - m.debugEnvironment, - } - end - - function m.debugSettings(cfg) - p.callArray(m.elements.debugSettings, cfg) - end - - - function m.debugArgs(cfg) - if #cfg.debugargs > 0 then - p.x('CommandArguments="%s"', table.concat(cfg.debugargs, " ")) - end - end - - - function m.debugCommand(cfg) - if cfg.debugcommand then - p.x('Command="%s"', p.vstudio.path(cfg, cfg.debugcommand)) - end - end - - - function m.debugDir(cfg) - if cfg.debugdir then - p.x('WorkingDirectory="%s"', p.vstudio.path(cfg, cfg.debugdir)) - end - end - - - function m.debugEnvironment(cfg) - if #cfg.debugenvs > 0 then - p.x('Environment="%s"', table.concat(cfg.debugenvs, "\n")) - if cfg.flags.DebugEnvsDontMerge then - p.x('EnvironmentMerge="false"') - end - end - end +-- +-- vs200x_vcproj_user.lua +-- Generate a Visual Studio 2002-2008 C/C++ project .user file +-- Copyright (c) 2011-2015 Jason Perkins and the Premake project +-- + + local p = premake + local m = p.vstudio.vc200x + + + +-- +-- Generate a Visual Studio 200x C++ user file, with support for the new platforms API. +-- + + m.elements.user = function(cfg) + return { + m.debugSettings, + } + end + + function m.generateUser(prj) + p.indent("\t") + + -- Only want output if there is something to configure + local contents = {} + local size = 0 + + for cfg in p.project.eachconfig(prj) do + contents[cfg] = p.capture(function() + p.push(4) + p.callArray(m.elements.user, cfg) + p.pop(4) + end) + size = size + #contents[cfg] + end + + if size > 0 then + m.xmlElement() + m.visualStudioUserFile() + p.push('') + for cfg in p.project.eachconfig(prj) do + m.userConfiguration(cfg) + p.push(' 0 then + p.outln(contents[cfg]) + end + p.pop('/>') + p.pop('') + end + p.pop('') + p.pop('') + end + end + + + +--- +-- Output the opening project tag. +--- + + function m.visualStudioUserFile() + p.push('') + end + + + +-- +-- Write out the element, describing a specific Premake +-- build configuration/platform pairing. +-- + + function m.userConfiguration(cfg) + p.push('') + end + + + +-- +-- Write out the debug settings for this project. +-- + + m.elements.debugSettings = function(cfg) + return { + m.debugCommand, + m.debugDir, + m.debugArgs, + m.debugEnvironment, + } + end + + function m.debugSettings(cfg) + p.callArray(m.elements.debugSettings, cfg) + end + + + function m.debugArgs(cfg) + if #cfg.debugargs > 0 then + p.x('CommandArguments="%s"', table.concat(cfg.debugargs, " ")) + end + end + + + function m.debugCommand(cfg) + if cfg.debugcommand then + p.x('Command="%s"', p.vstudio.path(cfg, cfg.debugcommand)) + end + end + + + function m.debugDir(cfg) + if cfg.debugdir then + p.x('WorkingDirectory="%s"', p.vstudio.path(cfg, cfg.debugdir)) + end + end + + + function m.debugEnvironment(cfg) + if #cfg.debugenvs > 0 then + p.x('Environment="%s"', table.concat(cfg.debugenvs, "\n")) + if cfg.flags.DebugEnvsDontMerge then + p.x('EnvironmentMerge="false"') + end + end + end diff --git a/src/actions/vstudio/vs2010.lua b/modules/vstudio/vs2010.lua similarity index 98% rename from src/actions/vstudio/vs2010.lua rename to modules/vstudio/vs2010.lua index 2dd5116f..09d10514 100644 --- a/src/actions/vstudio/vs2010.lua +++ b/modules/vstudio/vs2010.lua @@ -17,7 +17,7 @@ -- Map Premake tokens to the corresponding Visual Studio variables. --- - vstudio.pathVars = { + vs2010.pathVars = { ["cfg.objdir"] = { absolute = true, token = "$(IntDir)" }, ["prj.location"] = { absolute = true, token = "$(ProjectDir)" }, ["prj.name"] = { absolute = false, token = "$(ProjectName)" }, @@ -163,7 +163,7 @@ vstudio.cleanTarget(prj) end, - pathVars = vstudio.pathVars, + pathVars = vs2010.pathVars, -- This stuff is specific to the Visual Studio exporters diff --git a/src/actions/vstudio/vs2010_nuget.lua b/modules/vstudio/vs2010_nuget.lua similarity index 100% rename from src/actions/vstudio/vs2010_nuget.lua rename to modules/vstudio/vs2010_nuget.lua diff --git a/src/actions/vstudio/vs2010_rules_props.lua b/modules/vstudio/vs2010_rules_props.lua similarity index 100% rename from src/actions/vstudio/vs2010_rules_props.lua rename to modules/vstudio/vs2010_rules_props.lua diff --git a/src/actions/vstudio/vs2010_rules_targets.lua b/modules/vstudio/vs2010_rules_targets.lua similarity index 100% rename from src/actions/vstudio/vs2010_rules_targets.lua rename to modules/vstudio/vs2010_rules_targets.lua diff --git a/src/actions/vstudio/vs2010_rules_xml.lua b/modules/vstudio/vs2010_rules_xml.lua similarity index 100% rename from src/actions/vstudio/vs2010_rules_xml.lua rename to modules/vstudio/vs2010_rules_xml.lua diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua similarity index 95% rename from src/actions/vstudio/vs2010_vcxproj.lua rename to modules/vstudio/vs2010_vcxproj.lua index b5be7f8b..16df6ef9 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -1,2300 +1,2300 @@ --- --- vs2010_vcxproj.lua --- Generate a Visual Studio 201x C/C++ project. --- Copyright (c) 2009-2015 Jason Perkins and the Premake project --- - - local p = premake - p.vstudio.vc2010 = {} - - local vstudio = p.vstudio - local project = p.project - local config = p.config - local fileconfig = p.fileconfig - local tree = p.tree - - local m = p.vstudio.vc2010 - - ---- --- Add namespace for element definition lists for p.callArray() ---- - - m.elements = {} - - --- --- Generate a Visual Studio 201x C++ project, with support for the new platforms API. --- - - m.elements.project = function(prj) - return { - m.xmlDeclaration, - m.project, - m.projectConfigurations, - m.globals, - m.importDefaultProps, - m.configurationPropertiesGroup, - m.importLanguageSettings, - m.importExtensionSettings, - m.propertySheetGroup, - m.userMacros, - m.outputPropertiesGroup, - m.itemDefinitionGroups, - m.assemblyReferences, - m.files, - m.projectReferences, - m.importLanguageTargets, - m.importExtensionTargets, - m.ensureNuGetPackageBuildImports, - } - end - - function m.generate(prj) - p.utf8() - p.callArray(m.elements.project, prj) - p.out('') - end - - --- --- Output the XML declaration and opening tag. --- - - function m.project(prj) - local action = p.action.current() - p.push('', - action.vstudio.toolsVersion) - end - - --- --- Write out the list of project configurations, which pairs build --- configurations with architectures. --- - - function m.projectConfigurations(prj) - - -- build a list of all architectures used in this project - local platforms = {} - for cfg in project.eachconfig(prj) do - local arch = vstudio.archFromConfig(cfg, true) - if not table.contains(platforms, arch) then - table.insert(platforms, arch) - end - end - - local configs = {} - p.push('') - for cfg in project.eachconfig(prj) do - for _, arch in ipairs(platforms) do - local prjcfg = vstudio.projectConfig(cfg, arch) - if not configs[prjcfg] then - configs[prjcfg] = prjcfg - p.push('', vstudio.projectConfig(cfg, arch)) - p.x('%s', vstudio.projectPlatform(cfg)) - p.w('%s', arch) - p.pop('') - end - end - end - p.pop('') - end - - --- --- Write out the TargetFrameworkVersion property. --- - - function m.targetFramework(prj) - local action = p.action.current() - local tools = string.format(' ToolsVersion="%s"', action.vstudio.toolsVersion) - - local framework = prj.dotnetframework or action.vstudio.targetFramework or "4.0" - p.w('v%s', framework) - end - - - --- --- Write out the Globals property group. --- - - m.elements.globals = function(prj) - return { - m.projectGuid, - m.ignoreWarnDuplicateFilename, - m.keyword, - m.projectName, - m.targetPlatformVersion, - } - end - - function m.globals(prj) - m.propertyGroup(nil, "Globals") - p.callArray(m.elements.globals, prj) - p.pop('') - end - - --- --- Write out the configuration property group: what kind of binary it --- produces, and some global settings. --- - - m.elements.configurationProperties = function(cfg) - if cfg.kind == p.UTILITY then - return { - m.configurationType, - m.platformToolset, - } - else - return { - m.configurationType, - m.useDebugLibraries, - m.useOfMfc, - m.useOfAtl, - m.clrSupport, - m.characterSet, - m.platformToolset, - m.wholeProgramOptimization, - m.nmakeOutDirs, - m.windowsSDKDesktopARMSupport, - } - end - end - - function m.configurationProperties(cfg) - m.propertyGroup(cfg, "Configuration") - p.callArray(m.elements.configurationProperties, cfg) - p.pop('') - end - - function m.configurationPropertiesGroup(prj) - for cfg in project.eachconfig(prj) do - m.configurationProperties(cfg) - end - end - - - --- --- Write the output property group, which includes the output and intermediate --- directories, manifest, etc. --- - - m.elements.outputProperties = function(cfg) - if cfg.kind == p.UTILITY then - return { - m.outDir, - m.intDir, - m.extensionsToDeleteOnClean, - } - else - return { - m.linkIncremental, - m.ignoreImportLibrary, - m.outDir, - m.outputFile, - m.intDir, - m.targetName, - m.targetExt, - m.includePath, - m.libraryPath, - m.imageXexOutput, - m.generateManifest, - m.extensionsToDeleteOnClean, - m.executablePath, - } - end - end - - function m.outputProperties(cfg) - if not vstudio.isMakefile(cfg) then - m.propertyGroup(cfg) - p.callArray(m.elements.outputProperties, cfg) - p.pop('') - end - end - - --- --- Write the NMake property group for Makefile projects, which includes the custom --- build commands, output file location, etc. --- - - m.elements.nmakeProperties = function(cfg) - return { - m.nmakeOutput, - m.nmakeBuildCommands, - m.nmakeRebuildCommands, - m.nmakeCleanCommands, - m.nmakePreprocessorDefinitions, - m.nmakeIncludeDirs - } - end - - function m.nmakeProperties(cfg) - if vstudio.isMakefile(cfg) then - m.propertyGroup(cfg) - p.callArray(m.elements.nmakeProperties, cfg) - p.pop('') - end - end - - --- --- Output properties and NMake properties should appear side-by-side --- for each configuration. --- - - function m.outputPropertiesGroup(prj) - for cfg in project.eachconfig(prj) do - m.outputProperties(cfg) - m.nmakeProperties(cfg) - end - end - - - --- --- Write a configuration's item definition group, which contains all --- of the per-configuration compile and link settings. --- - - m.elements.itemDefinitionGroup = function(cfg) - if cfg.kind == p.UTILITY then - return { - m.ruleVars, - m.buildEvents, - } - else - return { - m.clCompile, - m.resourceCompile, - m.linker, - m.manifest, - m.buildEvents, - m.imageXex, - m.deploy, - m.ruleVars, - m.buildLog, - } - end - end - - function m.itemDefinitionGroup(cfg) - if not vstudio.isMakefile(cfg) then - p.push('', m.condition(cfg)) - p.callArray(m.elements.itemDefinitionGroup, cfg) - p.pop('') - - else - if cfg == project.getfirstconfig(cfg.project) then - p.w('') - p.w('') - end - end - end - - function m.itemDefinitionGroups(prj) - for cfg in project.eachconfig(prj) do - m.itemDefinitionGroup(cfg) - end - end - - - --- --- Write the the compiler settings block. --- - - m.elements.clCompile = function(cfg) - return { - m.precompiledHeader, - m.warningLevel, - m.treatWarningAsError, - m.disableSpecificWarnings, - m.treatSpecificWarningsAsErrors, - m.basicRuntimeChecks, - m.clCompilePreprocessorDefinitions, - m.clCompileUndefinePreprocessorDefinitions, - m.clCompileAdditionalIncludeDirectories, - m.clCompileAdditionalUsingDirectories, - m.forceIncludes, - m.debugInformationFormat, - m.optimization, - m.functionLevelLinking, - m.intrinsicFunctions, - m.minimalRebuild, - m.omitFramePointers, - m.stringPooling, - m.runtimeLibrary, - m.omitDefaultLib, - m.exceptionHandling, - m.runtimeTypeInfo, - m.bufferSecurityCheck, - m.treatWChar_tAsBuiltInType, - m.floatingPointModel, - m.floatingPointExceptions, - m.inlineFunctionExpansion, - m.enableEnhancedInstructionSet, - m.multiProcessorCompilation, - m.additionalCompileOptions, - m.compileAs, - m.callingConvention, - m.languageStandard, - } - end - - function m.clCompile(cfg) - p.push('') - p.callArray(m.elements.clCompile, cfg) - p.pop('') - end - - --- --- Write out the resource compiler block. --- - - m.elements.resourceCompile = function(cfg) - return { - m.resourcePreprocessorDefinitions, - m.resourceAdditionalIncludeDirectories, - m.culture, - } - end - - function m.resourceCompile(cfg) - if cfg.system ~= p.XBOX360 and p.config.hasFile(cfg, path.isresourcefile) then - local contents = p.capture(function () - p.push() - p.callArray(m.elements.resourceCompile, cfg) - p.pop() - end) - - if #contents > 0 then - p.push('') - p.outln(contents) - p.pop('') - end - end - end - - --- --- Write out the linker tool block. --- - - m.elements.linker = function(cfg, explicit) - return { - m.link, - m.lib, - m.linkLibraryDependencies, - } - end - - function m.linker(cfg) - local explicit = vstudio.needsExplicitLink(cfg) - p.callArray(m.elements.linker, cfg, explicit) - end - - - - m.elements.link = function(cfg, explicit) - if cfg.kind == p.STATICLIB then - return { - m.subSystem, - m.fullProgramDatabaseFile, - m.generateDebugInformation, - m.optimizeReferences, - } - else - return { - m.subSystem, - m.fullProgramDatabaseFile, - m.generateDebugInformation, - m.optimizeReferences, - m.additionalDependencies, - m.additionalLibraryDirectories, - m.importLibrary, - m.entryPointSymbol, - m.generateMapFile, - m.moduleDefinitionFile, - m.treatLinkerWarningAsErrors, - m.ignoreDefaultLibraries, - m.largeAddressAware, - m.targetMachine, - m.additionalLinkOptions, - m.programDatabaseFile, - } - end - end - - function m.link(cfg, explicit) - local contents = p.capture(function () - p.push() - p.callArray(m.elements.link, cfg, explicit) - p.pop() - end) - if #contents > 0 then - p.push('') - p.outln(contents) - p.pop('') - end - end - - - - m.elements.lib = function(cfg, explicit) - if cfg.kind == p.STATICLIB then - return { - m.additionalDependencies, - m.additionalLibraryDirectories, - m.treatLinkerWarningAsErrors, - m.targetMachine, - m.additionalLinkOptions, - } - else - return {} - end - end - - function m.lib(cfg, explicit) - local contents = p.capture(function () - p.push() - p.callArray(m.elements.lib, cfg, explicit) - p.pop() - end) - if #contents > 0 then - p.push('') - p.outln(contents) - p.pop('') - end - end - - - --- --- Write the manifest section. --- - - function m.manifest(cfg) - if cfg.kind ~= p.STATICLIB then - -- get the manifests files - local manifests = {} - for _, fname in ipairs(cfg.files) do - if path.getextension(fname) == ".manifest" then - table.insert(manifests, project.getrelative(cfg.project, fname)) - end - end - - if #manifests > 0 then - p.push('') - m.element("AdditionalManifestFiles", nil, "%s %%(AdditionalManifestFiles)", table.concat(manifests, " ")) - p.pop('') - end - end - end - - - ---- --- Write out the pre- and post-build event settings. ---- - - function m.buildEvents(cfg) - local write = function (event) - local name = event .. "Event" - local field = event:lower() - local steps = cfg[field .. "commands"] - local msg = cfg[field .. "message"] - - if #steps > 0 then - steps = os.translateCommandsAndPaths(steps, cfg.project.basedir, cfg.project.location) - p.push('<%s>', name) - p.x('%s', table.implode(steps, "", "", "\r\n")) - if msg then - p.x('%s', msg) - end - p.pop('', name) - end - end - - write("PreBuild") - write("PreLink") - write("PostBuild") - end - - - ---- --- Write out project-level custom rule variables. ---- - - function m.ruleVars(cfg) - for i = 1, #cfg.rules do - local rule = p.global.getRule(cfg.rules[i]) - - local contents = p.capture(function () - p.push() - for prop in p.rule.eachProperty(rule) do - local fld = p.rule.getPropertyField(rule, prop) - local value = cfg[fld.name] - if value ~= nil then - if fld.kind == "list:path" then - value = table.concat(vstudio.path(cfg, value), ';') - elseif fld.kind == "path" then - value = vstudio.path(cfg, value) - else - value = p.rule.getPropertyString(rule, prop, value) - end - - if value ~= nil and #value > 0 then - m.element(prop.name, nil, '%s', value) - end - end - end - p.pop() - end) - - if #contents > 0 then - p.push('<%s>', rule.name) - p.outln(contents) - p.pop('', rule.name) - end - end - end - - --- --- Reference any managed assemblies listed in the links() --- - - function m.assemblyReferences(prj) - -- Visual Studio doesn't support per-config references; use - -- whatever is contained in the first configuration - local cfg = project.getfirstconfig(prj) - - local refs = config.getlinks(cfg, "system", "fullpath", "managed") - if #refs > 0 then - p.push('') - for i = 1, #refs do - local value = refs[i] - - -- If the link contains a '/' then it is a relative path to - -- a local assembly. Otherwise treat it as a system assembly. - if value:find('/', 1, true) then - p.push('', path.getbasename(value)) - p.x('%s', path.translate(value)) - p.pop('') - else - p.x('', path.getbasename(value)) - end - end - p.pop('') - end - end - - - function m.generatedFile(cfg, file) - if file.generated then - local path = path.translate(file.dependsOn.relpath) - m.element("AutoGen", nil, 'true') - m.element("DependentUpon", nil, path) - end - end - - ---- --- Write out the list of source code files, and any associated configuration. ---- - - function m.files(prj) - local groups = m.categorizeSources(prj) - for _, group in ipairs(groups) do - group.category.emitFiles(prj, group) - end - end - - - m.categories = {} - ---- --- ClInclude group ---- - m.categories.ClInclude = { - name = "ClInclude", - extensions = { ".h", ".hh", ".hpp", ".hxx", ".inl" }, - priority = 1, - - emitFiles = function(prj, group) - m.emitFiles(prj, group, "ClInclude", {m.generatedFile}) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "ClInclude") - end - } - - ---- --- ClCompile group ---- - m.categories.ClCompile = { - name = "ClCompile", - extensions = { ".cc", ".cpp", ".cxx", ".c", ".s", ".m", ".mm" }, - priority = 2, - - emitFiles = function(prj, group) - local fileCfgFunc = function(fcfg, condition) - if fcfg then - return { - m.excludedFromBuild, - m.objectFileName, - m.clCompilePreprocessorDefinitions, - m.clCompileUndefinePreprocessorDefinitions, - m.optimization, - m.forceIncludes, - m.precompiledHeader, - m.enableEnhancedInstructionSet, - m.additionalCompileOptions, - m.disableSpecificWarnings, - m.treatSpecificWarningsAsErrors, - m.basicRuntimeChecks, - m.exceptionHandling, - m.compileAsManaged, - m.runtimeTypeInfo, - } - else - return { - m.excludedFromBuild - } - end - end - - m.emitFiles(prj, group, "ClCompile", {m.generatedFile}, fileCfgFunc) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "ClCompile") - end - } - - ---- --- None group ---- - m.categories.None = { - name = "None", - priority = 3, - - emitFiles = function(prj, group) - m.emitFiles(prj, group, "None", {m.generatedFile}) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "None") - end - } - - ---- --- ResourceCompile group ---- - m.categories.ResourceCompile = { - name = "ResourceCompile", - extensions = ".rc", - priority = 4, - - emitFiles = function(prj, group) - local fileCfgFunc = { - m.excludedFromBuild - } - - m.emitFiles(prj, group, "ResourceCompile", nil, fileCfgFunc, function(cfg) - return cfg.system == p.WINDOWS - end) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "ResourceCompile") - end - } - - ---- --- CustomBuild group ---- - m.categories.CustomBuild = { - name = "CustomBuild", - priority = 5, - - emitFiles = function(prj, group) - local fileFunc = { - m.fileType - } - - local fileCfgFunc = { - m.excludedFromBuild, - m.buildCommands, - m.buildOutputs, - m.linkObjects, - m.buildMessage, - m.buildAdditionalInputs - } - - m.emitFiles(prj, group, "CustomBuild", fileFunc, fileCfgFunc, function (cfg, fcfg) - return fileconfig.hasCustomBuildRule(fcfg) - end) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "CustomBuild") - end - } - - ---- --- Midl group ---- - m.categories.Midl = { - name = "Midl", - extensions = ".idl", - priority = 6, - - emitFiles = function(prj, group) - local fileCfgFunc = { - m.excludedFromBuild - } - - m.emitFiles(prj, group, "Midl", nil, fileCfgFunc, function(cfg) - return cfg.system == p.WINDOWS - end) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "Midl") - end - } - ---- --- Masm group ---- - m.categories.Masm = { - name = "Masm", - extensions = ".asm", - priority = 7, - - emitFiles = function(prj, group) - local fileCfgFunc = function(fcfg, condition) - if fcfg then - return { - m.excludedFromBuild, - m.exceptionHandlingSEH, - } - else - return { - m.excludedFromBuild - } - end - end - m.emitFiles(prj, group, "Masm", nil, fileCfgFunc) - end, - - emitFilter = function(prj, group) - m.filterGroup(prj, group, "Masm") - end, - - emitExtensionSettings = function(prj, group) - p.w('') - end, - - emitExtensionTargets = function(prj, group) - p.w('') - end - } - - ---- --- Categorize files into groups. ---- - function m.categorizeSources(prj) - -- if we already did this, return the cached result. - if prj._vc2010_sources then - return prj._vc2010_sources - end - - -- build the new group table. - local result = {} - local groups = {} - prj._vc2010_sources = result - - local tr = project.getsourcetree(prj) - tree.traverse(tr, { - onleaf = function(node) - local cat = m.categorizeFile(prj, node) - groups[cat.name] = groups[cat.name] or { - category = cat, - files = {} - } - table.insert(groups[cat.name].files, node) - end - }) - - -- sort by relative-to path; otherwise VS will reorder the files - for name, group in pairs(groups) do - table.sort(group.files, function (a, b) - return a.relpath < b.relpath - end) - table.insert(result, group) - end - - -- sort by category priority then name; so we get stable results. - table.sort(result, function (a, b) - if (a.category.priority == b.category.priority) then - return a.category.name < b.category.name - end - return a.category.priority < b.category.priority - end) - - return result - end - - - function m.categorizeFile(prj, file) - -- If any configuration for this file uses a custom build step, - -- that's the category to use - for cfg in project.eachconfig(prj) do - local fcfg = fileconfig.getconfig(file, cfg) - if fileconfig.hasCustomBuildRule(fcfg) then - return m.categories.CustomBuild - end - end - - -- If there is a custom rule associated with it, use that - local rule = p.global.getRuleForFile(file.name, prj.rules) - if rule then - return { - name = rule.name, - priority = 100, - rule = rule, - emitFiles = function(prj, group) - m.emitRuleFiles(prj, group) - end, - emitFilter = function(prj, group) - m.filterGroup(prj, group, group.category.name) - end - } - end - - -- Otherwise use the file extension to deduce a category - for _, cat in pairs(m.categories) do - if cat.extensions and path.hasextension(file.name, cat.extensions) then - return cat - end - end - - return m.categories.None - end - - - function m.emitFiles(prj, group, tag, fileFunc, fileCfgFunc, checkFunc) - local files = group.files - if files and #files > 0 then - p.push('') - for _, file in ipairs(files) do - - local contents = p.capture(function () - p.push() - p.callArray(fileFunc, cfg, file) - for cfg in project.eachconfig(prj) do - local fcfg = fileconfig.getconfig(file, cfg) - if not checkFunc or checkFunc(cfg, fcfg) then - p.callArray(fileCfgFunc, fcfg, m.condition(cfg)) - end - end - p.pop() - end) - - local rel = path.translate(file.relpath) - if #contents > 0 then - p.push('<%s Include="%s">', tag, rel) - p.outln(contents) - p.pop('', tag) - else - p.x('<%s Include="%s" />', tag, rel) - end - - end - p.pop('') - end - end - - function m.emitRuleFiles(prj, group) - local files = group.files - local rule = group.category.rule - - if files and #files > 0 then - p.push('') - - for _, file in ipairs(files) do - local contents = p.capture(function() - p.push() - for prop in p.rule.eachProperty(rule) do - local fld = p.rule.getPropertyField(rule, prop) - - for cfg in project.eachconfig(prj) do - local fcfg = fileconfig.getconfig(file, cfg) - if fcfg and fcfg[fld.name] then - local value = p.rule.getPropertyString(rule, prop, fcfg[fld.name]) - if value and #value > 0 then - m.element(prop.name, m.condition(cfg), '%s', value) - end - end - end - - end - p.pop() - end) - - if #contents > 0 then - p.push('<%s Include=\"%s\">', rule.name, path.translate(file.relpath)) - p.outln(contents) - p.pop('', rule.name) - else - p.x('<%s Include=\"%s\" />', rule.name, path.translate(file.relpath)) - end - end - - p.pop('') - end - end - - - function m.isClrMixed(prj) - -- check to see if any files are marked with clr - local isMixed = false - if not prj.clr or prj.clr == p.OFF then - if prj._isClrMixed ~= nil then - isMixed = prj._isClrMixed - else - table.foreachi(prj._.files, function(file) - for cfg in p.project.eachconfig(prj) do - local fcfg = p.fileconfig.getconfig(file, cfg) - if fcfg and fcfg.clr and fcfg.clr ~= p.OFF then - isMixed = true - end - end - end) - prj._isClrMixed = isMixed -- cache the results - end - end - return isMixed - end - - --- --- Generate the list of project dependencies. --- - - m.elements.projectReferences = function(prj, ref) - if prj.clr ~= p.OFF or (m.isClrMixed(prj) and ref and ref.kind ~=p.STATICLIB) then - return { - m.referenceProject, - m.referencePrivate, - m.referenceOutputAssembly, - m.referenceCopyLocalSatelliteAssemblies, - m.referenceLinkLibraryDependencies, - m.referenceUseLibraryDependences, - } - else - return { - m.referenceProject, - } - end - end - - function m.projectReferences(prj) - local refs = project.getdependencies(prj, 'linkOnly') - if #refs > 0 then - p.push('') - for _, ref in ipairs(refs) do - local relpath = vstudio.path(prj, vstudio.projectfile(ref)) - p.push('', relpath) - p.callArray(m.elements.projectReferences, prj, ref) - p.pop('') - end - p.pop('') - end - end - - - ---------------------------------------------------------------------------- --- --- Handlers for individual project elements --- ---------------------------------------------------------------------------- - - function m.additionalDependencies(cfg, explicit) - local links - - -- check to see if this project uses an external toolset. If so, let the - -- toolset define the format of the links - local toolset = config.toolset(cfg) - if toolset then - links = toolset.getlinks(cfg, not explicit) - else - links = vstudio.getLinks(cfg, explicit) - end - - if #links > 0 then - links = path.translate(table.concat(links, ";")) - m.element("AdditionalDependencies", nil, "%s;%%(AdditionalDependencies)", links) - end - end - - - function m.additionalIncludeDirectories(cfg, includedirs) - if #includedirs > 0 then - local dirs = vstudio.path(cfg, includedirs) - if #dirs > 0 then - m.element("AdditionalIncludeDirectories", nil, "%s;%%(AdditionalIncludeDirectories)", table.concat(dirs, ";")) - end - end - end - - - function m.additionalLibraryDirectories(cfg) - if #cfg.libdirs > 0 then - local dirs = table.concat(vstudio.path(cfg, cfg.libdirs), ";") - m.element("AdditionalLibraryDirectories", nil, "%s;%%(AdditionalLibraryDirectories)", dirs) - end - end - - - function m.additionalUsingDirectories(cfg) - if #cfg.usingdirs > 0 then - local dirs = vstudio.path(cfg, cfg.usingdirs) - if #dirs > 0 then - m.element("AdditionalUsingDirectories", nil, "%s;%%(AdditionalUsingDirectories)", table.concat(dirs, ";")) - end - end - end - - - function m.largeAddressAware(cfg) - if (cfg.largeaddressaware == true) then - m.element("LargeAddressAware", nil, 'true') - end - end - - - function m.languageStandard(cfg) - if _ACTION >= "vs2017" then - if (cfg.cppdialect == "C++14") then - m.element("LanguageStandard", nil, 'stdcpp14') - elseif (cfg.cppdialect == "C++17") then - m.element("LanguageStandard", nil, 'stdcpplatest') - end - end - end - - - function m.additionalCompileOptions(cfg, condition) - local opts = cfg.buildoptions - if _ACTION == "vs2015" then - if (cfg.cppdialect == "C++14") then - table.insert(opts, "/std:c++14") - elseif (cfg.cppdialect == "C++17") then - table.insert(opts, "/std:c++latest") - end - end - if #opts > 0 then - opts = table.concat(opts, " ") - m.element("AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts) - end - end - - - function m.additionalLinkOptions(cfg) - if #cfg.linkoptions > 0 then - local opts = table.concat(cfg.linkoptions, " ") - m.element("AdditionalOptions", nil, "%s %%(AdditionalOptions)", opts) - end - end - - - function m.compileAsManaged(fcfg, condition) - if fcfg.clr and fcfg ~= p.OFF then - m.element("CompileAsManaged", condition, "true") - end - end - - - function m.basicRuntimeChecks(cfg, condition) - local prjcfg, filecfg = p.config.normalize(cfg) - local runtime = config.getruntime(prjcfg) - if filecfg then - if filecfg.flags.NoRuntimeChecks or (config.isOptimizedBuild(filecfg) and runtime:endswith("Debug")) then - m.element("BasicRuntimeChecks", condition, "Default") - end - else - if prjcfg.flags.NoRuntimeChecks or (config.isOptimizedBuild(prjcfg) and runtime:endswith("Debug")) then - m.element("BasicRuntimeChecks", nil, "Default") - end - end - end - - - function m.buildAdditionalInputs(fcfg, condition) - if fcfg.buildinputs and #fcfg.buildinputs > 0 then - local inputs = project.getrelative(fcfg.project, fcfg.buildinputs) - m.element("AdditionalInputs", condition, '%s', table.concat(inputs, ";")) - end - end - - - function m.buildCommands(fcfg, condition) - local commands = os.translateCommandsAndPaths(fcfg.buildcommands, fcfg.project.basedir, fcfg.project.location) - commands = table.concat(commands,'\r\n') - m.element("Command", condition, '%s', commands) - end - - - function m.buildLog(cfg) - if cfg.buildlog and #cfg.buildlog > 0 then - p.push('') - m.element("Path", nil, "%s", vstudio.path(cfg, cfg.buildlog)) - p.pop('') - end - end - - - function m.buildMessage(fcfg, condition) - if fcfg.buildmessage then - m.element("Message", condition, '%s', fcfg.buildmessage) - end - end - - - function m.buildOutputs(fcfg, condition) - local outputs = project.getrelative(fcfg.project, fcfg.buildoutputs) - m.element("Outputs", condition, '%s', table.concat(outputs, ";")) - end - - - function m.linkObjects(fcfg, condition) - if fcfg.linkbuildoutputs ~= nil then - m.element("LinkObjects", condition, tostring(fcfg.linkbuildoutputs)) - end - end - - - function m.characterSet(cfg) - if not vstudio.isMakefile(cfg) then - local charactersets = { - ASCII = "NotSet", - MBCS = "MultiByte", - Unicode = "Unicode", - Default = "Unicode" - } - m.element("CharacterSet", nil, charactersets[cfg.characterset]) - end - end - - - function m.wholeProgramOptimization(cfg) - if cfg.flags.LinkTimeOptimization then - m.element("WholeProgramOptimization", nil, "true") - end - end - - function m.clCompileAdditionalIncludeDirectories(cfg) - m.additionalIncludeDirectories(cfg, cfg.includedirs) - end - - function m.clCompileAdditionalUsingDirectories(cfg) - m.additionalUsingDirectories(cfg, cfg.usingdirs) - end - - - function m.clCompilePreprocessorDefinitions(cfg, condition) - local defines = cfg.defines - if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then - defines = table.join(defines, "_HAS_EXCEPTIONS=0") - end - m.preprocessorDefinitions(cfg, defines, false, condition) - end - - - function m.clCompileUndefinePreprocessorDefinitions(cfg, condition) - m.undefinePreprocessorDefinitions(cfg, cfg.undefines, false, condition) - end - - - function m.clrSupport(cfg) - local value - if cfg.clr == "On" or cfg.clr == "Unsafe" then - value = "true" - elseif cfg.clr ~= p.OFF then - value = cfg.clr - end - if value then - m.element("CLRSupport", nil, value) - end - end - - - function m.compileAs(cfg) - if p.languages.isc(cfg.compileas) then - m.element("CompileAs", nil, "CompileAsC") - elseif p.languages.iscpp(cfg.compileas) then - m.element("CompileAs", nil, "CompileAsCpp") - end - end - - - function m.configurationType(cfg) - local types = { - SharedLib = "DynamicLibrary", - StaticLib = "StaticLibrary", - ConsoleApp = "Application", - WindowedApp = "Application", - Makefile = "Makefile", - None = "Makefile", - Utility = "Utility", - } - m.element("ConfigurationType", nil, types[cfg.kind]) - end - - - function m.culture(cfg) - local value = vstudio.cultureForLocale(cfg.locale) - if value then - m.element("Culture", nil, "0x%04x", tostring(value)) - end - end - - - function m.debugInformationFormat(cfg) - local value - local tool, toolVersion = p.config.toolset(cfg) - if (cfg.symbols == p.ON) or (cfg.symbols == "FastLink") then - if cfg.debugformat == "c7" then - value = "OldStyle" - elseif (cfg.architecture == "x86_64" and _ACTION < "vs2015") or - cfg.clr ~= p.OFF or - config.isOptimizedBuild(cfg) or - cfg.editandcontinue == p.OFF or - (toolVersion and toolVersion:startswith("LLVM-vs")) - then - value = "ProgramDatabase" - else - value = "EditAndContinue" - end - - m.element("DebugInformationFormat", nil, value) - elseif cfg.symbols == p.OFF then - -- leave field blank for vs2013 and older to workaround bug - if _ACTION < "vs2015" then - value = "" - else - value = "None" - end - - m.element("DebugInformationFormat", nil, value) - end - end - - - function m.deploy(cfg) - if cfg.system == p.XBOX360 then - p.push('') - m.element("DeploymentType", nil, "CopyToHardDrive") - m.element("DvdEmulationType", nil, "ZeroSeekTimes") - m.element("DeploymentFiles", nil, "$(RemoteRoot)=$(ImagePath);") - p.pop('') - end - end - - - function m.enableEnhancedInstructionSet(cfg, condition) - local v - local x = cfg.vectorextensions - if x == "AVX" and _ACTION > "vs2010" then - v = "AdvancedVectorExtensions" - elseif x == "AVX2" and _ACTION > "vs2012" then - v = "AdvancedVectorExtensions2" - elseif cfg.architecture ~= "x86_64" then - if x == "SSE2" or x == "SSE3" or x == "SSSE3" or x == "SSE4.1" then - v = "StreamingSIMDExtensions2" - elseif x == "SSE" then - v = "StreamingSIMDExtensions" - elseif x == "IA32" and _ACTION > "vs2010" then - v = "NoExtensions" - end - end - if v then - m.element('EnableEnhancedInstructionSet', condition, v) - end - end - - - function m.entryPointSymbol(cfg) - if cfg.entrypoint then - m.element("EntryPointSymbol", nil, cfg.entrypoint) - end - end - - - function m.exceptionHandling(cfg, condition) - if cfg.exceptionhandling == p.OFF then - m.element("ExceptionHandling", condition, "false") - elseif cfg.exceptionhandling == "SEH" then - m.element("ExceptionHandling", condition, "Async") - end - end - - - function m.excludedFromBuild(filecfg, condition) - if not filecfg or filecfg.flags.ExcludeFromBuild then - m.element("ExcludedFromBuild", condition, "true") - end - end - - - function m.exceptionHandlingSEH(filecfg, condition) - if not filecfg or filecfg.exceptionhandling == "SEH" then - m.element("UseSafeExceptionHandlers", condition, "true") - end - end - - - function m.extensionsToDeleteOnClean(cfg) - if #cfg.cleanextensions > 0 then - local value = table.implode(cfg.cleanextensions, "*", ";", "") - m.element("ExtensionsToDeleteOnClean", nil, value .. "$(ExtensionsToDeleteOnClean)") - end - end - - - function m.fileType(cfg, file) - m.element("FileType", nil, "Document") - end - - - function m.floatingPointModel(cfg) - if cfg.floatingpoint and cfg.floatingpoint ~= "Default" then - m.element("FloatingPointModel", nil, cfg.floatingpoint) - end - end - - - function m.floatingPointExceptions(cfg) - if cfg.floatingpointexceptions ~= nil then - if cfg.floatingpointexceptions then - m.element("FloatingPointExceptions", nil, "true") - else - m.element("FloatingPointExceptions", nil, "false") - end - end - end - - - function m.inlineFunctionExpansion(cfg) - if cfg.inlining then - local types = { - Default = "Default", - Disabled = "Disabled", - Explicit = "OnlyExplicitInline", - Auto = "AnySuitable", - } - m.element("InlineFunctionExpansion", nil, types[cfg.inlining]) - end - end - - - function m.forceIncludes(cfg, condition) - if #cfg.forceincludes > 0 then - local includes = vstudio.path(cfg, cfg.forceincludes) - if #includes > 0 then - m.element("ForcedIncludeFiles", condition, table.concat(includes, ';')) - end - end - if #cfg.forceusings > 0 then - local usings = vstudio.path(cfg, cfg.forceusings) - if #usings > 0 then - m.element("ForcedUsingFiles", condition, table.concat(usings, ';')) - end - end - end - - - function m.fullProgramDatabaseFile(cfg) - if _ACTION >= "vs2015" and cfg.symbols == "FastLink" then - m.element("FullProgramDatabaseFile", nil, "true") - end - end - - - function m.functionLevelLinking(cfg) - if cfg.functionlevellinking ~= nil then - if cfg.functionlevellinking then - m.element("FunctionLevelLinking", nil, "true") - else - m.element("FunctionLevelLinking", nil, "false") - end - elseif config.isOptimizedBuild(cfg) then - m.element("FunctionLevelLinking", nil, "true") - end - end - - - function m.generateDebugInformation(cfg) - local lookup = {} - if _ACTION >= "vs2017" then - lookup[p.ON] = "true" - lookup[p.OFF] = "false" - lookup["FastLink"] = "DebugFastLink" - lookup["Full"] = "DebugFull" - elseif _ACTION == "vs2015" then - lookup[p.ON] = "true" - lookup[p.OFF] = "false" - lookup["FastLink"] = "DebugFastLink" - lookup["Full"] = "true" - else - lookup[p.ON] = "true" - lookup[p.OFF] = "false" - lookup["FastLink"] = "true" - lookup["Full"] = "true" - end - - local value = lookup[cfg.symbols] - if value then - m.element("GenerateDebugInformation", nil, value) - end - end - - - function m.generateManifest(cfg) - if cfg.flags.NoManifest then - m.element("GenerateManifest", nil, "false") - end - end - - - function m.generateMapFile(cfg) - if cfg.flags.Maps then - m.element("GenerateMapFile", nil, "true") - end - end - - - function m.ignoreDefaultLibraries(cfg) - if #cfg.ignoredefaultlibraries > 0 then - local ignored = cfg.ignoredefaultlibraries - for i = 1, #ignored do - -- Add extension if required - if not p.tools.msc.getLibraryExtensions()[ignored[i]:match("[^.]+$")] then - ignored[i] = path.appendextension(ignored[i], ".lib") - end - end - - m.element("IgnoreSpecificDefaultLibraries", condition, table.concat(ignored, ';')) - end - end - - - function m.ignoreWarnDuplicateFilename(prj) - -- VS 2013 warns on duplicate file names, even those files which are - -- contained in different, mututally exclusive configurations. See: - -- http://connect.microsoft.com/VisualStudio/feedback/details/797460/incorrect-warning-msb8027-reported-for-files-excluded-from-build - -- Premake already adds unique object names to conflicting file names, so - -- just go ahead and disable that warning. - if _ACTION > "vs2012" then - m.element("IgnoreWarnCompileDuplicatedFilename", nil, "true") - end - end - - - function m.ignoreImportLibrary(cfg) - if cfg.kind == p.SHAREDLIB and cfg.flags.NoImportLib then - m.element("IgnoreImportLibrary", nil, "true") - end - end - - - function m.imageXex(cfg) - if cfg.system == p.XBOX360 then - p.push('') - if cfg.configfile then - m.element("ConfigurationFile", nil, "%s", cfg.configfile) - else - p.w('') - p.w('') - end - p.w('') - p.w('') - p.pop('') - end - end - - - function m.imageXexOutput(cfg) - if cfg.system == p.XBOX360 then - m.element("ImageXexOutput", nil, "%s", "$(OutDir)$(TargetName).xex") - end - end - - - function m.importLanguageTargets(prj) - p.w('') - end - - m.elements.importExtensionTargets = function(prj) - return { - m.importGroupTargets, - m.importRuleTargets, - m.importNuGetTargets, - m.importBuildCustomizationsTargets - } - end - - function m.importExtensionTargets(prj) - p.push('') - p.callArray(m.elements.importExtensionTargets, prj) - p.pop('') - end - - function m.importGroupTargets(prj) - local groups = m.categorizeSources(prj) - for _, group in ipairs(groups) do - if group.category.emitExtensionTargets then - group.category.emitExtensionTargets(prj, group) - end - end - end - - function m.importRuleTargets(prj) - for i = 1, #prj.rules do - local rule = p.global.getRule(prj.rules[i]) - local loc = vstudio.path(prj, p.filename(rule, ".targets")) - p.x('', loc) - end - end - - local function nuGetTargetsFile(prj, package) - local packageAPIInfo = vstudio.nuget2010.packageAPIInfo(prj, package) - return p.vstudio.path(prj, p.filename(prj.solution, string.format("packages\\%s.%s\\build\\native\\%s.targets", vstudio.nuget2010.packageId(package), packageAPIInfo.verbatimVersion or packageAPIInfo.version, vstudio.nuget2010.packageId(package)))) - end - - function m.importNuGetTargets(prj) - for i = 1, #prj.nuget do - local targetsFile = nuGetTargetsFile(prj, prj.nuget[i]) - p.x('', targetsFile, targetsFile) - end - end - - function m.importBuildCustomizationsTargets(prj) - for i, build in ipairs(prj.buildcustomizations) do - p.w('', path.translate(build)) - end - end - - - - function m.ensureNuGetPackageBuildImports(prj) - if #prj.nuget > 0 then - p.push('') - p.push('') - p.x('This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.') - p.pop('') - - for i = 1, #prj.nuget do - local targetsFile = nuGetTargetsFile(prj, prj.nuget[i]) - p.x('', targetsFile, targetsFile) - end - p.pop('') - end - end - - - - function m.importDefaultProps(prj) - p.w('') - end - - - - function m.importLanguageSettings(prj) - p.w('') - end - - m.elements.importExtensionSettings = function(prj) - return { - m.importGroupSettings, - m.importRuleSettings, - m.importBuildCustomizationsProps - } - end - - function m.importExtensionSettings(prj) - p.push('') - p.callArray(m.elements.importExtensionSettings, prj) - p.pop('') - end - - - function m.importGroupSettings(prj) - local groups = m.categorizeSources(prj) - for _, group in ipairs(groups) do - if group.category.emitExtensionSettings then - group.category.emitExtensionSettings(prj, group) - end - end - end - - - function m.importRuleSettings(prj) - for i = 1, #prj.rules do - local rule = p.global.getRule(prj.rules[i]) - local loc = vstudio.path(prj, p.filename(rule, ".props")) - p.x('', loc) - end - end - - - function m.importBuildCustomizationsProps(prj) - for i, build in ipairs(prj.buildcustomizations) do - p.w('', path.translate(build)) - end - end - - - - function m.importLibrary(cfg) - if cfg.kind == p.SHAREDLIB then - m.element("ImportLibrary", nil, "%s", path.translate(cfg.linktarget.relpath)) - end - end - - - function m.includePath(cfg) - local dirs = vstudio.path(cfg, cfg.sysincludedirs) - if #dirs > 0 then - m.element("IncludePath", nil, "%s;$(IncludePath)", table.concat(dirs, ";")) - end - end - - - function m.intDir(cfg) - local objdir = vstudio.path(cfg, cfg.objdir) - m.element("IntDir", nil, "%s\\", objdir) - end - - - function m.intrinsicFunctions(cfg) - if cfg.intrinsics ~= nil then - if cfg.intrinsics then - m.element("IntrinsicFunctions", nil, "true") - else - m.element("IntrinsicFunctions", nil, "false") - end - elseif config.isOptimizedBuild(cfg) then - m.element("IntrinsicFunctions", nil, "true") - end - end - - - function m.keyword(prj) - -- try to determine what kind of targets we're building here - local isWin, isManaged, isMakefile - for cfg in project.eachconfig(prj) do - if cfg.system == p.WINDOWS then - isWin = true - end - if cfg.clr ~= p.OFF then - isManaged = true - end - if vstudio.isMakefile(cfg) then - isMakefile = true - end - end - - if isWin then - if isMakefile then - m.element("Keyword", nil, "MakeFileProj") - else - if isManaged or m.isClrMixed(prj) then - m.targetFramework(prj) - end - if isManaged then - m.element("Keyword", nil, "ManagedCProj") - else - m.element("Keyword", nil, "Win32Proj") - end - m.element("RootNamespace", nil, "%s", prj.name) - end - end - end - - - function m.libraryPath(cfg) - local dirs = vstudio.path(cfg, cfg.syslibdirs) - if #dirs > 0 then - m.element("LibraryPath", nil, "%s;$(LibraryPath)", table.concat(dirs, ";")) - end - end - - - - function m.linkIncremental(cfg) - if cfg.kind ~= p.STATICLIB then - m.element("LinkIncremental", nil, "%s", tostring(config.canLinkIncremental(cfg))) - end - end - - - function m.linkLibraryDependencies(cfg, explicit) - -- Left to its own devices, VS will happily link against a project dependency - -- that has been excluded from the build. As a workaround, disable dependency - -- linking and list all siblings explicitly - if explicit then - p.push('') - m.element("LinkLibraryDependencies", nil, "false") - p.pop('') - end - end - - - function m.minimalRebuild(cfg) - if config.isOptimizedBuild(cfg) or - cfg.flags.NoMinimalRebuild or - cfg.flags.MultiProcessorCompile or - cfg.debugformat == p.C7 - then - m.element("MinimalRebuild", nil, "false") - end - end - - - function m.moduleDefinitionFile(cfg) - local df = config.findfile(cfg, ".def") - if df then - m.element("ModuleDefinitionFile", nil, "%s", df) - end - end - - - function m.multiProcessorCompilation(cfg) - if cfg.flags.MultiProcessorCompile then - m.element("MultiProcessorCompilation", nil, "true") - end - end - - - function m.nmakeBuildCommands(cfg) - m.nmakeCommandLine(cfg, cfg.buildcommands, "Build") - end - - - function m.nmakeCleanCommands(cfg) - m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean") - end - - - function m.nmakeCommandLine(cfg, commands, phase) - if #commands > 0 then - commands = os.translateCommandsAndPaths(commands, cfg.project.basedir, cfg.project.location) - commands = table.concat(p.esc(commands), p.eol()) - p.w('%s', phase, commands, phase) - end - end - - - function m.nmakeIncludeDirs(cfg) - if cfg.kind ~= p.NONE and #cfg.includedirs > 0 then - local dirs = vstudio.path(cfg, cfg.includedirs) - if #dirs > 0 then - m.element("NMakeIncludeSearchPath", nil, "%s", table.concat(dirs, ";")) - end - end - end - - - function m.nmakeOutDirs(cfg) - if vstudio.isMakefile(cfg) then - m.outDir(cfg) - m.intDir(cfg) - end - end - - - function m.windowsSDKDesktopARMSupport(cfg) - if cfg.architecture == p.ARM then - p.w('true') - end - end - - - function m.nmakeOutput(cfg) - m.element("NMakeOutput", nil, "$(OutDir)%s", cfg.buildtarget.name) - end - - - function m.nmakePreprocessorDefinitions(cfg) - if cfg.kind ~= p.NONE and #cfg.defines > 0 then - local defines = table.concat(cfg.defines, ";") - defines = defines .. ";$(NMakePreprocessorDefinitions)" - m.element('NMakePreprocessorDefinitions', nil, defines) - end - end - - - function m.nmakeRebuildCommands(cfg) - m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild") - end - - - function m.objectFileName(fcfg) - if fcfg.objname ~= fcfg.basename then - m.element("ObjectFileName", m.condition(fcfg.config), "$(IntDir)\\%s.obj", fcfg.objname) - end - end - - - - function m.omitDefaultLib(cfg) - if cfg.flags.OmitDefaultLibrary then - m.element("OmitDefaultLibName", nil, "true") - end - end - - - - function m.omitFramePointers(cfg) - if cfg.flags.NoFramePointer then - m.element("OmitFramePointers", nil, "true") - end - end - - - function m.optimizeReferences(cfg) - if config.isOptimizedBuild(cfg) then - m.element("EnableCOMDATFolding", nil, "true") - m.element("OptimizeReferences", nil, "true") - end - end - - - function m.optimization(cfg, condition) - local map = { Off="Disabled", On="Full", Debug="Disabled", Full="Full", Size="MinSpace", Speed="MaxSpeed" } - local value = map[cfg.optimize] - if value or not condition then - m.element('Optimization', condition, value or "Disabled") - end - end - - - function m.outDir(cfg) - local outdir = vstudio.path(cfg, cfg.buildtarget.directory) - m.element("OutDir", nil, "%s\\", outdir) - end - - - function m.outputFile(cfg) - if cfg.system == p.XBOX360 then - m.element("OutputFile", nil, "$(OutDir)%s", cfg.buildtarget.name) - end - end - - - function m.executablePath(cfg) - local dirs = vstudio.path(cfg, cfg.bindirs) - if #dirs > 0 then - dirs = table.translate(dirs, function(dir) - if path.isabsolute(dir) then - return dir - end - return "$(ProjectDir)" .. dir - end) - m.element("ExecutablePath", nil, "%s;$(ExecutablePath)", table.concat(dirs, ";")) - end - end - - - function m.platformToolset(cfg) - local tool, version = p.config.toolset(cfg) - if not version then - local action = p.action.current() - version = action.vstudio.platformToolset - end - if version then - if cfg.kind == p.NONE or cfg.kind == p.MAKEFILE then - if p.config.hasFile(cfg, path.iscppfile) then - m.element("PlatformToolset", nil, version) - end - else - m.element("PlatformToolset", nil, version) - end - end - end - - - function m.precompiledHeader(cfg, condition) - prjcfg, filecfg = p.config.normalize(cfg) - if filecfg then - if prjcfg.pchsource == filecfg.abspath and not prjcfg.flags.NoPCH then - m.element('PrecompiledHeader', condition, 'Create') - elseif filecfg.flags.NoPCH then - m.element('PrecompiledHeader', condition, 'NotUsing') - end - else - if not prjcfg.flags.NoPCH and prjcfg.pchheader then - m.element("PrecompiledHeader", nil, "Use") - m.element("PrecompiledHeaderFile", nil, "%s", prjcfg.pchheader) - else - m.element("PrecompiledHeader", nil, "NotUsing") - end - end - end - - - function m.preprocessorDefinitions(cfg, defines, escapeQuotes, condition) - if #defines > 0 then - defines = table.concat(defines, ";") - if escapeQuotes then - defines = defines:gsub('"', '\\"') - end - defines = defines .. ";%%(PreprocessorDefinitions)" - m.element('PreprocessorDefinitions', condition, defines) - end - end - - - function m.undefinePreprocessorDefinitions(cfg, undefines, escapeQuotes, condition) - if #undefines > 0 then - undefines = table.concat(undefines, ";") - if escapeQuotes then - undefines = undefines:gsub('"', '\\"') - end - undefines = undefines .. ";%%(UndefinePreprocessorDefinitions)" - m.element('UndefinePreprocessorDefinitions', condition, undefines) - end - end - - - function m.programDatabaseFile(cfg) - if cfg.symbolspath and cfg.symbols == p.ON and cfg.debugformat ~= "c7" then - m.element("ProgramDatabaseFile", nil, p.project.getrelative(cfg.project, cfg.symbolspath)) - end - end - - - function m.projectGuid(prj) - m.element("ProjectGuid", nil, "{%s}", prj.uuid) - end - - - function m.projectName(prj) - if prj.name ~= prj.filename then - m.element("ProjectName", nil, "%s", prj.name) - end - end - - - function m.propertyGroup(cfg, label) - local cond - if cfg then - cond = string.format(' %s', m.condition(cfg)) - end - - if label then - label = string.format(' Label="%s"', label) - end - - p.push('', cond or "", label or "") - end - - - - function m.propertySheets(cfg) - p.push('', m.condition(cfg)) - p.w('') - p.pop('') - end - - - function m.propertySheetGroup(prj) - for cfg in project.eachconfig(prj) do - m.propertySheets(cfg) - end - end - - - function m.referenceCopyLocalSatelliteAssemblies(prj, ref) - m.element("CopyLocalSatelliteAssemblies", nil, "false") - end - - - function m.referenceLinkLibraryDependencies(prj, ref) - m.element("LinkLibraryDependencies", nil, "true") - end - - - function m.referenceOutputAssembly(prj, ref) - m.element("ReferenceOutputAssembly", nil, "true") - end - - - function m.referencePrivate(prj, ref) - m.element("Private", nil, "true") - end - - - function m.referenceProject(prj, ref) - m.element("Project", nil, "{%s}", ref.uuid) - end - - - function m.referenceUseLibraryDependences(prj, ref) - m.element("UseLibraryDependencyInputs", nil, "false") - end - - - function m.resourceAdditionalIncludeDirectories(cfg) - m.additionalIncludeDirectories(cfg, table.join(cfg.includedirs, cfg.resincludedirs)) - end - - - function m.resourcePreprocessorDefinitions(cfg) - local defines = table.join(cfg.defines, cfg.resdefines) - if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then - table.insert(defines, "_HAS_EXCEPTIONS=0") - end - m.preprocessorDefinitions(cfg, defines, true) - end - - - function m.runtimeLibrary(cfg) - local runtimes = { - StaticDebug = "MultiThreadedDebug", - StaticRelease = "MultiThreaded", - } - local runtime = runtimes[config.getruntime(cfg)] - if runtime then - m.element("RuntimeLibrary", nil, runtime) - end - end - - function m.callingConvention(cfg) - if cfg.callingconvention then - m.element("CallingConvention", nil, cfg.callingconvention) - end - end - - function m.runtimeTypeInfo(cfg, condition) - if cfg.rtti == p.OFF and ((not cfg.clr) or cfg.clr == p.OFF) then - m.element("RuntimeTypeInfo", condition, "false") - elseif cfg.rtti == p.ON then - m.element("RuntimeTypeInfo", condition, "true") - end - end - - function m.bufferSecurityCheck(cfg) - local tool, toolVersion = p.config.toolset(cfg) - if cfg.flags.NoBufferSecurityCheck or (toolVersion and toolVersion:startswith("LLVM-vs")) then - m.element("BufferSecurityCheck", nil, "false") - end - end - - function m.stringPooling(cfg) - if cfg.stringpooling ~= nil then - if cfg.stringpooling then - m.element("StringPooling", nil, "true") - else - m.element("StringPooling", nil, "false") - end - elseif config.isOptimizedBuild(cfg) then - m.element("StringPooling", nil, "true") - end - end - - - function m.subSystem(cfg) - if cfg.system ~= p.XBOX360 then - local subsystem = iif(cfg.kind == p.CONSOLEAPP, "Console", "Windows") - m.element("SubSystem", nil, subsystem) - end - end - - - function m.targetExt(cfg) - local ext = cfg.buildtarget.extension - if ext ~= "" then - m.element("TargetExt", nil, "%s", ext) - else - p.w('') - p.w('') - end - end - - - function m.targetMachine(cfg) - -- If a static library project contains a resource file, VS will choke with - -- "LINK : warning LNK4068: /MACHINE not specified; defaulting to X86" - local targetmachine = { - x86 = "MachineX86", - x86_64 = "MachineX64", - } - if cfg.kind == p.STATICLIB and config.hasFile(cfg, path.isresourcefile) then - local value = targetmachine[cfg.architecture] - if value ~= nil then - m.element("TargetMachine", nil, '%s', value) - end - end - end - - - function m.targetName(cfg) - m.element("TargetName", nil, "%s%s", cfg.buildtarget.prefix, cfg.buildtarget.basename) - end - - - function m.targetPlatformVersion(prj) - local min = project.systemversion(prj) - if min ~= nil and _ACTION >= "vs2015" then - m.element("WindowsTargetPlatformVersion", nil, min) - end - end - - - function m.treatLinkerWarningAsErrors(cfg) - if cfg.flags.FatalLinkWarnings then - local el = iif(cfg.kind == p.STATICLIB, "Lib", "Linker") - m.element("Treat" .. el .. "WarningAsErrors", nil, "true") - end - end - - - function m.treatWChar_tAsBuiltInType(cfg) - local map = { On = "true", Off = "false" } - local value = map[cfg.nativewchar] - if value then - m.element("TreatWChar_tAsBuiltInType", nil, value) - end - end - - - function m.treatWarningAsError(cfg) - if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then - m.element("TreatWarningAsError", nil, "true") - end - end - - - function m.disableSpecificWarnings(cfg, condition) - if #cfg.disablewarnings > 0 then - local warnings = table.concat(cfg.disablewarnings, ";") - warnings = warnings .. ";%%(DisableSpecificWarnings)" - m.element('DisableSpecificWarnings', condition, warnings) - end - end - - - function m.treatSpecificWarningsAsErrors(cfg, condition) - if #cfg.fatalwarnings > 0 then - local fatal = table.concat(cfg.fatalwarnings, ";") - fatal = fatal .. ";%%(TreatSpecificWarningsAsErrors)" - m.element('TreatSpecificWarningsAsErrors', condition, fatal) - end - end - - - function m.useDebugLibraries(cfg) - local runtime = config.getruntime(cfg) - m.element("UseDebugLibraries", nil, tostring(runtime:endswith("Debug"))) - end - - - function m.useOfMfc(cfg) - if cfg.flags.MFC then - m.element("UseOfMfc", nil, iif(cfg.flags.StaticRuntime, "Static", "Dynamic")) - end - end - - function m.useOfAtl(cfg) - if cfg.atl then - m.element("UseOfATL", nil, cfg.atl) - end - end - - - - function m.userMacros(cfg) - p.w('') - end - - - - function m.warningLevel(cfg) - local map = { Off = "TurnOffAllWarnings", Extra = "Level4" } - m.element("WarningLevel", nil, "%s", map[cfg.warnings] or "Level3") - end - - - - function m.xmlDeclaration() - p.xmlUtf8() - end - - - ---------------------------------------------------------------------------- --- --- Support functions --- ---------------------------------------------------------------------------- - --- --- Format and return a Visual Studio Condition attribute. --- - - function m.condition(cfg) - return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', p.esc(vstudio.projectConfig(cfg))) - end - - --- --- Output an individual project XML element, with an optional configuration --- condition. --- --- @param depth --- How much to indent the element. --- @param name --- The element name. --- @param condition --- An optional configuration condition, formatted with vc2010.condition(). --- @param value --- The element value, which may contain printf formatting tokens. --- @param ... --- Optional additional arguments to satisfy any tokens in the value. --- - - function m.element(name, condition, value, ...) - if select('#',...) == 0 then - value = p.esc(value) - end - - local format - if condition then - format = string.format('<%s %s>%s', name, condition, value, name) - else - format = string.format('<%s>%s', name, value, name) - end - - p.x(format, ...) - end +-- +-- vs2010_vcxproj.lua +-- Generate a Visual Studio 201x C/C++ project. +-- Copyright (c) 2009-2015 Jason Perkins and the Premake project +-- + + local p = premake + p.vstudio.vc2010 = {} + + local vstudio = p.vstudio + local project = p.project + local config = p.config + local fileconfig = p.fileconfig + local tree = p.tree + + local m = p.vstudio.vc2010 + + +--- +-- Add namespace for element definition lists for p.callArray() +--- + + m.elements = {} + + +-- +-- Generate a Visual Studio 201x C++ project, with support for the new platforms API. +-- + + m.elements.project = function(prj) + return { + m.xmlDeclaration, + m.project, + m.projectConfigurations, + m.globals, + m.importDefaultProps, + m.configurationPropertiesGroup, + m.importLanguageSettings, + m.importExtensionSettings, + m.propertySheetGroup, + m.userMacros, + m.outputPropertiesGroup, + m.itemDefinitionGroups, + m.assemblyReferences, + m.files, + m.projectReferences, + m.importLanguageTargets, + m.importExtensionTargets, + m.ensureNuGetPackageBuildImports, + } + end + + function m.generate(prj) + p.utf8() + p.callArray(m.elements.project, prj) + p.out('') + end + + +-- +-- Output the XML declaration and opening tag. +-- + + function m.project(prj) + local action = p.action.current() + p.push('', + action.vstudio.toolsVersion) + end + + +-- +-- Write out the list of project configurations, which pairs build +-- configurations with architectures. +-- + + function m.projectConfigurations(prj) + + -- build a list of all architectures used in this project + local platforms = {} + for cfg in project.eachconfig(prj) do + local arch = vstudio.archFromConfig(cfg, true) + if not table.contains(platforms, arch) then + table.insert(platforms, arch) + end + end + + local configs = {} + p.push('') + for cfg in project.eachconfig(prj) do + for _, arch in ipairs(platforms) do + local prjcfg = vstudio.projectConfig(cfg, arch) + if not configs[prjcfg] then + configs[prjcfg] = prjcfg + p.push('', vstudio.projectConfig(cfg, arch)) + p.x('%s', vstudio.projectPlatform(cfg)) + p.w('%s', arch) + p.pop('') + end + end + end + p.pop('') + end + + +-- +-- Write out the TargetFrameworkVersion property. +-- + + function m.targetFramework(prj) + local action = p.action.current() + local tools = string.format(' ToolsVersion="%s"', action.vstudio.toolsVersion) + + local framework = prj.dotnetframework or action.vstudio.targetFramework or "4.0" + p.w('v%s', framework) + end + + + +-- +-- Write out the Globals property group. +-- + + m.elements.globals = function(prj) + return { + m.projectGuid, + m.ignoreWarnDuplicateFilename, + m.keyword, + m.projectName, + m.targetPlatformVersion, + } + end + + function m.globals(prj) + m.propertyGroup(nil, "Globals") + p.callArray(m.elements.globals, prj) + p.pop('') + end + + +-- +-- Write out the configuration property group: what kind of binary it +-- produces, and some global settings. +-- + + m.elements.configurationProperties = function(cfg) + if cfg.kind == p.UTILITY then + return { + m.configurationType, + m.platformToolset, + } + else + return { + m.configurationType, + m.useDebugLibraries, + m.useOfMfc, + m.useOfAtl, + m.clrSupport, + m.characterSet, + m.platformToolset, + m.wholeProgramOptimization, + m.nmakeOutDirs, + m.windowsSDKDesktopARMSupport, + } + end + end + + function m.configurationProperties(cfg) + m.propertyGroup(cfg, "Configuration") + p.callArray(m.elements.configurationProperties, cfg) + p.pop('') + end + + function m.configurationPropertiesGroup(prj) + for cfg in project.eachconfig(prj) do + m.configurationProperties(cfg) + end + end + + + +-- +-- Write the output property group, which includes the output and intermediate +-- directories, manifest, etc. +-- + + m.elements.outputProperties = function(cfg) + if cfg.kind == p.UTILITY then + return { + m.outDir, + m.intDir, + m.extensionsToDeleteOnClean, + } + else + return { + m.linkIncremental, + m.ignoreImportLibrary, + m.outDir, + m.outputFile, + m.intDir, + m.targetName, + m.targetExt, + m.includePath, + m.libraryPath, + m.imageXexOutput, + m.generateManifest, + m.extensionsToDeleteOnClean, + m.executablePath, + } + end + end + + function m.outputProperties(cfg) + if not vstudio.isMakefile(cfg) then + m.propertyGroup(cfg) + p.callArray(m.elements.outputProperties, cfg) + p.pop('') + end + end + + +-- +-- Write the NMake property group for Makefile projects, which includes the custom +-- build commands, output file location, etc. +-- + + m.elements.nmakeProperties = function(cfg) + return { + m.nmakeOutput, + m.nmakeBuildCommands, + m.nmakeRebuildCommands, + m.nmakeCleanCommands, + m.nmakePreprocessorDefinitions, + m.nmakeIncludeDirs + } + end + + function m.nmakeProperties(cfg) + if vstudio.isMakefile(cfg) then + m.propertyGroup(cfg) + p.callArray(m.elements.nmakeProperties, cfg) + p.pop('') + end + end + + +-- +-- Output properties and NMake properties should appear side-by-side +-- for each configuration. +-- + + function m.outputPropertiesGroup(prj) + for cfg in project.eachconfig(prj) do + m.outputProperties(cfg) + m.nmakeProperties(cfg) + end + end + + + +-- +-- Write a configuration's item definition group, which contains all +-- of the per-configuration compile and link settings. +-- + + m.elements.itemDefinitionGroup = function(cfg) + if cfg.kind == p.UTILITY then + return { + m.ruleVars, + m.buildEvents, + } + else + return { + m.clCompile, + m.resourceCompile, + m.linker, + m.manifest, + m.buildEvents, + m.imageXex, + m.deploy, + m.ruleVars, + m.buildLog, + } + end + end + + function m.itemDefinitionGroup(cfg) + if not vstudio.isMakefile(cfg) then + p.push('', m.condition(cfg)) + p.callArray(m.elements.itemDefinitionGroup, cfg) + p.pop('') + + else + if cfg == project.getfirstconfig(cfg.project) then + p.w('') + p.w('') + end + end + end + + function m.itemDefinitionGroups(prj) + for cfg in project.eachconfig(prj) do + m.itemDefinitionGroup(cfg) + end + end + + + +-- +-- Write the the compiler settings block. +-- + + m.elements.clCompile = function(cfg) + return { + m.precompiledHeader, + m.warningLevel, + m.treatWarningAsError, + m.disableSpecificWarnings, + m.treatSpecificWarningsAsErrors, + m.basicRuntimeChecks, + m.clCompilePreprocessorDefinitions, + m.clCompileUndefinePreprocessorDefinitions, + m.clCompileAdditionalIncludeDirectories, + m.clCompileAdditionalUsingDirectories, + m.forceIncludes, + m.debugInformationFormat, + m.optimization, + m.functionLevelLinking, + m.intrinsicFunctions, + m.minimalRebuild, + m.omitFramePointers, + m.stringPooling, + m.runtimeLibrary, + m.omitDefaultLib, + m.exceptionHandling, + m.runtimeTypeInfo, + m.bufferSecurityCheck, + m.treatWChar_tAsBuiltInType, + m.floatingPointModel, + m.floatingPointExceptions, + m.inlineFunctionExpansion, + m.enableEnhancedInstructionSet, + m.multiProcessorCompilation, + m.additionalCompileOptions, + m.compileAs, + m.callingConvention, + m.languageStandard, + } + end + + function m.clCompile(cfg) + p.push('') + p.callArray(m.elements.clCompile, cfg) + p.pop('') + end + + +-- +-- Write out the resource compiler block. +-- + + m.elements.resourceCompile = function(cfg) + return { + m.resourcePreprocessorDefinitions, + m.resourceAdditionalIncludeDirectories, + m.culture, + } + end + + function m.resourceCompile(cfg) + if cfg.system ~= p.XBOX360 and p.config.hasFile(cfg, path.isresourcefile) then + local contents = p.capture(function () + p.push() + p.callArray(m.elements.resourceCompile, cfg) + p.pop() + end) + + if #contents > 0 then + p.push('') + p.outln(contents) + p.pop('') + end + end + end + + +-- +-- Write out the linker tool block. +-- + + m.elements.linker = function(cfg, explicit) + return { + m.link, + m.lib, + m.linkLibraryDependencies, + } + end + + function m.linker(cfg) + local explicit = vstudio.needsExplicitLink(cfg) + p.callArray(m.elements.linker, cfg, explicit) + end + + + + m.elements.link = function(cfg, explicit) + if cfg.kind == p.STATICLIB then + return { + m.subSystem, + m.fullProgramDatabaseFile, + m.generateDebugInformation, + m.optimizeReferences, + } + else + return { + m.subSystem, + m.fullProgramDatabaseFile, + m.generateDebugInformation, + m.optimizeReferences, + m.additionalDependencies, + m.additionalLibraryDirectories, + m.importLibrary, + m.entryPointSymbol, + m.generateMapFile, + m.moduleDefinitionFile, + m.treatLinkerWarningAsErrors, + m.ignoreDefaultLibraries, + m.largeAddressAware, + m.targetMachine, + m.additionalLinkOptions, + m.programDatabaseFile, + } + end + end + + function m.link(cfg, explicit) + local contents = p.capture(function () + p.push() + p.callArray(m.elements.link, cfg, explicit) + p.pop() + end) + if #contents > 0 then + p.push('') + p.outln(contents) + p.pop('') + end + end + + + + m.elements.lib = function(cfg, explicit) + if cfg.kind == p.STATICLIB then + return { + m.additionalDependencies, + m.additionalLibraryDirectories, + m.treatLinkerWarningAsErrors, + m.targetMachine, + m.additionalLinkOptions, + } + else + return {} + end + end + + function m.lib(cfg, explicit) + local contents = p.capture(function () + p.push() + p.callArray(m.elements.lib, cfg, explicit) + p.pop() + end) + if #contents > 0 then + p.push('') + p.outln(contents) + p.pop('') + end + end + + + +-- +-- Write the manifest section. +-- + + function m.manifest(cfg) + if cfg.kind ~= p.STATICLIB then + -- get the manifests files + local manifests = {} + for _, fname in ipairs(cfg.files) do + if path.getextension(fname) == ".manifest" then + table.insert(manifests, project.getrelative(cfg.project, fname)) + end + end + + if #manifests > 0 then + p.push('') + m.element("AdditionalManifestFiles", nil, "%s %%(AdditionalManifestFiles)", table.concat(manifests, " ")) + p.pop('') + end + end + end + + + +--- +-- Write out the pre- and post-build event settings. +--- + + function m.buildEvents(cfg) + local write = function (event) + local name = event .. "Event" + local field = event:lower() + local steps = cfg[field .. "commands"] + local msg = cfg[field .. "message"] + + if #steps > 0 then + steps = os.translateCommandsAndPaths(steps, cfg.project.basedir, cfg.project.location) + p.push('<%s>', name) + p.x('%s', table.implode(steps, "", "", "\r\n")) + if msg then + p.x('%s', msg) + end + p.pop('', name) + end + end + + write("PreBuild") + write("PreLink") + write("PostBuild") + end + + + +--- +-- Write out project-level custom rule variables. +--- + + function m.ruleVars(cfg) + for i = 1, #cfg.rules do + local rule = p.global.getRule(cfg.rules[i]) + + local contents = p.capture(function () + p.push() + for prop in p.rule.eachProperty(rule) do + local fld = p.rule.getPropertyField(rule, prop) + local value = cfg[fld.name] + if value ~= nil then + if fld.kind == "list:path" then + value = table.concat(vstudio.path(cfg, value), ';') + elseif fld.kind == "path" then + value = vstudio.path(cfg, value) + else + value = p.rule.getPropertyString(rule, prop, value) + end + + if value ~= nil and #value > 0 then + m.element(prop.name, nil, '%s', value) + end + end + end + p.pop() + end) + + if #contents > 0 then + p.push('<%s>', rule.name) + p.outln(contents) + p.pop('', rule.name) + end + end + end + + +-- +-- Reference any managed assemblies listed in the links() +-- + + function m.assemblyReferences(prj) + -- Visual Studio doesn't support per-config references; use + -- whatever is contained in the first configuration + local cfg = project.getfirstconfig(prj) + + local refs = config.getlinks(cfg, "system", "fullpath", "managed") + if #refs > 0 then + p.push('') + for i = 1, #refs do + local value = refs[i] + + -- If the link contains a '/' then it is a relative path to + -- a local assembly. Otherwise treat it as a system assembly. + if value:find('/', 1, true) then + p.push('', path.getbasename(value)) + p.x('%s', path.translate(value)) + p.pop('') + else + p.x('', path.getbasename(value)) + end + end + p.pop('') + end + end + + + function m.generatedFile(cfg, file) + if file.generated then + local path = path.translate(file.dependsOn.relpath) + m.element("AutoGen", nil, 'true') + m.element("DependentUpon", nil, path) + end + end + + +--- +-- Write out the list of source code files, and any associated configuration. +--- + + function m.files(prj) + local groups = m.categorizeSources(prj) + for _, group in ipairs(groups) do + group.category.emitFiles(prj, group) + end + end + + + m.categories = {} + +--- +-- ClInclude group +--- + m.categories.ClInclude = { + name = "ClInclude", + extensions = { ".h", ".hh", ".hpp", ".hxx", ".inl" }, + priority = 1, + + emitFiles = function(prj, group) + m.emitFiles(prj, group, "ClInclude", {m.generatedFile}) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "ClInclude") + end + } + + +--- +-- ClCompile group +--- + m.categories.ClCompile = { + name = "ClCompile", + extensions = { ".cc", ".cpp", ".cxx", ".c", ".s", ".m", ".mm" }, + priority = 2, + + emitFiles = function(prj, group) + local fileCfgFunc = function(fcfg, condition) + if fcfg then + return { + m.excludedFromBuild, + m.objectFileName, + m.clCompilePreprocessorDefinitions, + m.clCompileUndefinePreprocessorDefinitions, + m.optimization, + m.forceIncludes, + m.precompiledHeader, + m.enableEnhancedInstructionSet, + m.additionalCompileOptions, + m.disableSpecificWarnings, + m.treatSpecificWarningsAsErrors, + m.basicRuntimeChecks, + m.exceptionHandling, + m.compileAsManaged, + m.runtimeTypeInfo, + } + else + return { + m.excludedFromBuild + } + end + end + + m.emitFiles(prj, group, "ClCompile", {m.generatedFile}, fileCfgFunc) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "ClCompile") + end + } + + +--- +-- None group +--- + m.categories.None = { + name = "None", + priority = 3, + + emitFiles = function(prj, group) + m.emitFiles(prj, group, "None", {m.generatedFile}) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "None") + end + } + + +--- +-- ResourceCompile group +--- + m.categories.ResourceCompile = { + name = "ResourceCompile", + extensions = ".rc", + priority = 4, + + emitFiles = function(prj, group) + local fileCfgFunc = { + m.excludedFromBuild + } + + m.emitFiles(prj, group, "ResourceCompile", nil, fileCfgFunc, function(cfg) + return cfg.system == p.WINDOWS + end) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "ResourceCompile") + end + } + + +--- +-- CustomBuild group +--- + m.categories.CustomBuild = { + name = "CustomBuild", + priority = 5, + + emitFiles = function(prj, group) + local fileFunc = { + m.fileType + } + + local fileCfgFunc = { + m.excludedFromBuild, + m.buildCommands, + m.buildOutputs, + m.linkObjects, + m.buildMessage, + m.buildAdditionalInputs + } + + m.emitFiles(prj, group, "CustomBuild", fileFunc, fileCfgFunc, function (cfg, fcfg) + return fileconfig.hasCustomBuildRule(fcfg) + end) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "CustomBuild") + end + } + + +--- +-- Midl group +--- + m.categories.Midl = { + name = "Midl", + extensions = ".idl", + priority = 6, + + emitFiles = function(prj, group) + local fileCfgFunc = { + m.excludedFromBuild + } + + m.emitFiles(prj, group, "Midl", nil, fileCfgFunc, function(cfg) + return cfg.system == p.WINDOWS + end) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "Midl") + end + } + +--- +-- Masm group +--- + m.categories.Masm = { + name = "Masm", + extensions = ".asm", + priority = 7, + + emitFiles = function(prj, group) + local fileCfgFunc = function(fcfg, condition) + if fcfg then + return { + m.excludedFromBuild, + m.exceptionHandlingSEH, + } + else + return { + m.excludedFromBuild + } + end + end + m.emitFiles(prj, group, "Masm", nil, fileCfgFunc) + end, + + emitFilter = function(prj, group) + m.filterGroup(prj, group, "Masm") + end, + + emitExtensionSettings = function(prj, group) + p.w('') + end, + + emitExtensionTargets = function(prj, group) + p.w('') + end + } + + +--- +-- Categorize files into groups. +--- + function m.categorizeSources(prj) + -- if we already did this, return the cached result. + if prj._vc2010_sources then + return prj._vc2010_sources + end + + -- build the new group table. + local result = {} + local groups = {} + prj._vc2010_sources = result + + local tr = project.getsourcetree(prj) + tree.traverse(tr, { + onleaf = function(node) + local cat = m.categorizeFile(prj, node) + groups[cat.name] = groups[cat.name] or { + category = cat, + files = {} + } + table.insert(groups[cat.name].files, node) + end + }) + + -- sort by relative-to path; otherwise VS will reorder the files + for name, group in pairs(groups) do + table.sort(group.files, function (a, b) + return a.relpath < b.relpath + end) + table.insert(result, group) + end + + -- sort by category priority then name; so we get stable results. + table.sort(result, function (a, b) + if (a.category.priority == b.category.priority) then + return a.category.name < b.category.name + end + return a.category.priority < b.category.priority + end) + + return result + end + + + function m.categorizeFile(prj, file) + -- If any configuration for this file uses a custom build step, + -- that's the category to use + for cfg in project.eachconfig(prj) do + local fcfg = fileconfig.getconfig(file, cfg) + if fileconfig.hasCustomBuildRule(fcfg) then + return m.categories.CustomBuild + end + end + + -- If there is a custom rule associated with it, use that + local rule = p.global.getRuleForFile(file.name, prj.rules) + if rule then + return { + name = rule.name, + priority = 100, + rule = rule, + emitFiles = function(prj, group) + m.emitRuleFiles(prj, group) + end, + emitFilter = function(prj, group) + m.filterGroup(prj, group, group.category.name) + end + } + end + + -- Otherwise use the file extension to deduce a category + for _, cat in pairs(m.categories) do + if cat.extensions and path.hasextension(file.name, cat.extensions) then + return cat + end + end + + return m.categories.None + end + + + function m.emitFiles(prj, group, tag, fileFunc, fileCfgFunc, checkFunc) + local files = group.files + if files and #files > 0 then + p.push('') + for _, file in ipairs(files) do + + local contents = p.capture(function () + p.push() + p.callArray(fileFunc, cfg, file) + for cfg in project.eachconfig(prj) do + local fcfg = fileconfig.getconfig(file, cfg) + if not checkFunc or checkFunc(cfg, fcfg) then + p.callArray(fileCfgFunc, fcfg, m.condition(cfg)) + end + end + p.pop() + end) + + local rel = path.translate(file.relpath) + if #contents > 0 then + p.push('<%s Include="%s">', tag, rel) + p.outln(contents) + p.pop('', tag) + else + p.x('<%s Include="%s" />', tag, rel) + end + + end + p.pop('') + end + end + + function m.emitRuleFiles(prj, group) + local files = group.files + local rule = group.category.rule + + if files and #files > 0 then + p.push('') + + for _, file in ipairs(files) do + local contents = p.capture(function() + p.push() + for prop in p.rule.eachProperty(rule) do + local fld = p.rule.getPropertyField(rule, prop) + + for cfg in project.eachconfig(prj) do + local fcfg = fileconfig.getconfig(file, cfg) + if fcfg and fcfg[fld.name] then + local value = p.rule.getPropertyString(rule, prop, fcfg[fld.name]) + if value and #value > 0 then + m.element(prop.name, m.condition(cfg), '%s', value) + end + end + end + + end + p.pop() + end) + + if #contents > 0 then + p.push('<%s Include=\"%s\">', rule.name, path.translate(file.relpath)) + p.outln(contents) + p.pop('', rule.name) + else + p.x('<%s Include=\"%s\" />', rule.name, path.translate(file.relpath)) + end + end + + p.pop('') + end + end + + + function m.isClrMixed(prj) + -- check to see if any files are marked with clr + local isMixed = false + if not prj.clr or prj.clr == p.OFF then + if prj._isClrMixed ~= nil then + isMixed = prj._isClrMixed + else + table.foreachi(prj._.files, function(file) + for cfg in p.project.eachconfig(prj) do + local fcfg = p.fileconfig.getconfig(file, cfg) + if fcfg and fcfg.clr and fcfg.clr ~= p.OFF then + isMixed = true + end + end + end) + prj._isClrMixed = isMixed -- cache the results + end + end + return isMixed + end + + +-- +-- Generate the list of project dependencies. +-- + + m.elements.projectReferences = function(prj, ref) + if prj.clr ~= p.OFF or (m.isClrMixed(prj) and ref and ref.kind ~=p.STATICLIB) then + return { + m.referenceProject, + m.referencePrivate, + m.referenceOutputAssembly, + m.referenceCopyLocalSatelliteAssemblies, + m.referenceLinkLibraryDependencies, + m.referenceUseLibraryDependences, + } + else + return { + m.referenceProject, + } + end + end + + function m.projectReferences(prj) + local refs = project.getdependencies(prj, 'linkOnly') + if #refs > 0 then + p.push('') + for _, ref in ipairs(refs) do + local relpath = vstudio.path(prj, vstudio.projectfile(ref)) + p.push('', relpath) + p.callArray(m.elements.projectReferences, prj, ref) + p.pop('') + end + p.pop('') + end + end + + + +--------------------------------------------------------------------------- +-- +-- Handlers for individual project elements +-- +--------------------------------------------------------------------------- + + function m.additionalDependencies(cfg, explicit) + local links + + -- check to see if this project uses an external toolset. If so, let the + -- toolset define the format of the links + local toolset = config.toolset(cfg) + if toolset then + links = toolset.getlinks(cfg, not explicit) + else + links = vstudio.getLinks(cfg, explicit) + end + + if #links > 0 then + links = path.translate(table.concat(links, ";")) + m.element("AdditionalDependencies", nil, "%s;%%(AdditionalDependencies)", links) + end + end + + + function m.additionalIncludeDirectories(cfg, includedirs) + if #includedirs > 0 then + local dirs = vstudio.path(cfg, includedirs) + if #dirs > 0 then + m.element("AdditionalIncludeDirectories", nil, "%s;%%(AdditionalIncludeDirectories)", table.concat(dirs, ";")) + end + end + end + + + function m.additionalLibraryDirectories(cfg) + if #cfg.libdirs > 0 then + local dirs = table.concat(vstudio.path(cfg, cfg.libdirs), ";") + m.element("AdditionalLibraryDirectories", nil, "%s;%%(AdditionalLibraryDirectories)", dirs) + end + end + + + function m.additionalUsingDirectories(cfg) + if #cfg.usingdirs > 0 then + local dirs = vstudio.path(cfg, cfg.usingdirs) + if #dirs > 0 then + m.element("AdditionalUsingDirectories", nil, "%s;%%(AdditionalUsingDirectories)", table.concat(dirs, ";")) + end + end + end + + + function m.largeAddressAware(cfg) + if (cfg.largeaddressaware == true) then + m.element("LargeAddressAware", nil, 'true') + end + end + + + function m.languageStandard(cfg) + if _ACTION >= "vs2017" then + if (cfg.cppdialect == "C++14") then + m.element("LanguageStandard", nil, 'stdcpp14') + elseif (cfg.cppdialect == "C++17") then + m.element("LanguageStandard", nil, 'stdcpplatest') + end + end + end + + + function m.additionalCompileOptions(cfg, condition) + local opts = cfg.buildoptions + if _ACTION == "vs2015" then + if (cfg.cppdialect == "C++14") then + table.insert(opts, "/std:c++14") + elseif (cfg.cppdialect == "C++17") then + table.insert(opts, "/std:c++latest") + end + end + if #opts > 0 then + opts = table.concat(opts, " ") + m.element("AdditionalOptions", condition, '%s %%(AdditionalOptions)', opts) + end + end + + + function m.additionalLinkOptions(cfg) + if #cfg.linkoptions > 0 then + local opts = table.concat(cfg.linkoptions, " ") + m.element("AdditionalOptions", nil, "%s %%(AdditionalOptions)", opts) + end + end + + + function m.compileAsManaged(fcfg, condition) + if fcfg.clr and fcfg ~= p.OFF then + m.element("CompileAsManaged", condition, "true") + end + end + + + function m.basicRuntimeChecks(cfg, condition) + local prjcfg, filecfg = p.config.normalize(cfg) + local runtime = config.getruntime(prjcfg) + if filecfg then + if filecfg.flags.NoRuntimeChecks or (config.isOptimizedBuild(filecfg) and runtime:endswith("Debug")) then + m.element("BasicRuntimeChecks", condition, "Default") + end + else + if prjcfg.flags.NoRuntimeChecks or (config.isOptimizedBuild(prjcfg) and runtime:endswith("Debug")) then + m.element("BasicRuntimeChecks", nil, "Default") + end + end + end + + + function m.buildAdditionalInputs(fcfg, condition) + if fcfg.buildinputs and #fcfg.buildinputs > 0 then + local inputs = project.getrelative(fcfg.project, fcfg.buildinputs) + m.element("AdditionalInputs", condition, '%s', table.concat(inputs, ";")) + end + end + + + function m.buildCommands(fcfg, condition) + local commands = os.translateCommandsAndPaths(fcfg.buildcommands, fcfg.project.basedir, fcfg.project.location) + commands = table.concat(commands,'\r\n') + m.element("Command", condition, '%s', commands) + end + + + function m.buildLog(cfg) + if cfg.buildlog and #cfg.buildlog > 0 then + p.push('') + m.element("Path", nil, "%s", vstudio.path(cfg, cfg.buildlog)) + p.pop('') + end + end + + + function m.buildMessage(fcfg, condition) + if fcfg.buildmessage then + m.element("Message", condition, '%s', fcfg.buildmessage) + end + end + + + function m.buildOutputs(fcfg, condition) + local outputs = project.getrelative(fcfg.project, fcfg.buildoutputs) + m.element("Outputs", condition, '%s', table.concat(outputs, ";")) + end + + + function m.linkObjects(fcfg, condition) + if fcfg.linkbuildoutputs ~= nil then + m.element("LinkObjects", condition, tostring(fcfg.linkbuildoutputs)) + end + end + + + function m.characterSet(cfg) + if not vstudio.isMakefile(cfg) then + local charactersets = { + ASCII = "NotSet", + MBCS = "MultiByte", + Unicode = "Unicode", + Default = "Unicode" + } + m.element("CharacterSet", nil, charactersets[cfg.characterset]) + end + end + + + function m.wholeProgramOptimization(cfg) + if cfg.flags.LinkTimeOptimization then + m.element("WholeProgramOptimization", nil, "true") + end + end + + function m.clCompileAdditionalIncludeDirectories(cfg) + m.additionalIncludeDirectories(cfg, cfg.includedirs) + end + + function m.clCompileAdditionalUsingDirectories(cfg) + m.additionalUsingDirectories(cfg, cfg.usingdirs) + end + + + function m.clCompilePreprocessorDefinitions(cfg, condition) + local defines = cfg.defines + if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then + defines = table.join(defines, "_HAS_EXCEPTIONS=0") + end + m.preprocessorDefinitions(cfg, defines, false, condition) + end + + + function m.clCompileUndefinePreprocessorDefinitions(cfg, condition) + m.undefinePreprocessorDefinitions(cfg, cfg.undefines, false, condition) + end + + + function m.clrSupport(cfg) + local value + if cfg.clr == "On" or cfg.clr == "Unsafe" then + value = "true" + elseif cfg.clr ~= p.OFF then + value = cfg.clr + end + if value then + m.element("CLRSupport", nil, value) + end + end + + + function m.compileAs(cfg) + if p.languages.isc(cfg.compileas) then + m.element("CompileAs", nil, "CompileAsC") + elseif p.languages.iscpp(cfg.compileas) then + m.element("CompileAs", nil, "CompileAsCpp") + end + end + + + function m.configurationType(cfg) + local types = { + SharedLib = "DynamicLibrary", + StaticLib = "StaticLibrary", + ConsoleApp = "Application", + WindowedApp = "Application", + Makefile = "Makefile", + None = "Makefile", + Utility = "Utility", + } + m.element("ConfigurationType", nil, types[cfg.kind]) + end + + + function m.culture(cfg) + local value = vstudio.cultureForLocale(cfg.locale) + if value then + m.element("Culture", nil, "0x%04x", tostring(value)) + end + end + + + function m.debugInformationFormat(cfg) + local value + local tool, toolVersion = p.config.toolset(cfg) + if (cfg.symbols == p.ON) or (cfg.symbols == "FastLink") then + if cfg.debugformat == "c7" then + value = "OldStyle" + elseif (cfg.architecture == "x86_64" and _ACTION < "vs2015") or + cfg.clr ~= p.OFF or + config.isOptimizedBuild(cfg) or + cfg.editandcontinue == p.OFF or + (toolVersion and toolVersion:startswith("LLVM-vs")) + then + value = "ProgramDatabase" + else + value = "EditAndContinue" + end + + m.element("DebugInformationFormat", nil, value) + elseif cfg.symbols == p.OFF then + -- leave field blank for vs2013 and older to workaround bug + if _ACTION < "vs2015" then + value = "" + else + value = "None" + end + + m.element("DebugInformationFormat", nil, value) + end + end + + + function m.deploy(cfg) + if cfg.system == p.XBOX360 then + p.push('') + m.element("DeploymentType", nil, "CopyToHardDrive") + m.element("DvdEmulationType", nil, "ZeroSeekTimes") + m.element("DeploymentFiles", nil, "$(RemoteRoot)=$(ImagePath);") + p.pop('') + end + end + + + function m.enableEnhancedInstructionSet(cfg, condition) + local v + local x = cfg.vectorextensions + if x == "AVX" and _ACTION > "vs2010" then + v = "AdvancedVectorExtensions" + elseif x == "AVX2" and _ACTION > "vs2012" then + v = "AdvancedVectorExtensions2" + elseif cfg.architecture ~= "x86_64" then + if x == "SSE2" or x == "SSE3" or x == "SSSE3" or x == "SSE4.1" then + v = "StreamingSIMDExtensions2" + elseif x == "SSE" then + v = "StreamingSIMDExtensions" + elseif x == "IA32" and _ACTION > "vs2010" then + v = "NoExtensions" + end + end + if v then + m.element('EnableEnhancedInstructionSet', condition, v) + end + end + + + function m.entryPointSymbol(cfg) + if cfg.entrypoint then + m.element("EntryPointSymbol", nil, cfg.entrypoint) + end + end + + + function m.exceptionHandling(cfg, condition) + if cfg.exceptionhandling == p.OFF then + m.element("ExceptionHandling", condition, "false") + elseif cfg.exceptionhandling == "SEH" then + m.element("ExceptionHandling", condition, "Async") + end + end + + + function m.excludedFromBuild(filecfg, condition) + if not filecfg or filecfg.flags.ExcludeFromBuild then + m.element("ExcludedFromBuild", condition, "true") + end + end + + + function m.exceptionHandlingSEH(filecfg, condition) + if not filecfg or filecfg.exceptionhandling == "SEH" then + m.element("UseSafeExceptionHandlers", condition, "true") + end + end + + + function m.extensionsToDeleteOnClean(cfg) + if #cfg.cleanextensions > 0 then + local value = table.implode(cfg.cleanextensions, "*", ";", "") + m.element("ExtensionsToDeleteOnClean", nil, value .. "$(ExtensionsToDeleteOnClean)") + end + end + + + function m.fileType(cfg, file) + m.element("FileType", nil, "Document") + end + + + function m.floatingPointModel(cfg) + if cfg.floatingpoint and cfg.floatingpoint ~= "Default" then + m.element("FloatingPointModel", nil, cfg.floatingpoint) + end + end + + + function m.floatingPointExceptions(cfg) + if cfg.floatingpointexceptions ~= nil then + if cfg.floatingpointexceptions then + m.element("FloatingPointExceptions", nil, "true") + else + m.element("FloatingPointExceptions", nil, "false") + end + end + end + + + function m.inlineFunctionExpansion(cfg) + if cfg.inlining then + local types = { + Default = "Default", + Disabled = "Disabled", + Explicit = "OnlyExplicitInline", + Auto = "AnySuitable", + } + m.element("InlineFunctionExpansion", nil, types[cfg.inlining]) + end + end + + + function m.forceIncludes(cfg, condition) + if #cfg.forceincludes > 0 then + local includes = vstudio.path(cfg, cfg.forceincludes) + if #includes > 0 then + m.element("ForcedIncludeFiles", condition, table.concat(includes, ';')) + end + end + if #cfg.forceusings > 0 then + local usings = vstudio.path(cfg, cfg.forceusings) + if #usings > 0 then + m.element("ForcedUsingFiles", condition, table.concat(usings, ';')) + end + end + end + + + function m.fullProgramDatabaseFile(cfg) + if _ACTION >= "vs2015" and cfg.symbols == "FastLink" then + m.element("FullProgramDatabaseFile", nil, "true") + end + end + + + function m.functionLevelLinking(cfg) + if cfg.functionlevellinking ~= nil then + if cfg.functionlevellinking then + m.element("FunctionLevelLinking", nil, "true") + else + m.element("FunctionLevelLinking", nil, "false") + end + elseif config.isOptimizedBuild(cfg) then + m.element("FunctionLevelLinking", nil, "true") + end + end + + + function m.generateDebugInformation(cfg) + local lookup = {} + if _ACTION >= "vs2017" then + lookup[p.ON] = "true" + lookup[p.OFF] = "false" + lookup["FastLink"] = "DebugFastLink" + lookup["Full"] = "DebugFull" + elseif _ACTION == "vs2015" then + lookup[p.ON] = "true" + lookup[p.OFF] = "false" + lookup["FastLink"] = "DebugFastLink" + lookup["Full"] = "true" + else + lookup[p.ON] = "true" + lookup[p.OFF] = "false" + lookup["FastLink"] = "true" + lookup["Full"] = "true" + end + + local value = lookup[cfg.symbols] + if value then + m.element("GenerateDebugInformation", nil, value) + end + end + + + function m.generateManifest(cfg) + if cfg.flags.NoManifest then + m.element("GenerateManifest", nil, "false") + end + end + + + function m.generateMapFile(cfg) + if cfg.flags.Maps then + m.element("GenerateMapFile", nil, "true") + end + end + + + function m.ignoreDefaultLibraries(cfg) + if #cfg.ignoredefaultlibraries > 0 then + local ignored = cfg.ignoredefaultlibraries + for i = 1, #ignored do + -- Add extension if required + if not p.tools.msc.getLibraryExtensions()[ignored[i]:match("[^.]+$")] then + ignored[i] = path.appendextension(ignored[i], ".lib") + end + end + + m.element("IgnoreSpecificDefaultLibraries", condition, table.concat(ignored, ';')) + end + end + + + function m.ignoreWarnDuplicateFilename(prj) + -- VS 2013 warns on duplicate file names, even those files which are + -- contained in different, mututally exclusive configurations. See: + -- http://connect.microsoft.com/VisualStudio/feedback/details/797460/incorrect-warning-msb8027-reported-for-files-excluded-from-build + -- Premake already adds unique object names to conflicting file names, so + -- just go ahead and disable that warning. + if _ACTION > "vs2012" then + m.element("IgnoreWarnCompileDuplicatedFilename", nil, "true") + end + end + + + function m.ignoreImportLibrary(cfg) + if cfg.kind == p.SHAREDLIB and cfg.flags.NoImportLib then + m.element("IgnoreImportLibrary", nil, "true") + end + end + + + function m.imageXex(cfg) + if cfg.system == p.XBOX360 then + p.push('') + if cfg.configfile then + m.element("ConfigurationFile", nil, "%s", cfg.configfile) + else + p.w('') + p.w('') + end + p.w('') + p.w('') + p.pop('') + end + end + + + function m.imageXexOutput(cfg) + if cfg.system == p.XBOX360 then + m.element("ImageXexOutput", nil, "%s", "$(OutDir)$(TargetName).xex") + end + end + + + function m.importLanguageTargets(prj) + p.w('') + end + + m.elements.importExtensionTargets = function(prj) + return { + m.importGroupTargets, + m.importRuleTargets, + m.importNuGetTargets, + m.importBuildCustomizationsTargets + } + end + + function m.importExtensionTargets(prj) + p.push('') + p.callArray(m.elements.importExtensionTargets, prj) + p.pop('') + end + + function m.importGroupTargets(prj) + local groups = m.categorizeSources(prj) + for _, group in ipairs(groups) do + if group.category.emitExtensionTargets then + group.category.emitExtensionTargets(prj, group) + end + end + end + + function m.importRuleTargets(prj) + for i = 1, #prj.rules do + local rule = p.global.getRule(prj.rules[i]) + local loc = vstudio.path(prj, p.filename(rule, ".targets")) + p.x('', loc) + end + end + + local function nuGetTargetsFile(prj, package) + local packageAPIInfo = vstudio.nuget2010.packageAPIInfo(prj, package) + return p.vstudio.path(prj, p.filename(prj.solution, string.format("packages\\%s.%s\\build\\native\\%s.targets", vstudio.nuget2010.packageId(package), packageAPIInfo.verbatimVersion or packageAPIInfo.version, vstudio.nuget2010.packageId(package)))) + end + + function m.importNuGetTargets(prj) + for i = 1, #prj.nuget do + local targetsFile = nuGetTargetsFile(prj, prj.nuget[i]) + p.x('', targetsFile, targetsFile) + end + end + + function m.importBuildCustomizationsTargets(prj) + for i, build in ipairs(prj.buildcustomizations) do + p.w('', path.translate(build)) + end + end + + + + function m.ensureNuGetPackageBuildImports(prj) + if #prj.nuget > 0 then + p.push('') + p.push('') + p.x('This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.') + p.pop('') + + for i = 1, #prj.nuget do + local targetsFile = nuGetTargetsFile(prj, prj.nuget[i]) + p.x('', targetsFile, targetsFile) + end + p.pop('') + end + end + + + + function m.importDefaultProps(prj) + p.w('') + end + + + + function m.importLanguageSettings(prj) + p.w('') + end + + m.elements.importExtensionSettings = function(prj) + return { + m.importGroupSettings, + m.importRuleSettings, + m.importBuildCustomizationsProps + } + end + + function m.importExtensionSettings(prj) + p.push('') + p.callArray(m.elements.importExtensionSettings, prj) + p.pop('') + end + + + function m.importGroupSettings(prj) + local groups = m.categorizeSources(prj) + for _, group in ipairs(groups) do + if group.category.emitExtensionSettings then + group.category.emitExtensionSettings(prj, group) + end + end + end + + + function m.importRuleSettings(prj) + for i = 1, #prj.rules do + local rule = p.global.getRule(prj.rules[i]) + local loc = vstudio.path(prj, p.filename(rule, ".props")) + p.x('', loc) + end + end + + + function m.importBuildCustomizationsProps(prj) + for i, build in ipairs(prj.buildcustomizations) do + p.w('', path.translate(build)) + end + end + + + + function m.importLibrary(cfg) + if cfg.kind == p.SHAREDLIB then + m.element("ImportLibrary", nil, "%s", path.translate(cfg.linktarget.relpath)) + end + end + + + function m.includePath(cfg) + local dirs = vstudio.path(cfg, cfg.sysincludedirs) + if #dirs > 0 then + m.element("IncludePath", nil, "%s;$(IncludePath)", table.concat(dirs, ";")) + end + end + + + function m.intDir(cfg) + local objdir = vstudio.path(cfg, cfg.objdir) + m.element("IntDir", nil, "%s\\", objdir) + end + + + function m.intrinsicFunctions(cfg) + if cfg.intrinsics ~= nil then + if cfg.intrinsics then + m.element("IntrinsicFunctions", nil, "true") + else + m.element("IntrinsicFunctions", nil, "false") + end + elseif config.isOptimizedBuild(cfg) then + m.element("IntrinsicFunctions", nil, "true") + end + end + + + function m.keyword(prj) + -- try to determine what kind of targets we're building here + local isWin, isManaged, isMakefile + for cfg in project.eachconfig(prj) do + if cfg.system == p.WINDOWS then + isWin = true + end + if cfg.clr ~= p.OFF then + isManaged = true + end + if vstudio.isMakefile(cfg) then + isMakefile = true + end + end + + if isWin then + if isMakefile then + m.element("Keyword", nil, "MakeFileProj") + else + if isManaged or m.isClrMixed(prj) then + m.targetFramework(prj) + end + if isManaged then + m.element("Keyword", nil, "ManagedCProj") + else + m.element("Keyword", nil, "Win32Proj") + end + m.element("RootNamespace", nil, "%s", prj.name) + end + end + end + + + function m.libraryPath(cfg) + local dirs = vstudio.path(cfg, cfg.syslibdirs) + if #dirs > 0 then + m.element("LibraryPath", nil, "%s;$(LibraryPath)", table.concat(dirs, ";")) + end + end + + + + function m.linkIncremental(cfg) + if cfg.kind ~= p.STATICLIB then + m.element("LinkIncremental", nil, "%s", tostring(config.canLinkIncremental(cfg))) + end + end + + + function m.linkLibraryDependencies(cfg, explicit) + -- Left to its own devices, VS will happily link against a project dependency + -- that has been excluded from the build. As a workaround, disable dependency + -- linking and list all siblings explicitly + if explicit then + p.push('') + m.element("LinkLibraryDependencies", nil, "false") + p.pop('') + end + end + + + function m.minimalRebuild(cfg) + if config.isOptimizedBuild(cfg) or + cfg.flags.NoMinimalRebuild or + cfg.flags.MultiProcessorCompile or + cfg.debugformat == p.C7 + then + m.element("MinimalRebuild", nil, "false") + end + end + + + function m.moduleDefinitionFile(cfg) + local df = config.findfile(cfg, ".def") + if df then + m.element("ModuleDefinitionFile", nil, "%s", df) + end + end + + + function m.multiProcessorCompilation(cfg) + if cfg.flags.MultiProcessorCompile then + m.element("MultiProcessorCompilation", nil, "true") + end + end + + + function m.nmakeBuildCommands(cfg) + m.nmakeCommandLine(cfg, cfg.buildcommands, "Build") + end + + + function m.nmakeCleanCommands(cfg) + m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean") + end + + + function m.nmakeCommandLine(cfg, commands, phase) + if #commands > 0 then + commands = os.translateCommandsAndPaths(commands, cfg.project.basedir, cfg.project.location) + commands = table.concat(p.esc(commands), p.eol()) + p.w('%s', phase, commands, phase) + end + end + + + function m.nmakeIncludeDirs(cfg) + if cfg.kind ~= p.NONE and #cfg.includedirs > 0 then + local dirs = vstudio.path(cfg, cfg.includedirs) + if #dirs > 0 then + m.element("NMakeIncludeSearchPath", nil, "%s", table.concat(dirs, ";")) + end + end + end + + + function m.nmakeOutDirs(cfg) + if vstudio.isMakefile(cfg) then + m.outDir(cfg) + m.intDir(cfg) + end + end + + + function m.windowsSDKDesktopARMSupport(cfg) + if cfg.architecture == p.ARM then + p.w('true') + end + end + + + function m.nmakeOutput(cfg) + m.element("NMakeOutput", nil, "$(OutDir)%s", cfg.buildtarget.name) + end + + + function m.nmakePreprocessorDefinitions(cfg) + if cfg.kind ~= p.NONE and #cfg.defines > 0 then + local defines = table.concat(cfg.defines, ";") + defines = defines .. ";$(NMakePreprocessorDefinitions)" + m.element('NMakePreprocessorDefinitions', nil, defines) + end + end + + + function m.nmakeRebuildCommands(cfg) + m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild") + end + + + function m.objectFileName(fcfg) + if fcfg.objname ~= fcfg.basename then + m.element("ObjectFileName", m.condition(fcfg.config), "$(IntDir)\\%s.obj", fcfg.objname) + end + end + + + + function m.omitDefaultLib(cfg) + if cfg.flags.OmitDefaultLibrary then + m.element("OmitDefaultLibName", nil, "true") + end + end + + + + function m.omitFramePointers(cfg) + if cfg.flags.NoFramePointer then + m.element("OmitFramePointers", nil, "true") + end + end + + + function m.optimizeReferences(cfg) + if config.isOptimizedBuild(cfg) then + m.element("EnableCOMDATFolding", nil, "true") + m.element("OptimizeReferences", nil, "true") + end + end + + + function m.optimization(cfg, condition) + local map = { Off="Disabled", On="Full", Debug="Disabled", Full="Full", Size="MinSpace", Speed="MaxSpeed" } + local value = map[cfg.optimize] + if value or not condition then + m.element('Optimization', condition, value or "Disabled") + end + end + + + function m.outDir(cfg) + local outdir = vstudio.path(cfg, cfg.buildtarget.directory) + m.element("OutDir", nil, "%s\\", outdir) + end + + + function m.outputFile(cfg) + if cfg.system == p.XBOX360 then + m.element("OutputFile", nil, "$(OutDir)%s", cfg.buildtarget.name) + end + end + + + function m.executablePath(cfg) + local dirs = vstudio.path(cfg, cfg.bindirs) + if #dirs > 0 then + dirs = table.translate(dirs, function(dir) + if path.isabsolute(dir) then + return dir + end + return "$(ProjectDir)" .. dir + end) + m.element("ExecutablePath", nil, "%s;$(ExecutablePath)", table.concat(dirs, ";")) + end + end + + + function m.platformToolset(cfg) + local tool, version = p.config.toolset(cfg) + if not version then + local action = p.action.current() + version = action.vstudio.platformToolset + end + if version then + if cfg.kind == p.NONE or cfg.kind == p.MAKEFILE then + if p.config.hasFile(cfg, path.iscppfile) then + m.element("PlatformToolset", nil, version) + end + else + m.element("PlatformToolset", nil, version) + end + end + end + + + function m.precompiledHeader(cfg, condition) + prjcfg, filecfg = p.config.normalize(cfg) + if filecfg then + if prjcfg.pchsource == filecfg.abspath and not prjcfg.flags.NoPCH then + m.element('PrecompiledHeader', condition, 'Create') + elseif filecfg.flags.NoPCH then + m.element('PrecompiledHeader', condition, 'NotUsing') + end + else + if not prjcfg.flags.NoPCH and prjcfg.pchheader then + m.element("PrecompiledHeader", nil, "Use") + m.element("PrecompiledHeaderFile", nil, "%s", prjcfg.pchheader) + else + m.element("PrecompiledHeader", nil, "NotUsing") + end + end + end + + + function m.preprocessorDefinitions(cfg, defines, escapeQuotes, condition) + if #defines > 0 then + defines = table.concat(defines, ";") + if escapeQuotes then + defines = defines:gsub('"', '\\"') + end + defines = defines .. ";%%(PreprocessorDefinitions)" + m.element('PreprocessorDefinitions', condition, defines) + end + end + + + function m.undefinePreprocessorDefinitions(cfg, undefines, escapeQuotes, condition) + if #undefines > 0 then + undefines = table.concat(undefines, ";") + if escapeQuotes then + undefines = undefines:gsub('"', '\\"') + end + undefines = undefines .. ";%%(UndefinePreprocessorDefinitions)" + m.element('UndefinePreprocessorDefinitions', condition, undefines) + end + end + + + function m.programDatabaseFile(cfg) + if cfg.symbolspath and cfg.symbols == p.ON and cfg.debugformat ~= "c7" then + m.element("ProgramDatabaseFile", nil, p.project.getrelative(cfg.project, cfg.symbolspath)) + end + end + + + function m.projectGuid(prj) + m.element("ProjectGuid", nil, "{%s}", prj.uuid) + end + + + function m.projectName(prj) + if prj.name ~= prj.filename then + m.element("ProjectName", nil, "%s", prj.name) + end + end + + + function m.propertyGroup(cfg, label) + local cond + if cfg then + cond = string.format(' %s', m.condition(cfg)) + end + + if label then + label = string.format(' Label="%s"', label) + end + + p.push('', cond or "", label or "") + end + + + + function m.propertySheets(cfg) + p.push('', m.condition(cfg)) + p.w('') + p.pop('') + end + + + function m.propertySheetGroup(prj) + for cfg in project.eachconfig(prj) do + m.propertySheets(cfg) + end + end + + + function m.referenceCopyLocalSatelliteAssemblies(prj, ref) + m.element("CopyLocalSatelliteAssemblies", nil, "false") + end + + + function m.referenceLinkLibraryDependencies(prj, ref) + m.element("LinkLibraryDependencies", nil, "true") + end + + + function m.referenceOutputAssembly(prj, ref) + m.element("ReferenceOutputAssembly", nil, "true") + end + + + function m.referencePrivate(prj, ref) + m.element("Private", nil, "true") + end + + + function m.referenceProject(prj, ref) + m.element("Project", nil, "{%s}", ref.uuid) + end + + + function m.referenceUseLibraryDependences(prj, ref) + m.element("UseLibraryDependencyInputs", nil, "false") + end + + + function m.resourceAdditionalIncludeDirectories(cfg) + m.additionalIncludeDirectories(cfg, table.join(cfg.includedirs, cfg.resincludedirs)) + end + + + function m.resourcePreprocessorDefinitions(cfg) + local defines = table.join(cfg.defines, cfg.resdefines) + if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then + table.insert(defines, "_HAS_EXCEPTIONS=0") + end + m.preprocessorDefinitions(cfg, defines, true) + end + + + function m.runtimeLibrary(cfg) + local runtimes = { + StaticDebug = "MultiThreadedDebug", + StaticRelease = "MultiThreaded", + } + local runtime = runtimes[config.getruntime(cfg)] + if runtime then + m.element("RuntimeLibrary", nil, runtime) + end + end + + function m.callingConvention(cfg) + if cfg.callingconvention then + m.element("CallingConvention", nil, cfg.callingconvention) + end + end + + function m.runtimeTypeInfo(cfg, condition) + if cfg.rtti == p.OFF and ((not cfg.clr) or cfg.clr == p.OFF) then + m.element("RuntimeTypeInfo", condition, "false") + elseif cfg.rtti == p.ON then + m.element("RuntimeTypeInfo", condition, "true") + end + end + + function m.bufferSecurityCheck(cfg) + local tool, toolVersion = p.config.toolset(cfg) + if cfg.flags.NoBufferSecurityCheck or (toolVersion and toolVersion:startswith("LLVM-vs")) then + m.element("BufferSecurityCheck", nil, "false") + end + end + + function m.stringPooling(cfg) + if cfg.stringpooling ~= nil then + if cfg.stringpooling then + m.element("StringPooling", nil, "true") + else + m.element("StringPooling", nil, "false") + end + elseif config.isOptimizedBuild(cfg) then + m.element("StringPooling", nil, "true") + end + end + + + function m.subSystem(cfg) + if cfg.system ~= p.XBOX360 then + local subsystem = iif(cfg.kind == p.CONSOLEAPP, "Console", "Windows") + m.element("SubSystem", nil, subsystem) + end + end + + + function m.targetExt(cfg) + local ext = cfg.buildtarget.extension + if ext ~= "" then + m.element("TargetExt", nil, "%s", ext) + else + p.w('') + p.w('') + end + end + + + function m.targetMachine(cfg) + -- If a static library project contains a resource file, VS will choke with + -- "LINK : warning LNK4068: /MACHINE not specified; defaulting to X86" + local targetmachine = { + x86 = "MachineX86", + x86_64 = "MachineX64", + } + if cfg.kind == p.STATICLIB and config.hasFile(cfg, path.isresourcefile) then + local value = targetmachine[cfg.architecture] + if value ~= nil then + m.element("TargetMachine", nil, '%s', value) + end + end + end + + + function m.targetName(cfg) + m.element("TargetName", nil, "%s%s", cfg.buildtarget.prefix, cfg.buildtarget.basename) + end + + + function m.targetPlatformVersion(prj) + local min = project.systemversion(prj) + if min ~= nil and _ACTION >= "vs2015" then + m.element("WindowsTargetPlatformVersion", nil, min) + end + end + + + function m.treatLinkerWarningAsErrors(cfg) + if cfg.flags.FatalLinkWarnings then + local el = iif(cfg.kind == p.STATICLIB, "Lib", "Linker") + m.element("Treat" .. el .. "WarningAsErrors", nil, "true") + end + end + + + function m.treatWChar_tAsBuiltInType(cfg) + local map = { On = "true", Off = "false" } + local value = map[cfg.nativewchar] + if value then + m.element("TreatWChar_tAsBuiltInType", nil, value) + end + end + + + function m.treatWarningAsError(cfg) + if cfg.flags.FatalCompileWarnings and cfg.warnings ~= p.OFF then + m.element("TreatWarningAsError", nil, "true") + end + end + + + function m.disableSpecificWarnings(cfg, condition) + if #cfg.disablewarnings > 0 then + local warnings = table.concat(cfg.disablewarnings, ";") + warnings = warnings .. ";%%(DisableSpecificWarnings)" + m.element('DisableSpecificWarnings', condition, warnings) + end + end + + + function m.treatSpecificWarningsAsErrors(cfg, condition) + if #cfg.fatalwarnings > 0 then + local fatal = table.concat(cfg.fatalwarnings, ";") + fatal = fatal .. ";%%(TreatSpecificWarningsAsErrors)" + m.element('TreatSpecificWarningsAsErrors', condition, fatal) + end + end + + + function m.useDebugLibraries(cfg) + local runtime = config.getruntime(cfg) + m.element("UseDebugLibraries", nil, tostring(runtime:endswith("Debug"))) + end + + + function m.useOfMfc(cfg) + if cfg.flags.MFC then + m.element("UseOfMfc", nil, iif(cfg.flags.StaticRuntime, "Static", "Dynamic")) + end + end + + function m.useOfAtl(cfg) + if cfg.atl then + m.element("UseOfATL", nil, cfg.atl) + end + end + + + + function m.userMacros(cfg) + p.w('') + end + + + + function m.warningLevel(cfg) + local map = { Off = "TurnOffAllWarnings", Extra = "Level4" } + m.element("WarningLevel", nil, "%s", map[cfg.warnings] or "Level3") + end + + + + function m.xmlDeclaration() + p.xmlUtf8() + end + + + +--------------------------------------------------------------------------- +-- +-- Support functions +-- +--------------------------------------------------------------------------- + +-- +-- Format and return a Visual Studio Condition attribute. +-- + + function m.condition(cfg) + return string.format('Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"', p.esc(vstudio.projectConfig(cfg))) + end + + +-- +-- Output an individual project XML element, with an optional configuration +-- condition. +-- +-- @param depth +-- How much to indent the element. +-- @param name +-- The element name. +-- @param condition +-- An optional configuration condition, formatted with vc2010.condition(). +-- @param value +-- The element value, which may contain printf formatting tokens. +-- @param ... +-- Optional additional arguments to satisfy any tokens in the value. +-- + + function m.element(name, condition, value, ...) + if select('#',...) == 0 then + value = p.esc(value) + end + + local format + if condition then + format = string.format('<%s %s>%s', name, condition, value, name) + else + format = string.format('<%s>%s', name, value, name) + end + + p.x(format, ...) + end diff --git a/src/actions/vstudio/vs2010_vcxproj_filters.lua b/modules/vstudio/vs2010_vcxproj_filters.lua similarity index 100% rename from src/actions/vstudio/vs2010_vcxproj_filters.lua rename to modules/vstudio/vs2010_vcxproj_filters.lua diff --git a/src/actions/vstudio/vs2010_vcxproj_user.lua b/modules/vstudio/vs2010_vcxproj_user.lua old mode 100755 new mode 100644 similarity index 95% rename from src/actions/vstudio/vs2010_vcxproj_user.lua rename to modules/vstudio/vs2010_vcxproj_user.lua index 180a8ec5..86daebf6 --- a/src/actions/vstudio/vs2010_vcxproj_user.lua +++ b/modules/vstudio/vs2010_vcxproj_user.lua @@ -1,141 +1,141 @@ --- --- vs2010_vcxproj_user.lua --- Generate a Visual Studio 201x C/C++ project .user file --- Copyright (c) 2011-2015 Jason Perkins and the Premake project --- - - local p = premake - local m = p.vstudio.vc2010 - - --- --- Generate a Visual Studio 201x C++ user file. --- - - m.elements.user = function(cfg) - return { - m.debugSettings, - } - end - - function m.generateUser(prj) - -- Only want output if there is something to configure - local contents = {} - local size = 0 - - for cfg in p.project.eachconfig(prj) do - contents[cfg] = p.capture(function() - p.push(2) - p.callArray(m.elements.user, cfg) - p.pop(2) - end) - size = size + #contents[cfg] - end - - if size > 0 then - m.xmlDeclaration() - m.userProject() - for cfg in p.project.eachconfig(prj) do - p.push('', m.condition(cfg)) - if #contents[cfg] > 0 then - p.outln(contents[cfg]) - end - p.pop('') - end - p.pop('') - end - end - - - --- --- Output the opening tag. --- - - function m.userProject() - local action = p.action.current() - p.push('', - action.vstudio.toolsVersion) - end - - - - m.elements.debugSettings = function(cfg) - return { - m.localDebuggerCommand, - m.localDebuggerWorkingDirectory, - m.debuggerFlavor, - m.localDebuggerCommandArguments, - m.localDebuggerDebuggerType, - m.localDebuggerEnvironment, - m.localDebuggerMergeEnvironment, - } - end - - function m.debugSettings(cfg) - p.callArray(m.elements.debugSettings, cfg) - end - - - - function m.debuggerFlavor(cfg) - if cfg.debugdir or cfg.debugcommand then - p.w('WindowsLocalDebugger') - end - end - - - - function m.localDebuggerCommand(cfg) - if cfg.debugcommand then - local dir = path.translate(cfg.debugcommand) - p.w('%s', dir) - end - end - - - function m.localDebuggerDebuggerType(cfg) - if cfg.debuggertype then - p.w('%s', cfg.debuggertype) - end - end - - - function m.localDebuggerCommandArguments(cfg) - if #cfg.debugargs > 0 then - p.x('%s', table.concat(cfg.debugargs, " ")) - end - end - - - - function m.localDebuggerWorkingDirectory(cfg) - if cfg.debugdir then - local dir = p.vstudio.path(cfg, cfg.debugdir) - p.x('%s', dir) - end - end - - - - function m.localDebuggerEnvironment(cfg) - if #cfg.debugenvs > 0 then - local envs = table.concat(cfg.debugenvs, "\n") - if cfg.flags.DebugEnvsInherit then - envs = envs .. "\n$(LocalDebuggerEnvironment)" - end - p.w('%s', envs) - - if cfg.flags.DebugEnvsDontMerge then - p.w(2,'false') - end - end - end - - - - function m.localDebuggerMergeEnvironment(cfg) - if #cfg.debugenvs > 0 and cfg.flags.DebugEnvsDontMerge then - p.w(2,'false') - end - end +-- +-- vs2010_vcxproj_user.lua +-- Generate a Visual Studio 201x C/C++ project .user file +-- Copyright (c) 2011-2015 Jason Perkins and the Premake project +-- + + local p = premake + local m = p.vstudio.vc2010 + + +-- +-- Generate a Visual Studio 201x C++ user file. +-- + + m.elements.user = function(cfg) + return { + m.debugSettings, + } + end + + function m.generateUser(prj) + -- Only want output if there is something to configure + local contents = {} + local size = 0 + + for cfg in p.project.eachconfig(prj) do + contents[cfg] = p.capture(function() + p.push(2) + p.callArray(m.elements.user, cfg) + p.pop(2) + end) + size = size + #contents[cfg] + end + + if size > 0 then + m.xmlDeclaration() + m.userProject() + for cfg in p.project.eachconfig(prj) do + p.push('', m.condition(cfg)) + if #contents[cfg] > 0 then + p.outln(contents[cfg]) + end + p.pop('') + end + p.pop('') + end + end + + + +-- +-- Output the opening tag. +-- + + function m.userProject() + local action = p.action.current() + p.push('', + action.vstudio.toolsVersion) + end + + + + m.elements.debugSettings = function(cfg) + return { + m.localDebuggerCommand, + m.localDebuggerWorkingDirectory, + m.debuggerFlavor, + m.localDebuggerCommandArguments, + m.localDebuggerDebuggerType, + m.localDebuggerEnvironment, + m.localDebuggerMergeEnvironment, + } + end + + function m.debugSettings(cfg) + p.callArray(m.elements.debugSettings, cfg) + end + + + + function m.debuggerFlavor(cfg) + if cfg.debugdir or cfg.debugcommand then + p.w('WindowsLocalDebugger') + end + end + + + + function m.localDebuggerCommand(cfg) + if cfg.debugcommand then + local dir = path.translate(cfg.debugcommand) + p.w('%s', dir) + end + end + + + function m.localDebuggerDebuggerType(cfg) + if cfg.debuggertype then + p.w('%s', cfg.debuggertype) + end + end + + + function m.localDebuggerCommandArguments(cfg) + if #cfg.debugargs > 0 then + p.x('%s', table.concat(cfg.debugargs, " ")) + end + end + + + + function m.localDebuggerWorkingDirectory(cfg) + if cfg.debugdir then + local dir = p.vstudio.path(cfg, cfg.debugdir) + p.x('%s', dir) + end + end + + + + function m.localDebuggerEnvironment(cfg) + if #cfg.debugenvs > 0 then + local envs = table.concat(cfg.debugenvs, "\n") + if cfg.flags.DebugEnvsInherit then + envs = envs .. "\n$(LocalDebuggerEnvironment)" + end + p.w('%s', envs) + + if cfg.flags.DebugEnvsDontMerge then + p.w(2,'false') + end + end + end + + + + function m.localDebuggerMergeEnvironment(cfg) + if #cfg.debugenvs > 0 and cfg.flags.DebugEnvsDontMerge then + p.w(2,'false') + end + end diff --git a/src/actions/vstudio/vs2012.lua b/modules/vstudio/vs2012.lua similarity index 93% rename from src/actions/vstudio/vs2012.lua rename to modules/vstudio/vs2012.lua index c38075db..5cadc8d2 100644 --- a/src/actions/vstudio/vs2012.lua +++ b/modules/vstudio/vs2012.lua @@ -6,9 +6,6 @@ local p = premake local vstudio = p.vstudio - local cs2005 = vstudio.cs2005 - local vc2010 = vstudio.vc2010 - --- -- Define the Visual Studio 2010 export action. @@ -56,7 +53,7 @@ vstudio.cleanTarget(prj) end, - pathVars = vstudio.pathVars, + pathVars = vstudio.vs2010.pathVars, -- This stuff is specific to the Visual Studio exporters @@ -68,4 +65,3 @@ platformToolset = "v110" } } - diff --git a/src/actions/vstudio/vs2013.lua b/modules/vstudio/vs2013.lua similarity index 92% rename from src/actions/vstudio/vs2013.lua rename to modules/vstudio/vs2013.lua index 60d7adf9..c00040ce 100644 --- a/src/actions/vstudio/vs2013.lua +++ b/modules/vstudio/vs2013.lua @@ -5,13 +5,7 @@ -- local p = premake - p.vstudio.vc2013 = {} - local vstudio = p.vstudio - local vc2010 = vstudio.vc2010 - - local m = vstudio.vc2013 - --- -- Define the Visual Studio 2013 export action. @@ -59,7 +53,7 @@ vstudio.cleanTarget(prj) end, - pathVars = vstudio.pathVars, + pathVars = vstudio.vs2010.pathVars, -- This stuff is specific to the Visual Studio exporters diff --git a/src/actions/vstudio/vs2015.lua b/modules/vstudio/vs2015.lua similarity index 92% rename from src/actions/vstudio/vs2015.lua rename to modules/vstudio/vs2015.lua index 1d1d4b6f..848c0f15 100644 --- a/src/actions/vstudio/vs2015.lua +++ b/modules/vstudio/vs2015.lua @@ -5,13 +5,7 @@ -- local p = premake - p.vstudio.vc2015 = {} - local vstudio = p.vstudio - local vc2010 = vstudio.vc2010 - - local m = vstudio.vc2015 - --- -- Define the Visual Studio 2015 export action. @@ -59,7 +53,7 @@ vstudio.cleanTarget(prj) end, - pathVars = vstudio.pathVars, + pathVars = vstudio.vs2010.pathVars, -- This stuff is specific to the Visual Studio exporters diff --git a/src/actions/vstudio/vs2017.lua b/modules/vstudio/vs2017.lua similarity index 80% rename from src/actions/vstudio/vs2017.lua rename to modules/vstudio/vs2017.lua index 260396a9..0c812f98 100644 --- a/src/actions/vstudio/vs2017.lua +++ b/modules/vstudio/vs2017.lua @@ -5,13 +5,7 @@ -- local p = premake - p.vstudio.vc2017 = {} - local vstudio = p.vstudio - local vc2010 = vstudio.vc2010 - - local m = vstudio.vc2017 - --- -- Define the Visual Studio 2017 export action. @@ -40,26 +34,26 @@ -- Workspace and project generation logic onWorkspace = function(wks) - vstudio.vs2005.generateSolution(wks) + p.vstudio.vs2005.generateSolution(wks) end, onProject = function(prj) - vstudio.vs2010.generateProject(prj) + p.vstudio.vs2010.generateProject(prj) end, onRule = function(rule) - vstudio.vs2010.generateRule(rule) + p.vstudio.vs2010.generateRule(rule) end, onCleanWorkspace = function(wks) - vstudio.cleanSolution(wks) + p.vstudio.cleanSolution(wks) end, onCleanProject = function(prj) - vstudio.cleanProject(prj) + p.vstudio.cleanProject(prj) end, onCleanTarget = function(prj) - vstudio.cleanTarget(prj) + p.vstudio.cleanTarget(prj) end, - pathVars = vstudio.pathVars, + pathVars = vstudio.vs2010.pathVars, -- This stuff is specific to the Visual Studio exporters diff --git a/src/actions/vstudio/_vstudio.lua b/modules/vstudio/vstudio.lua similarity index 95% rename from src/actions/vstudio/_vstudio.lua rename to modules/vstudio/vstudio.lua index 7375a218..39a468c3 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/modules/vstudio/vstudio.lua @@ -1,17 +1,21 @@ -- --- _vstudio.lua +-- vstudio.lua -- Define the Visual Studio 200x actions. --- Copyright (c) 2008-2013 Jason Perkins and the Premake project +-- Copyright (c) 2002-2017 Jason Perkins and the Premake project -- local p = premake - p.vstudio = {} - local vstudio = p.vstudio + p.modules.vstudio = p.modules.vstudio or {} + p.modules.vstudio._VERSION = p._VERSION + + -- for backwards compatibility. + p.vstudio = p.modules.vstudio + + local vstudio = p.vstudio local project = p.project local config = p.config - -- -- Mapping tables from Premake systems and architectures to Visual Studio -- identifiers. Broken out as tables so new values can be pushed in by @@ -616,3 +620,22 @@ end + +-- +-- Load all required code, and return the module. +-- + + include("vs200x_vcproj.lua") + include("vs200x_vcproj_user.lua") + include("vs2005_solution.lua") + include("vs2005_csproj.lua") + include("vs2005_csproj_user.lua") + include("vs2010_nuget.lua") + include("vs2010_vcxproj.lua") + include("vs2010_vcxproj_user.lua") + include("vs2010_vcxproj_filters.lua") + include("vs2010_rules_props.lua") + include("vs2010_rules_targets.lua") + include("vs2010_rules_xml.lua") + + return p.modules.vstudio diff --git a/src/_manifest.lua b/src/_manifest.lua index 159d19c2..8a355a5f 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -64,28 +64,6 @@ "tools/snc.lua", "tools/clang.lua", - -- Visual Studio actions - "actions/vstudio/_vstudio.lua", - "actions/vstudio/vs2005.lua", - "actions/vstudio/vs2008.lua", - "actions/vstudio/vs200x_vcproj.lua", - "actions/vstudio/vs200x_vcproj_user.lua", - "actions/vstudio/vs2005_solution.lua", - "actions/vstudio/vs2005_csproj.lua", - "actions/vstudio/vs2005_csproj_user.lua", - "actions/vstudio/vs2010.lua", - "actions/vstudio/vs2010_nuget.lua", - "actions/vstudio/vs2010_vcxproj.lua", - "actions/vstudio/vs2010_vcxproj_user.lua", - "actions/vstudio/vs2010_vcxproj_filters.lua", - "actions/vstudio/vs2010_rules_props.lua", - "actions/vstudio/vs2010_rules_targets.lua", - "actions/vstudio/vs2010_rules_xml.lua", - "actions/vstudio/vs2012.lua", - "actions/vstudio/vs2013.lua", - "actions/vstudio/vs2015.lua", - "actions/vstudio/vs2017.lua", - -- Clean action "actions/clean/_clean.lua", diff --git a/src/_modules.lua b/src/_modules.lua index c6fd8958..f8f046dd 100644 --- a/src/_modules.lua +++ b/src/_modules.lua @@ -6,6 +6,7 @@ return { "gmake", + "vstudio", "xcode", "codelite", "gmake2", diff --git a/tests/_tests.lua b/tests/_tests.lua index 94160210..b0a8fe46 100644 --- a/tests/_tests.lua +++ b/tests/_tests.lua @@ -61,87 +61,4 @@ return { "tools/test_dotnet.lua", "tools/test_gcc.lua", "tools/test_msc.lua", - - -- Visual Studio 2005-2013 C# projects - "actions/vstudio/cs2005/test_assembly_refs.lua", - "actions/vstudio/cs2005/test_build_events.lua", - "actions/vstudio/cs2005/test_common_props.lua", - "actions/vstudio/cs2005/test_compiler_props.lua", - "actions/vstudio/cs2005/test_debug_props.lua", - "actions/vstudio/cs2005/test_files.lua", - "actions/vstudio/cs2005/test_icon.lua", - "actions/vstudio/cs2005/test_nuget_config.lua", - "actions/vstudio/cs2005/test_nuget_packages_config.lua", - "actions/vstudio/cs2005/test_output_props.lua", - "actions/vstudio/cs2005/projectelement.lua", - "actions/vstudio/cs2005/test_platform_groups.lua", - "actions/vstudio/cs2005/test_project_refs.lua", - "actions/vstudio/cs2005/projectsettings.lua", - "actions/vstudio/cs2005/test_targets.lua", - "actions/vstudio/cs2005/test_user_file.lua", - - -- Visual Studio 2005-2013 solutions - "actions/vstudio/sln2005/test_dependencies.lua", - "actions/vstudio/sln2005/test_header.lua", - "actions/vstudio/sln2005/test_nested_projects.lua", - "actions/vstudio/sln2005/test_projects.lua", - "actions/vstudio/sln2005/test_platforms.lua", - "actions/vstudio/sln2005/test_sections.lua", - - -- Visual Studio 2002-2008 C/C++ projects - "actions/vstudio/vc200x/test_assembly_refs.lua", - "actions/vstudio/vc200x/test_build_steps.lua", - "actions/vstudio/vc200x/test_configuration.lua", - "actions/vstudio/vc200x/test_compiler_block.lua", - "actions/vstudio/vc200x/test_debug_settings.lua", - "actions/vstudio/vc200x/test_excluded_configs.lua", - "actions/vstudio/vc200x/test_files.lua", - "actions/vstudio/vc200x/test_linker_block.lua", - "actions/vstudio/vc200x/test_manifest_block.lua", - "actions/vstudio/vc200x/test_nmake_settings.lua", - "actions/vstudio/vc200x/test_platforms.lua", - "actions/vstudio/vc200x/test_project.lua", - "actions/vstudio/vc200x/test_project_refs.lua", - "actions/vstudio/vc200x/test_resource_compiler.lua", - "actions/vstudio/vc200x/test_user_file.lua", - - -- Visual Studio 2010-2013 C/C++ projects - "actions/vstudio/vc2010/test_assembly_refs.lua", - "actions/vstudio/vc2010/test_build_events.lua", - "actions/vstudio/vc2010/test_build_log.lua", - "actions/vstudio/vc2010/test_character_set.lua", - "actions/vstudio/vc2010/test_compile_settings.lua", - "actions/vstudio/vc2010/test_config_props.lua", - "actions/vstudio/vc2010/test_debug_settings.lua", - "actions/vstudio/vc2010/test_excluded_configs.lua", - "actions/vstudio/vc2010/test_extension_settings.lua", - "actions/vstudio/vc2010/test_extension_targets.lua", - "actions/vstudio/vc2010/test_language_settings.lua", - "actions/vstudio/vc2010/test_language_targets.lua", - "actions/vstudio/vc2010/test_floatingpoint.lua", - "actions/vstudio/vc2010/test_globals.lua", - "actions/vstudio/vc2010/test_header.lua", - "actions/vstudio/vc2010/test_files.lua", - "actions/vstudio/vc2010/test_filter_ids.lua", - "actions/vstudio/vc2010/test_filters.lua", - "actions/vstudio/vc2010/test_imagexex_settings.lua", - "actions/vstudio/vc2010/test_item_def_group.lua", - "actions/vstudio/vc2010/test_link.lua", - "actions/vstudio/vc2010/test_manifest.lua", - "actions/vstudio/vc2010/test_nmake_props.lua", - "actions/vstudio/vc2010/test_nuget_packages_config.lua", - "actions/vstudio/vc2010/test_output_props.lua", - "actions/vstudio/vc2010/test_platform_toolset.lua", - "actions/vstudio/vc2010/test_project_configs.lua", - "actions/vstudio/vc2010/test_project_refs.lua", - "actions/vstudio/vc2010/test_prop_sheet.lua", - "actions/vstudio/vc2010/test_resource_compile.lua", - "actions/vstudio/vc2010/test_rule_props.lua", - "actions/vstudio/vc2010/test_rule_targets.lua", - "actions/vstudio/vc2010/test_rule_vars.lua", - "actions/vstudio/vc2010/test_rule_xml.lua", - "actions/vstudio/vc2010/test_target_machine.lua", - "actions/vstudio/vc2010/test_user_file.lua", - "actions/vstudio/vc2010/test_vectorextensions.lua", - "actions/vstudio/vc2010/test_ensure_nuget_imports.lua", } diff --git a/tests/base/test_os.lua b/tests/base/test_os.lua index 70cf21d1..0565a873 100644 --- a/tests/base/test_os.lua +++ b/tests/base/test_os.lua @@ -35,13 +35,13 @@ function suite.findlib_FailsOnBadLibName() test.isfalse(os.findlib("NoSuchLibraryAsThisOneHere")) end - + function suite.findheader_stdheaders() if not (os.istarget("windows")) then test.istrue(os.findheader("stdlib.h")) end end - + function suite.findheader_failure() test.isfalse(os.findheader("Knights/who/say/Ni.hpp")) end @@ -93,8 +93,8 @@ end function suite.matchfiles_OnSubfolderMatch() - local result = os.matchfiles("**/vc2010/*") - test.istrue(table.contains(result, "actions/vstudio/vc2010/test_globals.lua")) + local result = os.matchfiles("**/subfolder/*") + test.istrue(table.contains(result, "folder/subfolder/hello.txt")) test.isfalse(table.contains(result, "premake4.lua")) end