Parcourir la source

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 <[email protected]>
Enzo Einhorn il y a 1 an
Parent
commit
2a2247530b
1 fichiers modifiés avec 26 ajouts et 1 suppressions
  1. 26 1
      packages/b/binutils/xmake.lua

+ 26 - 1
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)