-- -- tests/actions/vstudio/vc2010/test_link.lua -- Validate linking and project references in Visual Studio 2010 C/C++ projects. -- Copyright (c) 2011 Jason Perkins and the Premake project -- T.vstudio_vs2010_link = { } local suite = T.vstudio_vs2010_link local vc2010 = premake.vstudio.vc2010 local project = premake5.project -- -- Setup -- local sln, prj, cfg function suite.setup() _ACTION = "vs2010" sln, prj = test.createsolution() kind "SharedLib" end local function prepare(platform) cfg = project.getconfig(prj, "Debug", platform) vc2010.link(cfg) end -- -- Check the basic element structure with default settings. -- function suite.defaultSettings() kind "SharedLib" prepare() test.capture [[ Windows false MyProject.lib ]] end -- -- Check the basic element structure with a release build. -- function suite.defaultSettings_onOptimize() flags "Optimize" prepare() test.capture [[ Windows false true true MyProject.lib ]] end -- -- Check subsystem values with each project kind. -- function suite.subsystem_onConsoleApp() kind "ConsoleApp" prepare() test.capture [[ Console false mainCRTStartup ]] end function suite.subsystem_onWindowedApp() kind "WindowedApp" prepare() test.capture [[ Windows false mainCRTStartup ]] end function suite.subsystem_onSharedLib() kind "SharedLib" prepare() test.capture [[ Windows false MyProject.lib ]] end function suite.subsystem_onStaticLib() kind "StaticLib" prepare() test.capture [[ Windows false ]] end -- -- Test the handling of the Symbols flag. -- function suite.generateDebugInfo_onSymbols() flags "Symbols" prepare() test.capture [[ Windows true ]] end -- -- Any system libraries specified in links() should be listed as -- additional dependencies. -- function suite.additionalDependencies_onSystemLinks() links { "lua", "zlib" } prepare() test.capture [[ Windows false lua.lib;zlib.lib;%(AdditionalDependencies) ]] end -- -- Additional library directories should be specified, relative to the project. -- function suite.additionalLibraryDirectories_onLibDirs() libdirs { "../lib", "../lib64" } prepare() test.capture [[ Windows false ..\lib;..\lib64;%(AdditionalLibraryDirectories) ]] end -- -- If a sibling library is listed in links(), it should NOT appear in -- the additional dependencies element. Visual Studio will figure that -- out from the project reference item group. -- function suite.noDependencies_onOnlySiblingProjectLinks() links { "MyProject2" } test.createproject(sln) prepare() test.capture [[ Windows false ]] end function suite.onlySystemDependencies_OnSiblingProjectLink() links { "MyProject2", "kernel32" } test.createproject(sln) prepare() test.capture [[ Windows false kernel32.lib;%(AdditionalDependencies) ]] end -- -- Static libraries do not link dependencies directly, to maintain -- compatibility with GCC and others. -- function suite.additionalDependencies_onSystemLinksAndStaticLib() kind "StaticLib" links { "lua", "zlib" } libdirs { "../lib", "../lib64" } prepare() test.capture [[ Windows false ]] end -- -- Check handling of the import library settings. -- function suite.importLibrary_onImpLibDir() implibdir "../lib" prepare() test.capture [[ Windows false ..\lib\MyProject.lib ]] end -- -- Check handling of additional options. -- function suite.additionalOptions_onNonStaticLib() kind "SharedLib" linkoptions { "/kupo" } prepare() test.capture [[ Windows false MyProject.lib /kupo %(AdditionalOptions) ]] end function suite.additionalOptions_onStaticLib() kind "StaticLib" linkoptions { "/kupo" } prepare() test.capture [[ Windows false /kupo %(AdditionalOptions) ]] end -- -- Enable reference optimizing if Optimize flag is specified. -- function suite.optimizeReferences_onOptimizeFlag() flags { "Optimize" } prepare() test.capture [[ Windows false true true ]] end -- -- On the PS3, system libraries must be prefixed with the "-l" flag. -- function suite.additionalDependencies_onPS3SystemLinks() system "PS3" links { "fs_stub", "net_stub" } prepare() test.capture [[ Windows false -lfs_stub;-lnet_stub;%(AdditionalDependencies) ]] end