From 2a2247530ba2cb2e4e07a465be67911829f7ee45 Mon Sep 17 00:00:00 2001 From: Enzo Einhorn <52015993+enzalito@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:51:06 +0200 Subject: [PATCH] add on_fetch to binutils package (#4636) * add on_fetch to binutils package * Update xmake.lua * Update xmake.lua * check more tools in binutil's on_fetch * fix boolean operator --------- Co-authored-by: ruki --- packages/b/binutils/xmake.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/b/binutils/xmake.lua b/packages/b/binutils/xmake.lua index cd41c5172..38d960634 100644 --- a/packages/b/binutils/xmake.lua +++ b/packages/b/binutils/xmake.lua @@ -10,7 +10,7 @@ package("binutils") add_versions("2.41", "ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450") add_versions("2.38", "e316477a914f567eccc34d5d29785b8b0f5a10208d36bbacedcc39048ecfe024") add_versions("2.34", "f00b0e8803dc9bab1e2165bd568528135be734df3fabf8d0161828cd56028952") - + if is_plat("mingw") and is_subhost("msys") then add_extsources("pacman::binutils") elseif is_plat("linux") then @@ -19,6 +19,31 @@ package("binutils") add_extsources("brew::binutils") end + on_fetch("@linux", "@macosx", "@msys", function (package, opt) + if opt.system then + if package:is_binary() then + local tools = {"lb", "ranlib", "objcopy"} + for _, tool in ipairs(tools) do + if not package:find_tool(tool) then + return + end + end + return {} + elseif package:is_library() then + local libs = {"bfd", "ctf", "opcodes"} + local result + for _, lib in ipairs(libs) do + local libinfo = package:find_package("system::" .. lib) + if libinfo then + result = result or {links = {}} + table.insert(result.links, libinfo.links) + end + end + return result + end + end + end) + add_deps("bison") on_install("@linux", "@macosx", "@msys", function (package)