2009-05-12 21:44:45 +00:00
|
|
|
--
|
|
|
|
-- tests/test_gcc.lua
|
|
|
|
-- Automated test suite for the GCC toolset interface.
|
2011-02-10 17:24:51 +00:00
|
|
|
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
|
2009-05-12 21:44:45 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
T.gcc = { }
|
2009-12-31 22:46:45 +00:00
|
|
|
local suite = T.gcc
|
2009-05-12 21:44:45 +00:00
|
|
|
|
|
|
|
local cfg
|
2009-12-31 22:46:45 +00:00
|
|
|
function suite.setup()
|
2009-05-12 21:44:45 +00:00
|
|
|
cfg = { }
|
|
|
|
cfg.basedir = "."
|
|
|
|
cfg.location = "."
|
|
|
|
cfg.language = "C++"
|
|
|
|
cfg.project = { name = "MyProject" }
|
|
|
|
cfg.flags = { }
|
|
|
|
cfg.objectsdir = "obj"
|
|
|
|
cfg.platform = "Native"
|
2009-05-22 18:24:42 +00:00
|
|
|
cfg.links = { }
|
|
|
|
cfg.libdirs = { }
|
2009-06-02 19:40:59 +00:00
|
|
|
cfg.linktarget = { fullpath="libMyProject.a" }
|
2009-05-12 21:44:45 +00:00
|
|
|
end
|
|
|
|
|
2009-12-31 22:46:45 +00:00
|
|
|
|
2011-02-10 17:24:51 +00:00
|
|
|
--
|
|
|
|
-- CPPFLAGS tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cppflags_OnWindows()
|
2009-05-12 21:44:45 +00:00
|
|
|
cfg.system = "windows"
|
2011-02-10 17:24:51 +00:00
|
|
|
local r = premake.gcc.getcppflags(cfg)
|
|
|
|
test.isequal("-MMD -MP", table.concat(r, " "))
|
2009-05-12 21:44:45 +00:00
|
|
|
end
|
|
|
|
|
2011-02-10 17:24:51 +00:00
|
|
|
function suite.cppflags_OnHaiku()
|
|
|
|
cfg.system = "haiku"
|
|
|
|
local r = premake.gcc.getcppflags(cfg)
|
|
|
|
test.isequal("-MMD", table.concat(r, " "))
|
|
|
|
end
|
2009-12-31 22:46:45 +00:00
|
|
|
|
2011-02-10 17:24:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- CFLAGS tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cflags_SharedLib_Windows()
|
2009-05-12 21:44:45 +00:00
|
|
|
cfg.kind = "SharedLib"
|
|
|
|
cfg.system = "windows"
|
2011-02-10 17:24:51 +00:00
|
|
|
local r = premake.gcc.getcflags(cfg)
|
|
|
|
test.isequal('', table.concat(r,"|"))
|
2009-05-12 21:44:45 +00:00
|
|
|
end
|
2009-09-29 20:28:13 +00:00
|
|
|
|
2009-12-31 22:46:45 +00:00
|
|
|
|
|
|
|
function suite.cflags_OnFpFast()
|
2009-09-29 20:28:13 +00:00
|
|
|
cfg.flags = { "FloatFast" }
|
|
|
|
local r = premake.gcc.getcflags(cfg)
|
|
|
|
test.isequal('-ffast-math', table.concat(r,"|"))
|
|
|
|
end
|
|
|
|
|
2009-12-31 22:46:45 +00:00
|
|
|
|
|
|
|
function suite.cflags_OnFpStrict()
|
2009-09-29 20:28:13 +00:00
|
|
|
cfg.flags = { "FloatStrict" }
|
|
|
|
local r = premake.gcc.getcflags(cfg)
|
|
|
|
test.isequal('-ffloat-store', table.concat(r,"|"))
|
|
|
|
end
|
2009-12-31 22:46:45 +00:00
|
|
|
|
|
|
|
|
2011-02-10 17:24:51 +00:00
|
|
|
--
|
|
|
|
-- LDFLAGS tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.ldflags_SharedLib_Windows()
|
|
|
|
cfg.kind = "SharedLib"
|
|
|
|
cfg.system = "windows"
|
|
|
|
local r = premake.gcc.getldflags(cfg)
|
|
|
|
test.isequal('-s|-shared|-Wl,--out-implib="libMyProject.a"', table.concat(r,"|"))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-12-31 22:46:45 +00:00
|
|
|
function suite.linkflags_OnFrameworks()
|
|
|
|
cfg.links = { "Cocoa.framework" }
|
|
|
|
local r = premake.gcc.getlinkflags(cfg)
|
|
|
|
test.isequal('-framework Cocoa', table.concat(r,"|"))
|
|
|
|
end
|