Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add perfile flags test for gmake backend. #919

Merged
merged 1 commit into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/gmake2/gmake2_cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/gmake2/tests/_tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
75 changes: 75 additions & 0 deletions modules/gmake2/tests/test_gmake2_perfile_flags.lua
Original file line number Diff line number Diff line change
@@ -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