Skip to content

Commit

Permalink
add bindirs for pacakge
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jul 25, 2024
1 parent 001cb3a commit 7ad05dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion xmake/core/package/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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(),
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions xmake/modules/package/manager/xmake/find_package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ad05dc

Please sign in to comment.