2012-08-18 20:33:37 +00:00
|
|
|
--
|
|
|
|
-- tests/test_msc.lua
|
|
|
|
-- Automated test suite for the Microsoft C toolset interface.
|
2013-11-14 13:52:55 +00:00
|
|
|
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
|
2012-08-18 20:33:37 +00:00
|
|
|
--
|
|
|
|
|
2013-11-14 13:52:55 +00:00
|
|
|
local suite = test.declare("tools_msc")
|
2012-08-18 20:33:37 +00:00
|
|
|
|
|
|
|
local msc = premake.tools.msc
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup/teardown
|
|
|
|
--
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks, prj, cfg
|
2012-08-18 20:33:37 +00:00
|
|
|
|
|
|
|
function suite.setup()
|
2015-08-28 20:16:14 +00:00
|
|
|
wks, prj = test.createWorkspace()
|
2013-12-17 21:43:09 +00:00
|
|
|
kind "SharedLib"
|
2012-08-18 20:33:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2013-11-14 13:52:55 +00:00
|
|
|
cfg = test.getconfig(prj, "Debug")
|
2012-08-18 20:33:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-10-16 17:47:09 +00:00
|
|
|
--
|
|
|
|
-- Check the optimization flags.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cflags_onNoOptimize()
|
|
|
|
optimize "Off"
|
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/Od", msc.getcflags(cfg))
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onOptimize()
|
|
|
|
optimize "On"
|
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/Ot", msc.getcflags(cfg))
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onOptimizeSize()
|
|
|
|
optimize "Size"
|
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/O1", msc.getcflags(cfg))
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onOptimizeSpeed()
|
|
|
|
optimize "Speed"
|
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/O2", msc.getcflags(cfg))
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onOptimizeFull()
|
|
|
|
optimize "Full"
|
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/Ox", msc.getcflags(cfg))
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onOptimizeDebug()
|
|
|
|
optimize "Debug"
|
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/Od", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onNoFramePointers()
|
|
|
|
flags "NoFramePointer"
|
|
|
|
prepare()
|
|
|
|
test.contains("/Oy", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.ldflags_onLinkTimeOptimizations()
|
|
|
|
flags "LinkTimeOptimization"
|
|
|
|
prepare()
|
|
|
|
test.contains("/GL", msc.getldflags(cfg))
|
2013-10-16 17:47:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-08-18 20:33:37 +00:00
|
|
|
--
|
2013-11-22 19:06:41 +00:00
|
|
|
-- Check handling of debugging support.
|
2012-08-18 20:33:37 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
function suite.ldflags_onSymbols()
|
2013-11-22 19:06:41 +00:00
|
|
|
flags "Symbols"
|
2012-08-18 20:33:37 +00:00
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/DEBUG", msc.getldflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling warnings and errors.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cflags_OnNoWarnings()
|
|
|
|
warnings "Off"
|
|
|
|
prepare()
|
|
|
|
test.contains("/W0", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_OnExtraWarnings()
|
|
|
|
warnings "Extra"
|
|
|
|
prepare()
|
|
|
|
test.contains("/W4", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_OnFatalWarnings()
|
|
|
|
flags "FatalWarnings"
|
|
|
|
prepare()
|
|
|
|
test.contains("/WX", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
2015-03-10 10:59:28 +00:00
|
|
|
function suite.cflags_onSpecificWarnings()
|
|
|
|
enablewarnings { "enable" }
|
|
|
|
disablewarnings { "disable" }
|
|
|
|
fatalwarnings { "fatal" }
|
|
|
|
prepare()
|
|
|
|
test.contains({ '/wd"disable"', '/we"fatal"' }, msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
2013-11-22 19:06:41 +00:00
|
|
|
function suite.ldflags_OnFatalWarnings()
|
|
|
|
flags "FatalWarnings"
|
|
|
|
prepare()
|
|
|
|
test.contains("/WX", msc.getldflags(cfg))
|
2012-08-18 20:33:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of library search paths.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.libdirs_onLibdirs()
|
2013-11-22 19:06:41 +00:00
|
|
|
libdirs { "../libs" }
|
2012-08-18 20:33:37 +00:00
|
|
|
prepare()
|
2014-05-24 00:10:34 +00:00
|
|
|
test.contains('/LIBPATH:"../libs"', msc.getLibraryDirectories(cfg))
|
2012-08-18 20:33:37 +00:00
|
|
|
end
|
2012-11-09 16:07:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of forced includes.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.forcedIncludeFiles()
|
2013-11-22 19:06:41 +00:00
|
|
|
forceincludes { "include/sys.h" }
|
|
|
|
prepare()
|
|
|
|
test.contains('/FIinclude/sys.h', msc.getforceincludes(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of floating point modifiers.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cflags_onFloatingPointFast()
|
|
|
|
floatingpoint "Fast"
|
|
|
|
prepare()
|
|
|
|
test.contains("/fp:fast", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onFloatingPointStrict()
|
|
|
|
floatingpoint "Strict"
|
|
|
|
prepare()
|
|
|
|
test.contains("/fp:strict", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onSSE()
|
|
|
|
vectorextensions "SSE"
|
|
|
|
prepare()
|
2015-03-26 12:17:13 +00:00
|
|
|
test.contains("/arch:SSE", msc.getcflags(cfg))
|
2013-11-22 19:06:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onSSE2()
|
|
|
|
vectorextensions "SSE2"
|
|
|
|
prepare()
|
2015-03-26 12:17:13 +00:00
|
|
|
test.contains("/arch:SSE2", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onAVX()
|
|
|
|
vectorextensions "AVX"
|
|
|
|
prepare()
|
|
|
|
test.contains("/arch:AVX", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onAVX2()
|
|
|
|
vectorextensions "AVX2"
|
|
|
|
prepare()
|
|
|
|
test.contains("/arch:AVX2", msc.getcflags(cfg))
|
2013-11-22 19:06:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-10 10:41:44 +00:00
|
|
|
--
|
|
|
|
-- Check the defines and undefines.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.defines()
|
|
|
|
defines "DEF"
|
|
|
|
prepare()
|
|
|
|
test.contains({ '/D"DEF"' }, msc.getdefines(cfg.defines))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.undefines()
|
|
|
|
undefines "UNDEF"
|
|
|
|
prepare()
|
|
|
|
test.contains({ '/U"UNDEF"' }, msc.getundefines(cfg.undefines))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-11-22 19:06:41 +00:00
|
|
|
--
|
|
|
|
-- Check compilation options.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cflags_onNoMinimalRebuild()
|
|
|
|
flags "NoMinimalRebuild"
|
|
|
|
prepare()
|
|
|
|
test.contains("/Gm-", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onMultiProcessorCompile()
|
|
|
|
flags "MultiProcessorCompile"
|
|
|
|
prepare()
|
|
|
|
test.contains("/MP", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of C++ language features.
|
|
|
|
--
|
|
|
|
|
2015-06-23 23:03:28 +00:00
|
|
|
function suite.cxxflags_onExceptions()
|
2015-06-16 15:44:18 +00:00
|
|
|
exceptionhandling "on"
|
2013-11-22 19:06:41 +00:00
|
|
|
prepare()
|
|
|
|
test.contains("/EHsc", msc.getcxxflags(cfg))
|
|
|
|
end
|
|
|
|
|
2015-06-23 23:03:28 +00:00
|
|
|
function suite.cxxflags_onSEH()
|
|
|
|
exceptionhandling "SEH"
|
2015-06-16 15:44:18 +00:00
|
|
|
prepare()
|
|
|
|
test.contains("/EHa", msc.getcxxflags(cfg))
|
|
|
|
end
|
|
|
|
|
2015-06-23 23:03:28 +00:00
|
|
|
function suite.cxxflags_onNoExceptions()
|
2015-06-23 20:53:10 +00:00
|
|
|
exceptionhandling "Off"
|
2013-11-22 19:06:41 +00:00
|
|
|
prepare()
|
|
|
|
test.missing("/EHsc", msc.getcxxflags(cfg))
|
|
|
|
end
|
|
|
|
|
2015-06-23 23:03:28 +00:00
|
|
|
function suite.cxxflags_onNoRTTI()
|
2015-06-23 20:53:10 +00:00
|
|
|
rtti "Off"
|
2013-11-22 19:06:41 +00:00
|
|
|
prepare()
|
|
|
|
test.contains("/GR-", msc.getcxxflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of additional linker options.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.ldflags_onOmitDefaultLibrary()
|
|
|
|
flags "OmitDefaultLibrary"
|
|
|
|
prepare()
|
|
|
|
test.contains("/NODEFAULTLIB", msc.getldflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.ldflags_onNoIncrementalLink()
|
|
|
|
flags "NoIncrementalLink"
|
|
|
|
prepare()
|
|
|
|
test.contains("/INCREMENTAL:NO", msc.getldflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.ldflags_onNoManifest()
|
|
|
|
flags "NoManifest"
|
2012-11-09 16:07:01 +00:00
|
|
|
prepare()
|
2013-11-22 19:06:41 +00:00
|
|
|
test.contains("/MANIFEST:NO", msc.getldflags(cfg))
|
2012-11-09 16:07:01 +00:00
|
|
|
end
|
2013-12-20 15:19:44 +00:00
|
|
|
|
|
|
|
function suite.ldflags_onDLL()
|
|
|
|
kind "SharedLib"
|
|
|
|
prepare()
|
|
|
|
test.contains("/DLL", msc.getldflags(cfg))
|
|
|
|
end
|
2014-11-12 00:44:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of CLR settings.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.cflags_onClrOn()
|
|
|
|
clr "On"
|
|
|
|
prepare()
|
|
|
|
test.contains("/clr", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onClrUnsafe()
|
|
|
|
clr "Unsafe"
|
|
|
|
prepare()
|
|
|
|
test.contains("/clr", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onClrSafe()
|
|
|
|
clr "Safe"
|
|
|
|
prepare()
|
|
|
|
test.contains("/clr:safe", msc.getcflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.cflags_onClrPure()
|
|
|
|
clr "Pure"
|
|
|
|
prepare()
|
|
|
|
test.contains("/clr:pure", msc.getcflags(cfg))
|
|
|
|
end
|
2015-05-19 19:35:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of system search paths.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.includeDirs_onSysIncludeDirs()
|
|
|
|
sysincludedirs { "/usr/local/include" }
|
|
|
|
prepare()
|
|
|
|
test.contains("-I/usr/local/include", msc.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.libDirs_onSysLibDirs()
|
|
|
|
syslibdirs { "/usr/local/lib" }
|
|
|
|
prepare()
|
|
|
|
test.contains('/LIBPATH:"/usr/local/lib"', msc.getLibraryDirectories(cfg))
|
|
|
|
end
|
2015-08-24 14:44:12 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of ignore default libraries
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.ignoreDefaultLibraries_WithExtensions()
|
|
|
|
ignoredefaultlibraries { "lib1.lib" }
|
|
|
|
prepare()
|
|
|
|
test.contains('/NODEFAULTLIB:lib1.lib', msc.getldflags(cfg))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.ignoreDefaultLibraries_WithoutExtensions()
|
|
|
|
ignoredefaultlibraries { "lib1" }
|
|
|
|
prepare()
|
|
|
|
test.contains('/NODEFAULTLIB:lib1.lib', msc.getldflags(cfg))
|
|
|
|
end
|