diff options
author | starkos <none@none> | 2009-06-08 19:36:28 +0400 |
---|---|---|
committer | starkos <none@none> | 2009-06-08 19:36:28 +0400 |
commit | a1cb562418270a8be7b61c7f9f3764060571281b (patch) | |
tree | 2ca5b139973a70b32295196251c94efb639e3b5a | |
parent | 77a5418eedaf02d455bd895bfb51bd0d6c3ad8dd (diff) |
Fixed naming of system libraries in Visual Studio link step
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | samples/project/premake4.lua | 4 | ||||
-rw-r--r-- | src/base/configs.lua | 4 | ||||
-rw-r--r-- | src/base/project.lua | 58 | ||||
-rw-r--r-- | tests/test_project.lua | 17 |
5 files changed, 71 insertions, 15 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index cd3fafb..c9522c7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -24,7 +24,8 @@ 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 ----- diff --git a/samples/project/premake4.lua b/samples/project/premake4.lua index 382f191..89d7ef1 100644 --- a/samples/project/premake4.lua +++ b/samples/project/premake4.lua @@ -24,8 +24,8 @@ solution "PremakeTestbox" include "CppStaticLib" if _ACTION ~= "codeblocks" and _ACTION ~= "codelite" then - include "CsSharedLib" - include "CsConsoleApp" +-- include "CsSharedLib" +-- include "CsConsoleApp" end diff --git a/src/base/configs.lua b/src/base/configs.lua index bad6a22..1aa64f0 100644 --- a/src/base/configs.lua +++ b/src/base/configs.lua @@ -392,8 +392,8 @@ for _, prj in ipairs(sln.projects) do for _, cfg in pairs(prj.__configs) do -- determine which conventions the target should follow for this config - local pathstyle = premake.actions[_ACTION].pathstyle or "posix" - local namestyle = premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or "posix" + local pathstyle = premake.getpathstyle(cfg) + local namestyle = premake.getnamestyle(cfg) -- build the targets cfg.buildtarget = premake.gettarget(cfg, "build", pathstyle, namestyle, cfg.system) diff --git a/src/base/project.lua b/src/base/project.lua index c94c426..10b21dc 100644 --- a/src/base/project.lua +++ b/src/base/project.lua @@ -252,14 +252,17 @@ -- am I getting links for a configuration or a project? 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) - if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then return false end - if (source.language == "C" or source.language == "C++") then - if (target.language ~= "C" and target.language ~= "C++") then return false end - return true - elseif (source.language == "C#") then - if (target.language ~= "C#") then return false end - return true + if (target.kind ~= "SharedLib" and target.kind ~= "StaticLib") then + return false + end + if premake.iscppproject(source) then + return premake.iscppproject(target) + elseif premake.isdotnetproject(source) then + return premake.isdotnetproject(target) end end @@ -292,8 +295,12 @@ end elseif (part == "fullpath") then item = link - if premake.actions[_ACTION].targetstyle == "windows" then - item = item .. iif(cfg.language == "C" or cfg.language == "C++", ".lib", ".dll") + if namestyle == "windows" then + if premake.iscppproject(cfg) then + item = item .. ".lib" + elseif premake.isdotnetproject(cfg) then + item = item .. ".dll" + end end if item:find("/", nil, true) then item = path.getrelative(cfg.basedir, item) @@ -305,7 +312,7 @@ end if item then - if premake.actions[_ACTION].targetstyle == "windows" and part ~= "object" then + if namestyle == "windows" and part ~= "object" then item = path.translate(item, "\\") end if not table.contains(result, item) then @@ -320,6 +327,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 -- action's template reference) into a filename for that template's output. -- The filespec may be either a file extension, or a function. @@ -338,6 +361,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. -- -- @param cfg diff --git a/tests/test_project.lua b/tests/test_project.lua index 8b9f4b9..3e0d302 100644 --- a/tests/test_project.lua +++ b/tests/test_project.lua @@ -11,12 +11,29 @@ function T.project.setup() _ACTION = "gmake" cfg = {} + cfg.project = {} + cfg.language = "C++" cfg.files = {} cfg.trimpaths = {} + cfg.platform = "Native" result = "\n" 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 |