diff --git a/modules/gmake2/gmake2_cpp.lua b/modules/gmake2/gmake2_cpp.lua index 7826a59e..b6b55ea9 100644 --- a/modules/gmake2/gmake2_cpp.lua +++ b/modules/gmake2/gmake2_cpp.lua @@ -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 diff --git a/modules/gmake2/tests/_tests.lua b/modules/gmake2/tests/_tests.lua index f8e86134..9ab48812 100644 --- a/modules/gmake2/tests/_tests.lua +++ b/modules/gmake2/tests/_tests.lua @@ -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", } diff --git a/modules/gmake2/tests/test_gmake2_perfile_flags.lua b/modules/gmake2/tests/test_gmake2_perfile_flags.lua new file mode 100644 index 00000000..f9843ae9 --- /dev/null +++ b/modules/gmake2/tests/test_gmake2_perfile_flags.lua @@ -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