Add build steps to Visual Studio
This commit is contained in:
parent
789c0ac343
commit
4ca4a1d0a0
@ -55,6 +55,7 @@ return {
|
||||
"vc2010/test_assembly_refs.lua",
|
||||
"vc2010/test_build_events.lua",
|
||||
"vc2010/test_build_log.lua",
|
||||
"vc2010/test_build_steps.lua",
|
||||
"vc2010/test_character_set.lua",
|
||||
"vc2010/test_compile_settings.lua",
|
||||
"vc2010/test_config_props.lua",
|
||||
|
92
modules/vstudio/tests/vc2010/test_build_steps.lua
Normal file
92
modules/vstudio/tests/vc2010/test_build_steps.lua
Normal file
@ -0,0 +1,92 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_compile_settings.lua
|
||||
-- Validate compiler settings in Visual Studio 2010 C/C++ projects.
|
||||
-- Copyright (c) 2011-2020 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("vstudio_vs2010_build_steps")
|
||||
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.buildStep(cfg)
|
||||
end
|
||||
|
||||
--
|
||||
-- Check that we output nothing unless there is something to output
|
||||
--
|
||||
|
||||
function suite.buildStepNone()
|
||||
prepare()
|
||||
test.capture [[
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check the basic build step example
|
||||
--
|
||||
|
||||
function suite.buildStepBasic()
|
||||
buildcommands("Example.exe")
|
||||
prepare()
|
||||
test.capture [[
|
||||
<CustomBuildStep>
|
||||
<Command>Example.exe</Command>
|
||||
</CustomBuildStep>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check a normal build step setup
|
||||
--
|
||||
|
||||
function suite.buildStepCommon()
|
||||
buildcommands("Example.exe")
|
||||
buildoutputs("Example.out")
|
||||
buildinputs("Example.in")
|
||||
buildmessage("Hello World")
|
||||
prepare()
|
||||
test.capture [[
|
||||
<CustomBuildStep>
|
||||
<Command>Example.exe</Command>
|
||||
<Message>Hello World</Message>
|
||||
<Outputs>Example.out</Outputs>
|
||||
<Inputs>Example.in</Inputs>
|
||||
</CustomBuildStep>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check a more complex build step setup
|
||||
--
|
||||
|
||||
function suite.buildStepComplex()
|
||||
buildcommands ( "Example.exe" )
|
||||
buildoutputs { "Example.out", "Example2.out" }
|
||||
buildinputs { "Example.in", "Example2.in" }
|
||||
buildmessage("Hello World")
|
||||
prepare()
|
||||
test.capture [[
|
||||
<CustomBuildStep>
|
||||
<Command>Example.exe</Command>
|
||||
<Message>Hello World</Message>
|
||||
<Outputs>Example.out;Example2.out</Outputs>
|
||||
<Inputs>Example.in;Example2.in</Inputs>
|
||||
</CustomBuildStep>
|
||||
]]
|
||||
end
|
@ -307,6 +307,7 @@
|
||||
else
|
||||
return {
|
||||
m.clCompile,
|
||||
m.buildStep,
|
||||
m.fxCompile,
|
||||
m.resourceCompile,
|
||||
m.linker,
|
||||
@ -395,6 +396,31 @@
|
||||
p.pop('</ClCompile>')
|
||||
end
|
||||
|
||||
--
|
||||
-- Write the the <CustomBuildStep> compiler settings block.
|
||||
--
|
||||
|
||||
m.elements.buildStep = function(cfg)
|
||||
local calls = {
|
||||
m.buildCommands,
|
||||
m.buildMessage,
|
||||
m.buildOutputs,
|
||||
m.buildInputs
|
||||
}
|
||||
|
||||
return calls
|
||||
end
|
||||
|
||||
function m.buildStep(cfg)
|
||||
if #cfg.buildCommands > 0 or #cfg.buildOutputs > 0 or #cfg.buildInputs > 0 or cfg.buildMessage then
|
||||
|
||||
p.push('<CustomBuildStep>')
|
||||
p.callArray(m.elements.buildStep, cfg)
|
||||
p.pop('</CustomBuildStep>')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Write the <FxCompile> settings block.
|
||||
@ -1514,6 +1540,12 @@
|
||||
end
|
||||
end
|
||||
|
||||
function m.buildInputs(cfg, condition)
|
||||
if cfg.buildinputs and #cfg.buildinputs > 0 then
|
||||
local inputs = project.getrelative(cfg.project, cfg.buildinputs)
|
||||
m.element("Inputs", condition, '%s', table.concat(inputs, ";"))
|
||||
end
|
||||
end
|
||||
|
||||
function m.buildAdditionalInputs(fcfg, condition)
|
||||
if fcfg.buildinputs and #fcfg.buildinputs > 0 then
|
||||
@ -1524,9 +1556,10 @@
|
||||
|
||||
|
||||
function m.buildCommands(fcfg, condition)
|
||||
if #fcfg.buildcommands > 0 then
|
||||
local commands = os.translateCommandsAndPaths(fcfg.buildcommands, fcfg.project.basedir, fcfg.project.location)
|
||||
commands = table.concat(commands,'\r\n')
|
||||
m.element("Command", condition, '%s', commands)
|
||||
m.element("Command", condition, '%s', table.concat(commands,'\r\n'))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1547,9 +1580,11 @@
|
||||
|
||||
|
||||
function m.buildOutputs(fcfg, condition)
|
||||
if #fcfg.buildoutputs > 0 then
|
||||
local outputs = project.getrelative(fcfg.project, fcfg.buildoutputs)
|
||||
m.element("Outputs", condition, '%s', table.concat(outputs, ";"))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.linkObjects(fcfg, condition)
|
||||
|
Reference in New Issue
Block a user