From 7ad05dc941aa400582ad2357217ab976fd55b576 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 25 Jul 2024 22:48:57 +0800 Subject: [PATCH] add bindirs for pacakge --- xmake/core/package/package.lua | 8 +++++++- xmake/modules/package/manager/xmake/find_package.lua | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index b4249c6a08a..fd5d5243354 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1032,7 +1032,10 @@ function _instance:_rawenvs() envs = {} -- add bin PATH - if self:is_binary() or self:is_plat("windows", "mingw") then -- bin/*.dll for windows + local bindirs = self:get("bindirs") + if bindirs then + envs.PATH = table.wrap(bindirs) + elseif self:is_binary() or self:is_plat("windows", "mingw") then -- bin/*.dll for windows envs.PATH = {"bin"} end @@ -1863,6 +1866,7 @@ function _instance:find_tool(name, opt) self._find_tool = self._find_tool or sandbox_module.import("lib.detect.find_tool", {anonymous = true}) return self._find_tool(name, {cachekey = opt.cachekey or "fetch_package_system", installdir = self:installdir({readonly = true}), + bindirs = self:get("bindirs"), version = true, -- we alway check version require_version = opt.require_version, norun = opt.norun, @@ -1888,6 +1892,7 @@ function _instance:find_package(name, opt) return self._find_package(name, { force = opt.force, installdir = self:installdir({readonly = true}), + bindirs = self:get("bindirs"), version = true, -- we alway check version require_version = opt.require_version, mode = self:mode(), @@ -2714,6 +2719,7 @@ function package.apis() , "package.set_sourcedir" , "package.set_cachedir" , "package.set_installdir" + , "package.add_bindirs" -- package.add_xxx , "package.add_deps" , "package.add_urls" diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua index e3aed1294ce..18f6908ee24 100644 --- a/xmake/modules/package/manager/xmake/find_package.lua +++ b/xmake/modules/package/manager/xmake/find_package.lua @@ -163,9 +163,12 @@ function _find_package_from_repo(name, opt) end end if opt.plat == "windows" or opt.plat == "mingw" then - for _, file in ipairs(os.files(path.join(installdir, "bin", "*.dll"))) do - result.shared = true - table.insert(libfiles, file) + local bindirs = opt.bindirs or "bin" + for _, bindir in ipairs(bindirs) do + for _, file in ipairs(os.files(path.join(installdir, bindir, "*.dll"))) do + result.shared = true + table.insert(libfiles, file) + end end -- @see https://github.com/xmake-io/xmake/issues/5325#issuecomment-2242513463 if not result.shared then