2012-01-18 21:26:05 +00:00
|
|
|
--
|
|
|
|
-- tests/config/test_linkinfo.lua
|
2013-09-13 15:15:36 +00:00
|
|
|
-- Test the config object's link target accessor.
|
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_linkinfo")
|
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")
|
2015-08-28 20:16:14 +00:00
|
|
|
wks, prj = test.createWorkspace()
|
2012-01-18 21:26:05 +00:00
|
|
|
kind "StaticLib"
|
2012-06-28 19:48:05 +00:00
|
|
|
system "Windows"
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2013-11-14 13:52:55 +00:00
|
|
|
local cfg = test.getconfig(prj, "Debug")
|
2012-01-18 21:26:05 +00:00
|
|
|
return config.getlinkinfo(cfg)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Directory should use targetdir() value if present.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.directoryIsTargetDir_onTargetDir()
|
|
|
|
targetdir "../bin"
|
|
|
|
i = prepare()
|
2012-10-08 15:50:42 +00:00
|
|
|
test.isequal("../bin", path.getrelative(os.getcwd(), i.directory))
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Shared library should use implibdir() if present.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.directoryIsImpLibDir_onImpLibAndTargetDir()
|
|
|
|
kind "SharedLib"
|
|
|
|
targetdir "../bin"
|
|
|
|
implibdir "../lib"
|
|
|
|
i = prepare()
|
2012-10-08 15:50:42 +00:00
|
|
|
test.isequal("../lib", path.getrelative(os.getcwd(), i.directory))
|
2012-01-18 21:26:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Base name should use the project name by default.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.basenameIsProjectName_onNoTargetName()
|
|
|
|
i = prepare()
|
|
|
|
test.isequal("MyProject", i.basename)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Base name should use targetname() if present.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.basenameIsTargetName_onTargetName()
|
|
|
|
targetname "MyTarget"
|
|
|
|
i = prepare()
|
|
|
|
test.isequal("MyTarget", i.basename)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Shared library should use implibname() if present.
|
|
|
|
--
|
|
|
|
|
2018-04-30 13:40:49 +00:00
|
|
|
function suite.basenameIsImplibName_onTargetName()
|
2012-01-18 21:26:05 +00:00
|
|
|
kind "SharedLib"
|
|
|
|
targetname "MyTarget"
|
|
|
|
implibname "MyTargetImports"
|
|
|
|
i = prepare()
|
|
|
|
test.isequal("MyTargetImports", i.basename)
|
|
|
|
end
|
|
|
|
|
2012-06-28 19:48:05 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Test library name formatting.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.nameFormatting_onWindows()
|
|
|
|
system "Windows"
|
|
|
|
i = prepare()
|
|
|
|
test.isequal("MyProject.lib", i.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.nameFormatting_onLinux()
|
|
|
|
system "Linux"
|
|
|
|
i = prepare()
|
|
|
|
test.isequal("libMyProject.a", i.name)
|
|
|
|
end
|
2012-07-11 19:53:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
2013-09-13 15:15:36 +00:00
|
|
|
-- The import library extension should not change if the a
|
2012-07-11 19:53:21 +00:00
|
|
|
-- custom target extension is set.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.impLibExtensionUnmodified_OnCustomTargetExt()
|
|
|
|
system "windows"
|
|
|
|
kind "SharedLib"
|
|
|
|
targetextension ".mil"
|
|
|
|
i = prepare()
|
|
|
|
test.isequal("MyProject.lib", i.name)
|
|
|
|
end
|