Added some sanity tests for config linker information, to get things started
This commit is contained in:
parent
3f0f15942a
commit
761673005b
@ -224,86 +224,6 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Return the list of tools required to build a specific configuration.
|
||||
-- Each tool gets represented by an XML element in the project file.
|
||||
--
|
||||
|
||||
function vc200x.gettools(cfg)
|
||||
if _ACTION == "vs2002" then
|
||||
return {
|
||||
"VCCLCompilerTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCLinkerTool",
|
||||
"VCMIDLTool",
|
||||
"VCPostBuildEventTool",
|
||||
"VCPreBuildEventTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCWebDeploymentTool"
|
||||
}
|
||||
end
|
||||
if _ACTION == "vs2003" then
|
||||
return {
|
||||
"VCCLCompilerTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCLinkerTool",
|
||||
"VCMIDLTool",
|
||||
"VCPostBuildEventTool",
|
||||
"VCPreBuildEventTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCXMLDataGeneratorTool",
|
||||
"VCWebDeploymentTool",
|
||||
"VCManagedWrapperGeneratorTool",
|
||||
"VCAuxiliaryManagedWrapperGeneratorTool"
|
||||
}
|
||||
end
|
||||
if cfg.system == premake.XBOX360 then
|
||||
return {
|
||||
"VCPreBuildEventTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCXMLDataGeneratorTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCMIDLTool",
|
||||
"VCCLCompilerTool",
|
||||
"VCManagedResourceCompilerTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCLinkerTool",
|
||||
"VCALinkTool",
|
||||
"VCX360ImageTool",
|
||||
"VCBscMakeTool",
|
||||
"VCX360DeploymentTool",
|
||||
"VCPostBuildEventTool",
|
||||
"DebuggerTool",
|
||||
}
|
||||
end
|
||||
return {
|
||||
"VCPreBuildEventTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCXMLDataGeneratorTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCMIDLTool",
|
||||
"VCCLCompilerTool",
|
||||
"VCManagedResourceCompilerTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCLinkerTool",
|
||||
"VCALinkTool",
|
||||
"VCManifestTool",
|
||||
"VCXDCMakeTool",
|
||||
"VCBscMakeTool",
|
||||
"VCFxCopTool",
|
||||
"VCAppVerifierTool",
|
||||
"VCWebDeploymentTool",
|
||||
"VCPostBuildEventTool"
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Write out an empty tool element.
|
||||
--
|
||||
@ -634,6 +554,86 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Return the list of tools required to build a specific configuration.
|
||||
-- Each tool gets represented by an XML element in the project file.
|
||||
--
|
||||
|
||||
function vc200x.gettools(cfg)
|
||||
if _ACTION == "vs2002" then
|
||||
return {
|
||||
"VCCLCompilerTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCLinkerTool",
|
||||
"VCMIDLTool",
|
||||
"VCPostBuildEventTool",
|
||||
"VCPreBuildEventTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCWebDeploymentTool"
|
||||
}
|
||||
end
|
||||
if _ACTION == "vs2003" then
|
||||
return {
|
||||
"VCCLCompilerTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCLinkerTool",
|
||||
"VCMIDLTool",
|
||||
"VCPostBuildEventTool",
|
||||
"VCPreBuildEventTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCXMLDataGeneratorTool",
|
||||
"VCWebDeploymentTool",
|
||||
"VCManagedWrapperGeneratorTool",
|
||||
"VCAuxiliaryManagedWrapperGeneratorTool"
|
||||
}
|
||||
end
|
||||
if cfg.system == premake.XBOX360 then
|
||||
return {
|
||||
"VCPreBuildEventTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCXMLDataGeneratorTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCMIDLTool",
|
||||
"VCCLCompilerTool",
|
||||
"VCManagedResourceCompilerTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCLinkerTool",
|
||||
"VCALinkTool",
|
||||
"VCX360ImageTool",
|
||||
"VCBscMakeTool",
|
||||
"VCX360DeploymentTool",
|
||||
"VCPostBuildEventTool",
|
||||
"DebuggerTool",
|
||||
}
|
||||
end
|
||||
return {
|
||||
"VCPreBuildEventTool",
|
||||
"VCCustomBuildTool",
|
||||
"VCXMLDataGeneratorTool",
|
||||
"VCWebServiceProxyGeneratorTool",
|
||||
"VCMIDLTool",
|
||||
"VCCLCompilerTool",
|
||||
"VCManagedResourceCompilerTool",
|
||||
"VCResourceCompilerTool",
|
||||
"VCPreLinkEventTool",
|
||||
"VCLinkerTool",
|
||||
"VCALinkTool",
|
||||
"VCManifestTool",
|
||||
"VCXDCMakeTool",
|
||||
"VCBscMakeTool",
|
||||
"VCFxCopTool",
|
||||
"VCAppVerifierTool",
|
||||
"VCWebDeploymentTool",
|
||||
"VCPostBuildEventTool"
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Map tool names to output functions. Tools that aren't listed will
|
||||
-- output a standard empty tool element.
|
||||
|
@ -29,7 +29,7 @@
|
||||
local basedir = project.getlocation(cfg.project)
|
||||
|
||||
local directory = cfg[field.."dir"] or cfg.targetdir or basedir
|
||||
directory = path.getrelative(basedir, directory)
|
||||
directory = project.getrelative(cfg.project, directory)
|
||||
|
||||
local basename = cfg[field.."name"] or cfg.targetname or cfg.project.name
|
||||
|
||||
@ -76,8 +76,8 @@
|
||||
end
|
||||
end
|
||||
|
||||
prefix = cfg.targetprefix or prefix
|
||||
suffix = cfg.targetsuffix or suffix
|
||||
prefix = cfg[field.."prefix"] or cfg.targetprefix or prefix
|
||||
suffix = cfg[field.."suffix"] or cfg.targetsuffix or suffix
|
||||
|
||||
local info = {}
|
||||
info.directory = directory
|
||||
|
98
tests/config/test_linkinfo.lua
Executable file
98
tests/config/test_linkinfo.lua
Executable file
@ -0,0 +1,98 @@
|
||||
--
|
||||
-- tests/config/test_linkinfo.lua
|
||||
-- Test the config object's link target accessor.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.config_linkinfo = { }
|
||||
local suite = T.config_linkinfo
|
||||
local project = premake5.project
|
||||
local config = premake5.config
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "test"
|
||||
sln, prj = test.createsolution()
|
||||
kind "StaticLib"
|
||||
system "windows"
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = project.getconfig(prj, "Debug")
|
||||
return config.getlinkinfo(cfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Directory should be current (".") by default.
|
||||
--
|
||||
|
||||
function suite.directoryIsDot_onNoTargetDir()
|
||||
i = prepare()
|
||||
test.isequal(".", i.directory)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Directory should use targetdir() value if present.
|
||||
--
|
||||
|
||||
function suite.directoryIsTargetDir_onTargetDir()
|
||||
targetdir "../bin"
|
||||
i = prepare()
|
||||
test.isequal("../bin", i.directory)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Shared library should use implibdir() if present.
|
||||
--
|
||||
|
||||
function suite.directoryIsImpLibDir_onImpLibAndTargetDir()
|
||||
kind "SharedLib"
|
||||
targetdir "../bin"
|
||||
implibdir "../lib"
|
||||
i = prepare()
|
||||
test.isequal("../lib", i.directory)
|
||||
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.
|
||||
--
|
||||
|
||||
function suite.basenameIsTargetName_onTargetName()
|
||||
kind "SharedLib"
|
||||
targetname "MyTarget"
|
||||
implibname "MyTargetImports"
|
||||
i = prepare()
|
||||
test.isequal("MyTargetImports", i.basename)
|
||||
end
|
||||
|
62
tests/config/test_links.lua
Executable file
62
tests/config/test_links.lua
Executable file
@ -0,0 +1,62 @@
|
||||
--
|
||||
-- tests/config/test_links.lua
|
||||
-- Test the list of linked objects retrieval function.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.config_links = { }
|
||||
local suite = T.config_links
|
||||
local project = premake5.project
|
||||
local config = premake5.config
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "test"
|
||||
sln, prj = test.createsolution()
|
||||
system "macosx"
|
||||
end
|
||||
|
||||
local function prepare(kind, part)
|
||||
cfg = project.getconfig(prj, "Debug")
|
||||
return config.getlinks(cfg, kind, part)
|
||||
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")
|
||||
test.isequal("../../libs/z", r[1])
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- On Windows, system libraries get the ".lib" file extensions.
|
||||
--
|
||||
|
||||
function suite.libAdded_onWindowsSystemLibs()
|
||||
system "windows"
|
||||
links { "user32" }
|
||||
local r = prepare("all", "fullpath")
|
||||
test.isequal("user32.lib", r[1])
|
||||
end
|
@ -57,15 +57,19 @@
|
||||
dofile("tools/test_gcc.lua")
|
||||
dofile("base/test_config_bug.lua")
|
||||
|
||||
-- Project API tests
|
||||
-- Project object tests
|
||||
dofile("test_project.lua")
|
||||
dofile("config/test_objdir.lua")
|
||||
dofile("config/test_targetinfo.lua")
|
||||
dofile("project/test_baking.lua")
|
||||
dofile("project/test_eachconfig.lua")
|
||||
dofile("project/test_eachfile.lua")
|
||||
dofile("project/test_vpaths.lua")
|
||||
|
||||
-- Configuration object tests
|
||||
dofile("config/test_linkinfo.lua")
|
||||
dofile("config/test_links.lua")
|
||||
dofile("config/test_objdir.lua")
|
||||
dofile("config/test_targetinfo.lua")
|
||||
|
||||
-- Baking tests
|
||||
dofile("base/test_baking.lua")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user