2012-01-18 21:26:05 +00:00
|
|
|
--
|
|
|
|
-- tests/config/test_links.lua
|
|
|
|
-- Test the list of linked objects retrieval function.
|
2013-11-14 13:52:55 +00:00
|
|
|
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
|
2012-01-18 21:26:05 +00:00
|
|
|
--
|
|
|
|
|
2017-04-25 05:44:13 +00:00
|
|
|
local p = premake
|
2013-11-14 13:52:55 +00:00
|
|
|
local suite = test.declare("config_links")
|
2017-04-25 05:44:13 +00:00
|
|
|
local config = p.config
|
2012-01-18 21:26:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks, prj
|
2012-01-18 21:26:05 +00:00
|
|
|
|
|
|
|
function suite.setup()
|
2017-04-25 05:44:13 +00:00
|
|
|
p.action.set("test")
|
2017-04-11 20:39:25 +00:00
|
|
|
_TARGET_OS = "windows"
|
2015-08-28 20:16:14 +00:00
|
|
|
wks, prj = test.createWorkspace()
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
|
|
|
|
2013-03-04 16:45:27 +00:00
|
|
|
local function prepare(kind, part, linkage)
|
2013-11-14 13:52:55 +00:00
|
|
|
cfg = test.getconfig(prj, "Debug")
|
2013-03-04 16:45:27 +00:00
|
|
|
return config.getlinks(cfg, kind, part, linkage)
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If no links are present, should return an empty table.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.emptyResult_onNoLinks()
|
|
|
|
local r = prepare("all", "object")
|
|
|
|
test.isequal(0, #r)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- System libraries which include path information are made project relative.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.pathMadeRelative_onSystemLibWithPath()
|
|
|
|
location "build"
|
|
|
|
links { "../libs/z" }
|
|
|
|
local r = prepare("all", "fullpath")
|
2015-02-14 19:56:02 +00:00
|
|
|
test.isequal({ "../../libs/z" }, r)
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-03-04 16:45:27 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Handle the case where the library extension has been explicitly
|
|
|
|
-- included in the link statement.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.skipsExtension_onExplicitExtension()
|
2012-03-22 23:30:34 +00:00
|
|
|
system "windows"
|
|
|
|
links { "user32.lib" }
|
|
|
|
local r = prepare("all", "fullpath")
|
|
|
|
test.isequal({ "user32.lib" }, r)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Check handling of shell variables in library paths.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.variableMaintained_onLeadingVariable()
|
|
|
|
system "windows"
|
|
|
|
location "build"
|
2015-03-11 20:16:56 +00:00
|
|
|
links { "$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI" }
|
2012-03-22 23:30:34 +00:00
|
|
|
local r = prepare("all", "fullpath")
|
2015-03-11 20:16:56 +00:00
|
|
|
test.isequal({ "$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI" }, r)
|
2012-03-22 23:30:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.variableMaintained_onQuotedVariable()
|
|
|
|
system "windows"
|
|
|
|
location "build"
|
2015-03-11 20:16:56 +00:00
|
|
|
links { '"$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI.lib"' }
|
2012-03-22 23:30:34 +00:00
|
|
|
local r = prepare("all", "fullpath")
|
2015-03-11 20:16:56 +00:00
|
|
|
test.isequal({ '"$(LOCAL_DEV_PATH)/sdk/lib/DEVMAPI.lib"' }, r)
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
2012-06-13 21:18:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If fetching directories, the libdirs should be included in the result.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.includesLibDirs_onDirectories()
|
|
|
|
libdirs { "../libs" }
|
|
|
|
local r = prepare("all", "directory")
|
|
|
|
test.isequal({ "../libs" }, r)
|
|
|
|
end
|
2012-06-30 12:25:30 +00:00
|
|
|
|
|
|
|
|
2013-03-04 16:45:27 +00:00
|
|
|
--
|
|
|
|
-- Managed C++ projects should ignore links to managed assemblies, which
|
|
|
|
-- are designated with an explicit ".dll" extension.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.skipsAssemblies_onManagedCpp()
|
|
|
|
system "windows"
|
2014-11-12 00:20:29 +00:00
|
|
|
clr "On"
|
2013-03-04 16:45:27 +00:00
|
|
|
links { "user32", "System.dll" }
|
|
|
|
local r = prepare("all", "fullpath")
|
2015-02-14 19:56:02 +00:00
|
|
|
test.isequal({ "user32" }, r)
|
2013-03-04 16:45:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- When explicitly requesting managed links, any unmanaged items in the
|
|
|
|
-- list should be ignored.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.skipsUnmanagedLibs_onManagedLinkage()
|
|
|
|
system "windows"
|
2014-11-12 00:20:29 +00:00
|
|
|
clr "On"
|
2013-03-04 16:45:27 +00:00
|
|
|
links { "user32", "System.dll" }
|
|
|
|
local r = prepare("all", "fullpath", "managed")
|
|
|
|
test.isequal({ "System.dll" }, r)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Managed projects can link to other managed projects, and unmanaged
|
|
|
|
-- projects can link to unmanaged projects.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.canLink_CppAndCpp()
|
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "StaticLib"
|
|
|
|
language "C++"
|
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
2015-07-02 14:14:26 +00:00
|
|
|
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
|
2013-03-04 16:45:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.canLink_CsAndCs()
|
|
|
|
language "C#"
|
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C#"
|
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
2015-07-02 14:14:26 +00:00
|
|
|
test.isequal({ "bin/Debug/MyProject2.dll" }, r)
|
2013-03-04 16:45:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.canLink_ManagedCppAndManagedCpp()
|
2014-11-12 00:20:29 +00:00
|
|
|
clr "On"
|
2013-03-04 16:45:27 +00:00
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "StaticLib"
|
|
|
|
language "C++"
|
2014-11-12 00:20:29 +00:00
|
|
|
clr "On"
|
2013-03-04 16:45:27 +00:00
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
2015-07-02 14:14:26 +00:00
|
|
|
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
|
2013-03-04 16:45:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.canLink_ManagedCppAndCs()
|
2014-11-12 00:20:29 +00:00
|
|
|
clr "On"
|
2013-03-04 16:45:27 +00:00
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C#"
|
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
2015-07-02 14:14:26 +00:00
|
|
|
test.isequal({ "bin/Debug/MyProject2.dll" }, r)
|
2013-03-04 16:45:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Managed and unmanaged projects can not link to each other.
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
function suite.ignoreLink_CppAndCs()
|
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C#"
|
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
|
|
|
test.isequal({}, r)
|
|
|
|
end
|
2019-02-07 14:10:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Mixed and unmanaged projects can link to each other.
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
function suite.canLink_MixedAndNativeCpp()
|
|
|
|
clr "On"
|
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C++"
|
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
|
|
|
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.canLink_NativeAndMixedCpp()
|
|
|
|
links { "MyProject2" }
|
|
|
|
|
|
|
|
project "MyProject2"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C++"
|
|
|
|
clr "On"
|
|
|
|
|
|
|
|
local r = prepare("all", "fullpath")
|
|
|
|
test.isequal({ "bin/Debug/MyProject2.lib" }, r)
|
|
|
|
end
|