Skip to content

Commit

Permalink
fix packagedeps
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Aug 19, 2024
1 parent cbefe04 commit e5c5bb0
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 19 deletions.
2 changes: 1 addition & 1 deletion xmake/modules/lib/detect/find_package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function _concat_packages(a, b)
result[k] = v
end
for k, v in pairs(result) do
if k == "links" then
if k == "links" or k == "syslinks" or k == "frameworks" or k == "ldflags" or k == "shflags" then
if type(v) == "table" and #v > 1 then
-- we need to ensure link orders when removing repeat values
v = table.reverse_unique(v)
Expand Down
49 changes: 40 additions & 9 deletions xmake/modules/package/tools/autoconf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,36 +181,67 @@ end

-- get cflags from package deps
function _get_cflags_from_packagedeps(package, opt)
local result = {}
local values
for _, depname in ipairs(opt.packagedeps) do
local dep = type(depname) ~= "string" and depname or package:dep(depname)
if dep then
local fetchinfo = dep:fetch()
if fetchinfo then
table.join2(result, _map_compflags(package, "cxx", "define", fetchinfo.defines))
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "includedir", fetchinfo.includedirs)))
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "sysincludedir", fetchinfo.sysincludedirs)))
if values then
values = values .. fetchinfo
else
values = fetchinfo
end
end
end
end
-- @see https://github.com/xmake-io/xmake-repo/pull/4973#issuecomment-2295890196
local result = {}
if values then
if values.defines then
table.join2(result, _map_compflags(package, "cxx", "define", values.defines))
end
if values.includedirs then
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "includedir", values.includedirs)))
end
if values.sysincludedirs then
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "sysincludedir", values.sysincludedirs)))
end
end
return result
end

-- get ldflags from package deps
function _get_ldflags_from_packagedeps(package, opt)
local result = {}
local values
for _, depname in ipairs(opt.packagedeps) do
local dep = type(depname) ~= "string" and depname or package:dep(depname)
if dep then
local fetchinfo = dep:fetch()
if fetchinfo then
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "linkdir", fetchinfo.linkdirs)))
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "link", fetchinfo.links))
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "syslink", fetchinfo.syslinks)))
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "framework", fetchinfo.frameworks))
if values then
values = values .. fetchinfo
else
values = fetchinfo
end
end
end
end
local result = {}
if values then
if values.linkdirs then
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "linkdir", values.linkdirs)))
end
if values.links then
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "link", values.links))
end
if values.syslinks then
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "syslink", values.syslinks)))
end
if values.frameworks then
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "framework", values.frameworks))
end
end
return result
end

Expand Down
49 changes: 40 additions & 9 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,36 +100,67 @@ end

-- get cflags from package deps
function _get_cflags_from_packagedeps(package, opt)
local result = {}
local values
for _, depname in ipairs(opt.packagedeps) do
local dep = type(depname) ~= "string" and depname or package:dep(depname)
if dep then
local fetchinfo = dep:fetch()
if fetchinfo then
table.join2(result, _map_compflags(package, "cxx", "define", fetchinfo.defines))
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "includedir", fetchinfo.includedirs)))
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "sysincludedir", fetchinfo.sysincludedirs)))
if values then
values = values .. fetchinfo
else
values = fetchinfo
end
end
end
end
-- @see https://github.com/xmake-io/xmake-repo/pull/4973#issuecomment-2295890196
local result = {}
if values then
if values.defines then
table.join2(result, _map_compflags(package, "cxx", "define", values.defines))
end
if values.includedirs then
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "includedir", values.includedirs)))
end
if values.sysincludedirs then
table.join2(result, _translate_paths(_map_compflags(package, "cxx", "sysincludedir", values.sysincludedirs)))
end
end
return result
end

-- get ldflags from package deps
function _get_ldflags_from_packagedeps(package, opt)
local result = {}
local values
for _, depname in ipairs(opt.packagedeps) do
local dep = type(depname) ~= "string" and depname or package:dep(depname)
if dep then
local fetchinfo = dep:fetch()
if fetchinfo then
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "linkdir", fetchinfo.linkdirs)))
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "link", fetchinfo.links))
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "syslink", fetchinfo.syslinks)))
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "framework", fetchinfo.frameworks))
if values then
values = values .. fetchinfo
else
values = fetchinfo
end
end
end
end
local result = {}
if values then
if values.linkdirs then
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "linkdir", values.linkdirs)))
end
if values.links then
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "link", values.links))
end
if values.syslinks then
table.join2(result, _translate_paths(_map_linkflags(package, "binary", {"cxx"}, "syslink", values.syslinks)))
end
if values.frameworks then
table.join2(result, _map_linkflags(package, "binary", {"cxx"}, "framework", values.frameworks))
end
end
return result
end

Expand Down

0 comments on commit e5c5bb0

Please sign in to comment.