diff options
| author | ruki <[email protected]> | 2019-04-25 22:47:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-04-25 10:45:28 +0800 |
| commit | bef83839894c841a4423f7724abd4495ea7b3c75 (patch) | |
| tree | 28732fd28d0c68f136d54ffc9216890c3569edd3 | |
| parent | 64a34fcca6999e1e0478d77d86801a8bf5fbff21 (diff) | |
improve find_library for mingw
| -rw-r--r-- | xmake/core/project/target.lua | 8 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_library.lua | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 0ad6b533e..cebbfec7d 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1605,6 +1605,14 @@ function target.linkname(filename) if count == 0 then linkname, count = filename:gsub(target.filename("__pattern__", "shared"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") end + if count == 0 and config.is_plat("mingw") then + -- for the mingw platform, it is compatible with the libxxx.a and xxx.lib + local formats = {static = "lib$(name).a", shared = "lib$(name).so"} + linkname, count = filename:gsub(target.filename("__pattern__", "static", formats["static"]):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") + if count == 0 then + linkname, count = filename:gsub(target.filename("__pattern__", "shared", formats["shared"]):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") + end + end return count > 0 and linkname or nil end diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua index 156195cba..a3fd9e43b 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua @@ -26,6 +26,7 @@ local os = require("base/os") local path = require("base/path") local utils = require("base/utils") local table = require("base/table") +local config = require("project/config") local target = require("project/target") local raise = require("sandbox/modules/raise") local import = require("sandbox/modules/import") @@ -63,6 +64,11 @@ function sandbox_lib_detect_find_library.main(names, pathes, opt) for _, name in ipairs(table.wrap(names)) do for _, kind in ipairs(table.wrap(kinds)) do local filepath = find_file(target.filename(name, kind), pathes, opt) + if not filepath and config.is_plat("mingw") then + -- for the mingw platform, it is compatible with the libxxx.a and xxx.lib + local formats = {static = "lib$(name).a", shared = "lib$(name).so"} + filepath = find_file(target.filename(name, kind, formats[kind]), pathes, opt) + end if filepath then local filename = path.filename(filepath) return {kind = kind, filename = filename, linkdir = path.directory(filepath), link = target.linkname(filename)} |
