Added ignoreDefaultLibraries API for Visual Studio 2010+ projects.

This commit is contained in:
Sam Surtees 2015-08-25 00:44:12 +10:00
parent 1de083849a
commit 5d6d05c31d
5 changed files with 83 additions and 1 deletions

View File

@ -561,6 +561,13 @@
tokens = true,
}
api.register {
name = "ignoredefaultlibraries",
scope = "project",
kind = "list:mixed",
tokens = true,
}
api.register {
name = "icon",
scope = "project",

View File

@ -401,6 +401,7 @@
m.generateMapFile,
m.moduleDefinitionFile,
m.treatLinkerWarningAsErrors,
m.ignoreDefaultLibraries,
m.additionalLinkOptions,
}
end
@ -1231,6 +1232,21 @@
end
function m.ignoreDefaultLibraries(cfg)
if #cfg.ignoredefaultlibraries > 0 then
local ignored = cfg.ignoredefaultlibraries
for i = 1, #ignored do
-- Add extension if required
if not p.tools.msc.getLibraryExtensions()[ignored[i]:match("[^.]+$")] then
ignored[i] = path.appendextension(ignored[i], ".lib")
end
end
m.element("IgnoreSpecificDefaultLibraries", condition, table.concat(ignored, ';'))
end
end
function m.ignoreWarnDuplicateFilename(prj)
-- VS 2013 warns on duplicate file names, even those files which are
-- contained in different, mututally exclusive configurations. See:

View File

@ -211,6 +211,16 @@
local map = iif(cfg.kind ~= premake.STATICLIB, msc.linkerFlags, msc.librarianFlags)
local flags = config.mapFlags(cfg, map)
table.insert(flags, 1, "/NOLOGO")
-- Ignore default libraries
for i, ignore in ipairs(cfg.ignoredefaultlibraries) do
-- Add extension if required
if not msc.getLibraryExtensions()[ignore:match("[^.]+$")] then
ignore = path.appendextension(ignore, ".lib")
end
table.insert(flags, '/NODEFAULTLIB:' .. ignore)
end
return flags
end
@ -262,7 +272,6 @@
return links
end
--
-- Returns makefile-specific configuration rules.
--

View File

@ -460,3 +460,37 @@
</Link>
]]
end
--
-- Test ignoring default libraries with extensions specified.
--
function suite.ignoreDefaultLibraries_WithExtensions()
ignoredefaultlibraries { "lib1.lib", "lib2.obj" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<IgnoreSpecificDefaultLibraries>lib1.lib;lib2.obj</IgnoreSpecificDefaultLibraries>
</Link>
]]
end
--
-- Test ignoring default libraries without extensions specified.
--
function suite.ignoreDefaultLibraries_WithExtensions()
ignoredefaultlibraries { "lib1", "lib2.obj" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ImportLibrary>bin\Debug\MyProject.lib</ImportLibrary>
<IgnoreSpecificDefaultLibraries>lib1.lib;lib2.obj</IgnoreSpecificDefaultLibraries>
</Link>
]]
end

View File

@ -326,3 +326,19 @@
prepare()
test.contains('/LIBPATH:"/usr/local/lib"', msc.getLibraryDirectories(cfg))
end
--
-- 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