diff options
-rw-r--r-- | CHANGES.txt | 1 | ||||
-rw-r--r-- | src/_manifest.lua | 1 | ||||
-rw-r--r-- | src/actions/make/make_cpp.lua | 24 | ||||
-rw-r--r-- | src/actions/vstudio/vs2010_vcxproj.lua | 6 | ||||
-rw-r--r-- | src/actions/vstudio/vs2013.lua | 53 | ||||
-rw-r--r-- | src/actions/xcode/xcode_common.lua | 62 | ||||
-rw-r--r-- | src/base/table.lua | 2 | ||||
-rw-r--r-- | tests/actions/make/test_make_pch.lua | 17 | ||||
-rwxr-xr-x | tests/actions/vstudio/cs2005/projectelement.lua | 9 | ||||
-rwxr-xr-x | tests/actions/vstudio/sln2005/header.lua | 10 | ||||
-rw-r--r-- | tests/actions/vstudio/vc2010/test_config_props.lua | 13 | ||||
-rw-r--r-- | tests/base/test_table.lua | 8 | ||||
-rw-r--r-- | tests/test_gmake_cpp.lua | 6 |
13 files changed, 187 insertions, 25 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 77e3bc1..2bb1fd1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -75,6 +75,7 @@ * Bug 171: ImpLib used incorrectly in dependency paths * Bug 176: Target prefix breaks GCC linking * Improved handling of precompiled headers across toolsets +* Initial support for Visual Studio 2013 (Igor Karatayev) ------- diff --git a/src/_manifest.lua b/src/_manifest.lua index a9ed645..ee07f81 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -64,6 +64,7 @@ "actions/vstudio/vs2010_vcxproj.lua", "actions/vstudio/vs2010_vcxproj_filters.lua", "actions/vstudio/vs2012.lua", + "actions/vstudio/vs2013.lua", -- Xcode action "actions/xcode/_xcode.lua", diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua index 0efd321..b3630f2 100644 --- a/src/actions/make/make_cpp.lua +++ b/src/actions/make/make_cpp.lua @@ -267,11 +267,15 @@ _p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)') end else + -- this was $(TARGET) $(LDFLAGS) $(OBJECTS) - -- but had trouble linking to certain static libs so $(OBJECTS) moved up - -- then $(LDFLAGS) moved to end - -- https://sourceforge.net/tracker/?func=detail&aid=3430158&group_id=71616&atid=531880 - _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS)', iif(cfg.language == "C", "CC", "CXX")) + -- but had trouble linking to certain static libs; $(OBJECTS) moved up + -- $(LDFLAGS) moved to end (http://sourceforge.net/p/premake/patches/107/) + -- $(LIBS) moved to end (http://sourceforge.net/p/premake/bugs/279/) + + local tool = iif(cfg.language == "C", "CC", "CXX") + _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)', tool) + end end @@ -301,15 +305,19 @@ local pch = cfg.pchheader for _, incdir in ipairs(cfg.includedirs) do - local testname = path.join(incdir, pch) + + -- convert this back to an absolute path for os.isfile() + local abspath = path.getabsolute(path.join(cfg.project.location, incdir)) + + local testname = path.join(abspath, pch) if os.isfile(testname) then - pch = testname + pch = path.getrelative(cfg.location, testname) break end end - _p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader))) - _p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch', _MAKE.esc(path.getname(cfg.pchheader))) + _p(' PCH = %s', _MAKE.esc(pch)) + _p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch') end diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 2c9a14a..b6b44e7 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -79,8 +79,10 @@ _p(2,'<UseDebugLibraries>%s</UseDebugLibraries>', iif(optimisation(cfg) == "Disabled","true","false")) _p(2,'<CharacterSet>%s</CharacterSet>',iif(cfg.flags.Unicode,"Unicode","MultiByte")) - if _ACTION > "vs2010" then - _p(2,'<PlatformToolset>%s</PlatformToolset>', "v110") + local toolsets = { vs2012 = "v110", vs2013 = "v120" } + local toolset = toolsets[_ACTION] + if toolset then + _p(2,'<PlatformToolset>%s</PlatformToolset>', toolset) end if cfg.flags.MFC then diff --git a/src/actions/vstudio/vs2013.lua b/src/actions/vstudio/vs2013.lua new file mode 100644 index 0000000..8654f21 --- /dev/null +++ b/src/actions/vstudio/vs2013.lua @@ -0,0 +1,53 @@ +-- +-- vs2013.lua +-- Baseline support for Visual Studio 2013. +-- Copyright (c) 2013 Jason Perkins and the Premake project +-- + + +--- +-- Register a command-line action for Visual Studio 2012. +--- + + newaction + { + trigger = "vs2013", + shortname = "Visual Studio 2013", + description = "Generate Microsoft Visual Studio 2013 project files", + os = "windows", + + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, + + valid_languages = { "C", "C++", "C#"}, + + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, + + onsolution = function(sln) + premake.generate(sln, "%%.sln", vstudio.sln2005.generate) + end, + + onproject = function(prj) + if premake.isdotnetproject(prj) then + premake.generate(prj, "%%.csproj", vstudio.cs2005.generate) + premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user) + else + premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) + premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) + premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters) + end + end, + + + oncleansolution = premake.vstudio.cleansolution, + oncleanproject = premake.vstudio.cleanproject, + oncleantarget = premake.vstudio.cleantarget, + + vstudio = { + solutionVersion = "12", + targetFramework = "4.5", + toolsVersion = "12.0", + } + } diff --git a/src/actions/xcode/xcode_common.lua b/src/actions/xcode/xcode_common.lua index b9f67de..4d413d4 100644 --- a/src/actions/xcode/xcode_common.lua +++ b/src/actions/xcode/xcode_common.lua @@ -32,6 +32,8 @@ [".nib"] = "Resources", [".xib"] = "Resources", [".icns"] = "Resources", + [".bmp"] = "Resources", + [".wav"] = "Resources", } return categories[path.getextension(node.name)] end @@ -85,6 +87,8 @@ [".strings"] = "text.plist.strings", [".xib"] = "file.xib", [".icns"] = "image.icns", + [".bmp"] = "image.bmp", + [".wav"] = "audio.wav", } return types[path.getextension(node.path)] or "text" end @@ -224,7 +228,8 @@ if #list > 0 then _p(4,'%s = (', tag) for _, item in ipairs(list) do - _p(5, '"%s",', item) + local escaped_item = item:gsub("\"", "\\\"") + _p(5, '"%s",', escaped_item) end _p(4,');') end @@ -314,18 +319,36 @@ local pth, src if xcode.isframework(node.path) then --respect user supplied paths - if string.find(node.path,'/') then - if string.find(node.path,'^%.')then + -- look for special variable-starting paths for different sources + local nodePath = node.path + local _, matchEnd, variable = string.find(nodePath, "^%$%((.+)%)/") + if variable then + -- by skipping the last '/' we support the same absolute/relative + -- paths as before + nodePath = string.sub(nodePath, matchEnd + 1) + end + if string.find(nodePath,'/') then + if string.find(nodePath,'^%.')then error('relative paths are not currently supported for frameworks') end - pth = node.path + pth = nodePath else - pth = "/System/Library/Frameworks/" .. node.path + pth = "/System/Library/Frameworks/" .. nodePath + end + -- if it starts with a variable, use that as the src instead + if variable then + src = variable + -- if we are using a different source tree, it has to be relative + -- to that source tree, so get rid of any leading '/' + if string.find(pth, '^/') then + pth = string.sub(pth, 2) + end + else + src = "<absolute>" end - src = "absolute" else -- something else; probably a source code file - src = "group" + src = "<group>" -- if the parent node is virtual, it won't have a local path -- of its own; need to use full relative path from project @@ -336,7 +359,7 @@ end end - _p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "<%s>"; };', + _p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "%s"; };', node.id, node.name, xcode.getfiletype(node), node.name, pth, src) end end @@ -428,20 +451,37 @@ for _, node in ipairs(tr.products.children) do local name = tr.project.name + -- This function checks whether there are build commands of a specific + -- type to be executed; they will be generated correctly, but the project + -- commands will not contain any per-configuration commands, so the logic + -- has to be extended a bit to account for that. + local function hasBuildCommands(which) + -- standard check...this is what existed before + if #tr.project[which] > 0 then + return true + end + -- what if there are no project-level commands? check configs... + for _, cfg in ipairs(tr.configs) do + if #cfg[which] > 0 then + return true + end + end + end + _p(2,'%s /* %s */ = {', node.targetid, name) _p(3,'isa = PBXNativeTarget;') _p(3,'buildConfigurationList = %s /* Build configuration list for PBXNativeTarget "%s" */;', node.cfgsection, name) _p(3,'buildPhases = (') - if #tr.project.prebuildcommands > 0 then + if hasBuildCommands('prebuildcommands') then _p(4,'9607AE1010C857E500CD1376 /* Prebuild */,') end _p(4,'%s /* Resources */,', node.resstageid) _p(4,'%s /* Sources */,', node.sourcesid) - if #tr.project.prelinkcommands > 0 then + if hasBuildCommands('prelinkcommands') then _p(4,'9607AE3510C85E7E00CD1376 /* Prelink */,') end _p(4,'%s /* Frameworks */,', node.fxstageid) - if #tr.project.postbuildcommands > 0 then + if hasBuildCommands('postbuildcommands') then _p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,') end _p(3,');') diff --git a/src/base/table.lua b/src/base/table.lua index ff874aa..3076cb0 100644 --- a/src/base/table.lua +++ b/src/base/table.lua @@ -99,7 +99,7 @@ -- function table.isempty(t) - return not next(t) + return next(t) == nil end diff --git a/tests/actions/make/test_make_pch.lua b/tests/actions/make/test_make_pch.lua index 75d9d9d..4664661 100644 --- a/tests/actions/make/test_make_pch.lua +++ b/tests/actions/make/test_make_pch.lua @@ -85,6 +85,7 @@ $(GCH): $(PCH) ]] end + -- -- Ensure that PCH is included on all files that use it. -- @@ -101,3 +102,19 @@ $(OBJDIR)/main.o: main.cpp ]] end + +-- +-- If the header is located on one of the include file +-- search directories, it should get found automatically. +-- + + function suite.findsPCH_onIncludeDirs() + location "MyProject" + pchheader "premake.h" + includedirs { "../src/host" } + prepare() + _.pchconfig(cfg) + test.capture [[ + PCH = ../../src/host/premake.h + ]] + end diff --git a/tests/actions/vstudio/cs2005/projectelement.lua b/tests/actions/vstudio/cs2005/projectelement.lua index 1d2a61f..5825abc 100755 --- a/tests/actions/vstudio/cs2005/projectelement.lua +++ b/tests/actions/vstudio/cs2005/projectelement.lua @@ -63,3 +63,12 @@ <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ]] end + + function suite.On2013() + _ACTION = "vs2013" + prepare() + test.capture [[ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + ]] + end diff --git a/tests/actions/vstudio/sln2005/header.lua b/tests/actions/vstudio/sln2005/header.lua index 5eb02e3..71e32f5 100755 --- a/tests/actions/vstudio/sln2005/header.lua +++ b/tests/actions/vstudio/sln2005/header.lua @@ -67,3 +67,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 ]] end + + + function suite.On2013() + _ACTION = "vs2013" + prepare() + test.capture [[ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 + ]] + end diff --git a/tests/actions/vstudio/vc2010/test_config_props.lua b/tests/actions/vstudio/vc2010/test_config_props.lua index 3aef357..50d78ae 100644 --- a/tests/actions/vstudio/vc2010/test_config_props.lua +++ b/tests/actions/vstudio/vc2010/test_config_props.lua @@ -63,3 +63,16 @@ </PropertyGroup> ]] end + + function suite.structureIsCorrect_onDefaultValues_on2013() + _ACTION = "vs2013" + prepare() + test.capture [[ + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v120</PlatformToolset> + </PropertyGroup> + ]] + end diff --git a/tests/base/test_table.lua b/tests/base/test_table.lua index 2bf26ed..0ac3442 100644 --- a/tests/base/test_table.lua +++ b/tests/base/test_table.lua @@ -55,3 +55,11 @@ function suite.isempty_ReturnsFalseOnNotEmpty() test.isfalse(table.isempty({ 1 })) end + + function suite.isempty_ReturnsFalseOnNotEmptyMap() + test.isfalse(table.isempty({ name = 'premake' })) + end + + function suite.isempty_ReturnsFalseOnNotEmptyMapWithFalseKey() + test.isfalse(table.isempty({ [false] = 0 })) + end diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua index 2844567..dde8033 100644 --- a/tests/test_gmake_cpp.lua +++ b/tests/test_gmake_cpp.lua @@ -85,7 +85,7 @@ ifeq ($(config),debug) ALL_LDFLAGS += $(LDFLAGS) -s LDDEPS += LIBS += $(LDDEPS) - LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS) + LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) define PREBUILDCMDS endef define PRELINKCMDS @@ -119,7 +119,7 @@ ifeq ($(config),debugps3) ALL_LDFLAGS += $(LDFLAGS) -s LDDEPS += LIBS += $(LDDEPS) - LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS) + LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) define PREBUILDCMDS endef define PRELINKCMDS @@ -150,7 +150,7 @@ ifeq ($(config),debug64) ALL_LDFLAGS += $(LDFLAGS) -s -m64 -L/usr/lib64 LDDEPS += LIBS += $(LDDEPS) - LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS) + LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) define PREBUILDCMDS endef define PRELINKCMDS |