Added build, rebuild, and clean commands for makefile projects

This commit is contained in:
Jason Perkins 2013-04-07 14:30:58 -04:00
parent fe1b37c9ae
commit b35e57d52b
5 changed files with 144 additions and 3 deletions

View File

@ -610,9 +610,9 @@
function vc200x.VCNMakeTool(cfg)
_p(3,'<Tool')
_p(4,'Name="VCNMakeTool"')
_p(4,'BuildCommandLine=""')
_p(4,'ReBuildCommandLine=""')
_p(4,'CleanCommandLine=""')
vc200x.nmakeCommandLine(cfg, cfg.buildcommands, "Build")
vc200x.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild")
vc200x.nmakeCommandLine(cfg, cfg.cleancommands, "Clean")
vc200x.nmakeOutput(cfg)
_p(4,'PreprocessorDefinitions=""')
_p(4,'IncludeSearchPath=""')
@ -985,6 +985,12 @@
end
function vc200x.nmakeCommandLine(cfg, commands, phase)
commands = table.concat(commands, "\r\n")
_p(4,'%sCommandLine="%s"', phase, premake.esc(commands))
end
function vc200x.nmakeOutput(cfg)
_p(4,'Output="$(OutDir)%s"', cfg.buildtarget.name)
end

View File

@ -216,6 +216,9 @@
if cfg.kind == premake.MAKEFILE then
vc2010.propertyGroup(cfg)
vc2010.nmakeOutput(cfg)
vc2010.nmakeCommandLine(cfg, cfg.buildcommands, "Build")
vc2010.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild")
vc2010.nmakeCommandLine(cfg, cfg.cleancommands, "Clean")
_p(1,'</PropertyGroup>')
end
end
@ -840,6 +843,14 @@
end
function vc2010.nmakeCommandLine(cfg, commands, phase)
if #commands > 0 then
commands = table.concat(premake.esc(commands), io.eol)
_p(2, '<NMake%sCommandLine>%s</NMake%sCommandLine>', phase, commands, phase)
end
end
function vc2010.nmakeOutput(cfg)
_p(2,'<NMakeOutput>$(OutDir)%s</NMakeOutput>', cfg.buildtarget.name)
end

View File

@ -513,6 +513,13 @@
},
}
api.register {
name = "buildcommands",
scope = "config",
kind = "string-list",
tokens = true,
}
api.register {
name = "buildoptions",
scope = "config",
@ -527,6 +534,13 @@
tokens = true,
}
api.register {
name = "cleancommands",
scope = "config",
kind = "string-list",
tokens = true,
}
api.register {
name = "configmap",
scope = "config",
@ -871,6 +885,13 @@
tokens = true,
}
api.register {
name = "rebuildcommands",
scope = "config",
kind = "string-list",
tokens = true,
}
api.register {
name = "resdefines",
scope = "config",

View File

@ -67,3 +67,56 @@
Output="$(OutDir)MyProject.exe"
]]
end
--
-- Verify generation of the build commands.
--
function suite.buildCommandLine_onSingleCommand()
buildcommands { "command 1" }
prepare()
test.capture [[
<Tool
Name="VCNMakeTool"
BuildCommandLine="command 1"
ReBuildCommandLine=""
CleanCommandLine=""
]]
end
function suite.buildCommandLine_onMultipleCommands()
buildcommands { "command 1", "command 2" }
prepare()
test.capture [[
<Tool
Name="VCNMakeTool"
BuildCommandLine="command 1&#x0D;&#x0A;command 2"
ReBuildCommandLine=""
CleanCommandLine=""
]]
end
function suite.rebuildCommandLine()
rebuildcommands { "command 1" }
prepare()
test.capture [[
<Tool
Name="VCNMakeTool"
BuildCommandLine=""
ReBuildCommandLine="command 1"
CleanCommandLine=""
]]
end
function suite.cleanCommandLine()
cleancommands { "command 1" }
prepare()
test.capture [[
<Tool
Name="VCNMakeTool"
BuildCommandLine=""
ReBuildCommandLine=""
CleanCommandLine="command 1"
]]
end

View File

@ -66,3 +66,53 @@
</PropertyGroup>
]]
end
--
-- Verify generation of the build commands.
--
function suite.buildCommandLine_onSingleCommand()
buildcommands { "command 1" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakeBuildCommandLine>command 1</NMakeBuildCommandLine>
</PropertyGroup>
]]
end
function suite.buildCommandLine_onMultipleCommands()
buildcommands { "command 1", "command 2" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakeBuildCommandLine>command 1
command 2</NMakeBuildCommandLine>
</PropertyGroup>
]]
end
function suite.rebuildCommandLine()
rebuildcommands { "command 1" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakeReBuildCommandLine>command 1</NMakeReBuildCommandLine>
</PropertyGroup>
]]
end
function suite.cleanCommandLine()
cleancommands { "command 1" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakeCleanCommandLine>command 1</NMakeCleanCommandLine>
</PropertyGroup>
]]
end