Fixed naming of system libraries in Visual Studio link step

This commit is contained in:
starkos 2009-06-08 15:36:28 +00:00
parent 1da7795d67
commit 2e920a1ef1
5 changed files with 71 additions and 15 deletions

View File

@ -24,7 +24,8 @@
RC1 -> RC2 RC1 -> RC2
- Removed additional MonoDevelop files in clean action. - Removed additional MonoDevelop files in clean action
- Fixed naming of system libraries in Visual Studio link step
----- -----

View File

@ -24,8 +24,8 @@ solution "PremakeTestbox"
include "CppStaticLib" include "CppStaticLib"
if _ACTION ~= "codeblocks" and _ACTION ~= "codelite" then if _ACTION ~= "codeblocks" and _ACTION ~= "codelite" then
include "CsSharedLib" -- include "CsSharedLib"
include "CsConsoleApp" -- include "CsConsoleApp"
end end

View File

@ -392,8 +392,8 @@
for _, prj in ipairs(sln.projects) do for _, prj in ipairs(sln.projects) do
for _, cfg in pairs(prj.__configs) do for _, cfg in pairs(prj.__configs) do
-- determine which conventions the target should follow for this config -- determine which conventions the target should follow for this config
local pathstyle = premake.actions[_ACTION].pathstyle or "posix" local pathstyle = premake.getpathstyle(cfg)
local namestyle = premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or "posix" local namestyle = premake.getnamestyle(cfg)
-- build the targets -- build the targets
cfg.buildtarget = premake.gettarget(cfg, "build", pathstyle, namestyle, cfg.system) cfg.buildtarget = premake.gettarget(cfg, "build", pathstyle, namestyle, cfg.system)

View File

@ -252,14 +252,17 @@
-- am I getting links for a configuration or a project? -- am I getting links for a configuration or a project?
local cfgname = iif(cfg.name == cfg.project.name, "", cfg.name) local cfgname = iif(cfg.name == cfg.project.name, "", cfg.name)
-- how should files be named?
local namestyle = premake.getnamestyle(cfg)
local function canlink(source, target) local function canlink(source, target)
if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then return false end if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then
if (source.language == "C" or source.language == "C++") then return false
if (target.language ~= "C" and target.language ~= "C++") then return false end end
return true if premake.iscppproject(source) then
elseif (source.language == "C#") then return premake.iscppproject(target)
if (target.language ~= "C#") then return false end elseif premake.isdotnetproject(source) then
return true return premake.isdotnetproject(target)
end end
end end
@ -292,8 +295,12 @@
end end
elseif (part == "fullpath") then elseif (part == "fullpath") then
item = link item = link
if premake.actions[_ACTION].targetstyle == "windows" then if namestyle == "windows" then
item = item .. iif(cfg.language == "C" or cfg.language == "C++", ".lib", ".dll") if premake.iscppproject(cfg) then
item = item .. ".lib"
elseif premake.isdotnetproject(cfg) then
item = item .. ".dll"
end
end end
if item:find("/", nil, true) then if item:find("/", nil, true) then
item = path.getrelative(cfg.basedir, item) item = path.getrelative(cfg.basedir, item)
@ -305,7 +312,7 @@
end end
if item then if item then
if premake.actions[_ACTION].targetstyle == "windows" and part ~= "object" then if namestyle == "windows" and part ~= "object" then
item = path.translate(item, "\\") item = path.translate(item, "\\")
end end
if not table.contains(result, item) then if not table.contains(result, item) then
@ -319,6 +326,22 @@
--
-- Gets the name style for a configuration, indicating what kind of prefix,
-- extensions, etc. should be used in target file names.
--
-- @param cfg
-- The configuration to check.
-- @returns
-- The target naming style, one of "windows", "posix", or "PS3".
--
function premake.getnamestyle(cfg)
return premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or "posix"
end
-- --
-- Converts a project object and a template filespec (the first value in an -- Converts a project object and a template filespec (the first value in an
-- action's template reference) into a filename for that template's output. -- action's template reference) into a filename for that template's output.
@ -337,6 +360,21 @@
--
-- Gets the path style for a configuration, indicating what kind of path separator
-- should be used in target file names.
--
-- @param cfg
-- The configuration to check.
-- @returns
-- The target path style, one of "windows" or "posix".
--
function premake.getpathstyle(cfg)
return premake.actions[_ACTION].pathstyle or "posix"
end
-- --
-- Assembles a target for a particular tool/system/configuration. -- Assembles a target for a particular tool/system/configuration.
-- --

View File

@ -11,12 +11,29 @@
function T.project.setup() function T.project.setup()
_ACTION = "gmake" _ACTION = "gmake"
cfg = {} cfg = {}
cfg.project = {}
cfg.language = "C++"
cfg.files = {} cfg.files = {}
cfg.trimpaths = {} cfg.trimpaths = {}
cfg.platform = "Native"
result = "\n" result = "\n"
end end
--
-- premake.getlinks() tests
--
function T.project.getlinks_OnMscSystemLibs()
_OPTIONS.cc = "msc"
cfg.links = { "user32", "gdi32" }
result = premake.getlinks(cfg, "all", "fullpath")
test.isequal("user32.lib gdi32.lib", table.concat(result, " "))
end
-- --
-- premake.walksources() tests -- premake.walksources() tests