Initial support for VC 2008 Makefile projects

This commit is contained in:
Jason Perkins 2013-04-03 14:09:39 -04:00
parent 5e4993b1d3
commit fe1b37c9ae
6 changed files with 177 additions and 20 deletions

View File

@ -86,28 +86,43 @@
_p(1,'ProjectGUID="{%s}"', prj.uuid)
-- try to determine what kind of targets we're building here
local isWin, isPS3, isManaged
local isWin, isPS3, isManaged, isMakefile
for cfg in project.eachconfig(prj) do
if cfg.system == premake.WINDOWS then
isWin = true
elseif cfg.system == premake.PS3 then
end
if cfg.system == premake.PS3 then
isPS3 = true
end
if cfg.flags.Managed then
isManaged = true
end
if cfg.kind == premake.MAKEFILE then
isMakefile = true
end
end
if isWin then
if _ACTION > "vs2003" then
if _ACTION > "vs2003" and not isMakefile then
_x(1,'RootNamespace="%s"', prj.name)
end
_p(1,'Keyword="%s"', iif(isManaged, "ManagedCProj", "Win32Proj"))
_p(1,'TargetFrameworkVersion="0"')
elseif isPS3 then
_p(1,'TargetFrameworkVersion="196613"')
local keyword = "Win32Proj"
if isManaged then
keyword = "ManagedCProj"
end
if isMakefile then
keyword = "MakeFileProj"
end
_p(1,'Keyword="%s"', keyword)
end
local version = 0
if isMakefile or not isWin then
version = 196613
end
_p(1,'TargetFrameworkVersion="%d"', version)
_p(1,'>')
end
@ -154,15 +169,7 @@
local objdir = project.getrelative(cfg.project, cfg.objdir)
_x(3,'IntermediateDirectory="%s"', path.translate(objdir))
local cfgtype
if (cfg.kind == "SharedLib") then
cfgtype = 2
elseif (cfg.kind == "StaticLib") then
cfgtype = 4
else
cfgtype = 1
end
_p(3,'ConfigurationType="%s"', cfgtype)
vc200x.configurationType(cfg)
if (cfg.flags.MFC) then
_p(3, 'UseOfMFC="%d"', iif(cfg.flags.StaticRuntime, 1, 2))
@ -206,6 +213,11 @@
--
function vc200x.toolsForConfig(cfg)
if cfg.kind == premake.MAKEFILE then
return {
"VCNMakeTool"
}
end
if _ACTION == "vs2002" then
return {
"VCCLCompilerTool",
@ -595,6 +607,23 @@
end
function vc200x.VCNMakeTool(cfg)
_p(3,'<Tool')
_p(4,'Name="VCNMakeTool"')
_p(4,'BuildCommandLine=""')
_p(4,'ReBuildCommandLine=""')
_p(4,'CleanCommandLine=""')
vc200x.nmakeOutput(cfg)
_p(4,'PreprocessorDefinitions=""')
_p(4,'IncludeSearchPath=""')
_p(4,'ForcedIncludes=""')
_p(4,'AssemblySearchPath=""')
_p(4,'ForcedUsingAssemblies=""')
_p(4,'CompileAsManaged=""')
_p(3,'/>')
end
function vc200x.VCResourceCompilerTool(cfg)
_p(3,'<Tool')
_p(4,'Name="VCResourceCompilerTool"')
@ -670,6 +699,7 @@
VCLinkerTool = vc200x.VCLinkerTool,
VCManifestTool = vc200x.VCManifestTool,
VCMIDLTool = vc200x.VCMIDLTool,
VCNMakeTool = vc200x.VCNMakeTool,
VCPostBuildEventTool = vc200x.VCPostBuildEventTool,
VCPreBuildEventTool = vc200x.VCPreBuildEventTool,
VCPreLinkEventTool = vc200x.VCPreLinkEventTool,
@ -879,7 +909,9 @@
function vc200x.characterSet(cfg)
_p(3,'CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2))
if cfg.kind ~= premake.MAKEFILE then
_p(3,'CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2))
end
end
@ -904,6 +936,16 @@
end
function vc200x.configurationType(cfg)
local cfgtypes = {
Makefile = 0,
SharedLib = 2,
StaticLib = 4,
}
_p(3,'ConfigurationType="%s"', cfgtypes[cfg.kind] or 1)
end
function vc200x.customBuildTool(filecfg, depth)
if filecfg.buildrule then
_x(depth, 'CommandLine="%s"', table.concat(filecfg.buildrule.commands,'\r\n'))
@ -943,6 +985,11 @@
end
function vc200x.nmakeOutput(cfg)
_p(4,'Output="$(OutDir)%s"', cfg.buildtarget.name)
end
function vc200x.objectFile(filecfg, depth)
if path.iscppfile(filecfg.name) then
local objectName = project.getfileobject(filecfg.project, filecfg.abspath)

View File

@ -11,16 +11,16 @@
--
-- Setup
-- Setup
--
local sln
function suite.setup()
_ACTION = "vs2008"
sln = test.createsolution()
end
local function prepare()
local prj = premake.solution.getproject_ng(sln, 1)
local cfg = project.getconfig(prj, "Debug", (prj.platforms or {})[1])
@ -89,3 +89,22 @@
OutputDirectory="..\bin"
]]
end
--
-- Makefiles set the configuration type and drop the
-- character encoding.
--
function suite.defaultSettings()
kind "Makefile"
prepare()
test.capture [[
<Configuration
Name="Debug|Win32"
OutputDirectory="."
IntermediateDirectory="obj\Debug"
ConfigurationType="0"
>
]]
end

View File

@ -0,0 +1,69 @@
--
-- tests/actions/vstudio/vc200x/test_nmake_settings.lua
-- Validate generation the VCNMakeTool element in Visual Studio 200x C/C++ projects.
-- Copyright (c) 2013 Jason Perkins and the Premake project
--
local suite = test.declare("vs200x_nmake_settings")
local vc200x = premake.vstudio.vc200x
--
-- Setup/teardown
--
local sln, prj, cfg
function suite.setup()
_ACTION = "vs2008"
sln = test.createsolution()
kind "Makefile"
end
local function prepare()
prj = premake.solution.getproject_ng(sln, 1)
cfg = premake5.project.getconfig(prj, "Debug")
vc200x.VCNMakeTool(cfg)
end
--
-- Verify the basic structure of the compiler block with no flags or settings.
--
function suite.onDefaultSettings()
prepare()
test.capture [[
<Tool
Name="VCNMakeTool"
BuildCommandLine=""
ReBuildCommandLine=""
CleanCommandLine=""
Output="$(OutDir)MyProject"
PreprocessorDefinitions=""
IncludeSearchPath=""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
]]
end
--
-- Make sure the target file extension is included.
--
function suite.usesTargetExtension()
targetextension ".exe"
prepare()
test.capture [[
<Tool
Name="VCNMakeTool"
BuildCommandLine=""
ReBuildCommandLine=""
CleanCommandLine=""
Output="$(OutDir)MyProject.exe"
]]
end

View File

@ -131,3 +131,23 @@
>
]]
end
--
-- Makefile projects set new keyword and drop the root namespace.
--
function suite.keywordIsCorrect_onMakefile()
kind "Makefile"
prepare()
test.capture [[
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="MyProject"
ProjectGUID="{AE61726D-187C-E440-BD07-2556188A6565}"
Keyword="MakeFileProj"
TargetFrameworkVersion="196613"
>
]]
end

View File

@ -16,6 +16,7 @@
local sln, prj, cfg
function suite.setup()
_ACTION = "vs2010"
sln = test.createsolution()
kind "Makefile"
end

View File

@ -123,6 +123,7 @@
dofile("actions/vstudio/vc200x/test_files.lua")
dofile("actions/vstudio/vc200x/test_linker_block.lua")
dofile("actions/vstudio/vc200x/test_manifest_block.lua")
dofile("actions/vstudio/vc200x/test_nmake_settings.lua")
dofile("actions/vstudio/vc200x/test_platforms.lua")
dofile("actions/vstudio/vc200x/test_project.lua")
dofile("actions/vstudio/vc200x/test_project_refs.lua")