From b5b490676355766b03ca366fe3900495cbf4a9fa Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 4 Sep 2021 23:13:28 +0800 Subject: add new merge archive rules --- xmake/modules/utils/archive/merge_staticlib.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'xmake/modules') diff --git a/xmake/modules/utils/archive/merge_staticlib.lua b/xmake/modules/utils/archive/merge_staticlib.lua index db72a8d97..8675f6c52 100644 --- a/xmake/modules/utils/archive/merge_staticlib.lua +++ b/xmake/modules/utils/archive/merge_staticlib.lua @@ -22,12 +22,17 @@ import("core.base.option") -- merge *.a archive libraries for ar -function _merge_for_ar(program, outputfile, libraryfiles, opt) +function _merge_for_ar(target, program, outputfile, libraryfiles, opt) opt = opt or {} + if target:is_plat("macosx") then + os.vrunv("libtool", table.join("-static", "-o", outputfile, libraryfiles)) + else + os.vrunv(program, table.join("crsT", outputfile, libraryfiles)) + end end -- merge *.a archive libraries for msvc/lib.exe -function _merge_for_msvclib(program, outputfile, libraryfiles, opt) +function _merge_for_msvclib(target, program, outputfile, libraryfiles, opt) opt = opt or {} end @@ -36,7 +41,7 @@ function main(target, outputfile, libraryfiles) local program, toolname = target:tool("ar") if program and toolname then if toolname:find("ar") then - _merge_for_ar(program, outputfile, libraryfiles) + _merge_for_ar(target, program, outputfile, libraryfiles) elseif toolname == "link" and target:is_plat("windows") then local msvc for _, toolchain_inst in ipairs(target:toolchains()) do @@ -45,7 +50,7 @@ function main(target, outputfile, libraryfiles) break end end - _merge_for_msvclib((program:gsub("link%.exe", "lib.exe")), outputfile, libraryfiles, {envs = msvc and msvc:runenvs()}) + _merge_for_msvclib(target, (program:gsub("link%.exe", "lib.exe")), outputfile, libraryfiles, {envs = msvc and msvc:runenvs()}) else raise("cannot merge (%s): unknown ar tool %s!", table.concat(libraryfiles, ", "), toolname) end -- cgit v1.3.1