diff options
| author | ruki <[email protected]> | 2021-09-16 00:31:02 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-16 00:31:02 +0800 |
| commit | 4cc9ef5e230ac3b765d26cdc3b0dd51ece2448e4 (patch) | |
| tree | 790fd7048c6f5eb18713ce41499719948b1f3fe3 | |
| parent | 43a72ecc3eba54b09dadcd0e8754dae7b23ed2da (diff) | |
improve mingw implib
| -rw-r--r-- | xmake/core/project/target.lua | 12 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_library.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 4 | ||||
| -rw-r--r-- | xmake/platforms/mingw/xmake.lua | 4 |
5 files changed, 12 insertions, 17 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 8cfbf0a12..959e94f5b 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2059,18 +2059,14 @@ end -- get the link name of the target file function target.linkname(filename) + -- for implib/mingw, e.g. libxxx.dll.a + if filename:startswith("lib") and filename:endswith(".dll.a") then + return filename:sub(4, #filename - 6) + end local linkname, count = filename:gsub(target.filename("__pattern__", "static"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") if count == 0 then linkname, count = filename:gsub(target.filename("__pattern__", "shared"):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") end - if count == 0 then - -- for the mingw/cross 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", {format = formats["static"]}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1") - if count == 0 then - linkname, count = filename:gsub(target.filename("__pattern__", "shared", {format = 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 bfb2315a5..0b783538c 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua @@ -64,10 +64,9 @@ function sandbox_lib_detect_find_library.main(names, paths, 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), paths, opt) - if not filepath then - -- for the mingw/cross 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, {format = formats[kind]}), paths, opt) + if not filepath and kind == "shared" then + -- for implib/mingw, e.g. libxxx.dll.a + filepath = find_file(target.filename(name, kind) .. ".a", paths, opt) end if filepath then local filename = path.filename(filepath) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 89b732ec9..713cd80aa 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -334,7 +334,7 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) -- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc if targetkind == "shared" and is_plat("mingw") then - table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib")) + table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".dll.a")) end -- init arguments diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 1ca09401e..41093c502 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -259,9 +259,9 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags) end -- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc - if targetkind == "shared" and config.plat() == "mingw" then + if targetkind == "shared" and is_plat("mingw") then table.insert(flags_extra, "-Xlinker") - table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".lib")) + table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".dll.a")) end -- make link args diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua index b856cf876..b86786a0f 100644 --- a/xmake/platforms/mingw/xmake.lua +++ b/xmake/platforms/mingw/xmake.lua @@ -31,9 +31,9 @@ platform("mingw") set_archs("i386", "x86_64", "arm", "arm64") -- set formats - set_formats("static", "$(name).lib") + set_formats("static", "lib$(name).a") set_formats("object", "$(name).obj") - set_formats("shared", "$(name).dll") + set_formats("shared", "lib$(name).dll") set_formats("binary", "$(name).exe") set_formats("symbol", "$(name).pdb") |
