Merge pull request #919 from Blizzard/gmake2-perfile_flags-test

Add perfile flags test for gmake backend.
This commit is contained in:
Tom van Dijck 2017-10-13 09:07:45 -07:00 committed by GitHub
commit d4a95ae606
3 changed files with 78 additions and 1 deletions

View File

@ -522,7 +522,7 @@
_p('# #############################################')
_p('')
for cfg in project.eachconfig(prj) do
table.foreachi(cfg.project._.files, function(node)
table.foreachi(prj._.files, function(node)
local fcfg = fileconfig.getconfig(node, cfg)
if fcfg then
cpp.perFileFlags(cfg, fcfg)
@ -533,6 +533,7 @@
end
local function makeVarName(prj, value, saltValue)
prj._gmake = prj._gmake or {}
prj._gmake.varlist = prj._gmake.varlist or {}
prj._gmake.varlistlength = prj._gmake.varlistlength or 0
local cache = prj._gmake.varlist

View File

@ -8,6 +8,7 @@ return {
"test_gmake2_linking.lua",
"test_gmake2_objects.lua",
"test_gmake2_pch.lua",
"test_gmake2_perfile_flags.lua",
"test_gmake2_target_rules.lua",
"test_gmake2_tools.lua",
}

View File

@ -0,0 +1,75 @@
--
-- gmake2_perfile_flags.lua
-- Tests compiler and linker flags for Makefiles.
-- (c) 2016-2017 Jason Perkins, Blizzard Entertainment and the Premake project
--
local suite = test.declare("gmake2_perfile_flags")
local p = premake
local gmake2 = p.modules.gmake2
local project = p.project
--
-- Setup
--
local wks
function suite.setup()
wks = test.createWorkspace()
end
local function prepare()
local prj = p.workspace.getproject(wks, 1)
gmake2.cpp.outputPerFileConfigurationSection(prj)
end
--
-- Test per file settings.
--
function suite.perfile_buildOptions()
files { 'a.cpp', 'b.cpp', 'c.cpp' }
filter { 'files:a.cpp' }
buildoptions { '-msse', '-msse2', '-mfpmath=sse,387', '-msse3', '-mssse3', '-msse4.1', '-mpclmul' }
filter { 'files:b.cpp' }
buildoptions { '-msse', '-msse2', '-mfpmath=sse,387' }
filter { 'files:c.cpp' }
buildoptions { '-msse', '-msse2', '-mfpmath=sse,387', '-msse3', '-mssse3', '-msse4.1', '-maes' }
prepare()
test.capture [[
# Per File Configurations
# #############################################
PERFILE_FLAGS_0 = $(ALL_CXXFLAGS) -msse -msse2 -mfpmath=sse,387 -msse3 -mssse3 -msse4.1 -mpclmul
PERFILE_FLAGS_1 = $(ALL_CXXFLAGS) -msse -msse2 -mfpmath=sse,387
PERFILE_FLAGS_2 = $(ALL_CXXFLAGS) -msse -msse2 -mfpmath=sse,387 -msse3 -mssse3 -msse4.1 -maes
]]
end
function suite.perfile_mixedbuildOptions()
files { 'a.c', 'b.cpp', 'c.c' }
filter { 'files:a.c' }
buildoptions { '-msse', '-msse2', '-mfpmath=sse,387', '-msse3', '-mssse3', '-msse4.1', '-mpclmul' }
filter { 'files:b.cpp' }
buildoptions { '-msse', '-msse2', '-mfpmath=sse,387' }
filter { 'files:c.c' }
buildoptions { '-msse', '-msse2', '-mfpmath=sse,387', '-msse3', '-mssse3', '-msse4.1', '-maes' }
prepare()
test.capture [[
# Per File Configurations
# #############################################
PERFILE_FLAGS_0 = $(ALL_CFLAGS) -msse -msse2 -mfpmath=sse,387 -msse3 -mssse3 -msse4.1 -mpclmul
PERFILE_FLAGS_1 = $(ALL_CXXFLAGS) -msse -msse2 -mfpmath=sse,387
PERFILE_FLAGS_2 = $(ALL_CFLAGS) -msse -msse2 -mfpmath=sse,387 -msse3 -mssse3 -msse4.1 -maes
]]
end