Skip to content

Commit 5cdbfe6

Browse files
committed
improve libfiles for apt
1 parent 7b7e98e commit 5cdbfe6

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

xmake/modules/package/manager/apt/find_package.lua

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ function _find_package(dpkg, name, opt)
5353
result.links = result.links or {}
5454
result.linkdirs = result.linkdirs or {}
5555
result.libfiles = result.libfiles or {}
56+
if line:endswith(".a") then
57+
result.static = true
58+
else
59+
result.shared = true
60+
end
5661
table.insert(result.linkdirs, path.directory(line))
5762
table.insert(result.links, target.linkname(path.filename(line), {plat = opt.plat}))
5863
table.insert(result.libfiles, path.join(path.directory(line), path.filename(line)))
@@ -62,7 +67,7 @@ function _find_package(dpkg, name, opt)
6267

6368
-- we iterate over each pkgconfig file to extract the required data
6469
local foundpc = false
65-
local pcresult = {includedirs = {}, linkdirs = {}, links = {}}
70+
local pcresult = {includedirs = {}, linkdirs = {}, links = {}, libfiles = {}}
6671
for _, pkgconfig_file in ipairs(pkgconfig_files) do
6772
local pkgconfig_dir = path.directory(pkgconfig_file)
6873
local pkgconfig_name = path.basename(pkgconfig_file)
@@ -79,6 +84,13 @@ function _find_package(dpkg, name, opt)
7984
for _, link in ipairs(pcinfo.links) do
8085
table.insert(pcresult.links, link)
8186
end
87+
if not result or not result.libfiles then
88+
for _, libfile in ipairs(pcinfo.libfiles) do
89+
table.insert(pcresult.libfiles, libfile)
90+
end
91+
pcresult.static = pcinfo.static
92+
pcresult.shared = pcinfo.shared
93+
end
8294
-- version should be the same if a pacman package contains multiples .pc
8395
pcresult.version = pcinfo.version
8496
foundpc = true
@@ -87,6 +99,7 @@ function _find_package(dpkg, name, opt)
8799
if foundpc == true then
88100
pcresult.includedirs = table.unique(pcresult.includedirs)
89101
pcresult.linkdirs = table.unique(pcresult.linkdirs)
102+
pcresult.libfiles = table.unique(pcresult.libfiles)
90103
pcresult.links = table.reverse_unique(pcresult.links)
91104
result = pcresult
92105
end
@@ -109,16 +122,30 @@ function _find_package(dpkg, name, opt)
109122
end
110123
end
111124

112-
-- remove repeat
113125
if result then
114126
if result.links then
115127
result.links = table.unique(result.links)
128+
if #result.links == 0 then
129+
result.links = nil
130+
end
116131
end
117132
if result.linkdirs then
118133
result.linkdirs = table.unique(result.linkdirs)
134+
if #result.linkdirs == 0 then
135+
result.linkdirs = nil
136+
end
119137
end
120138
if result.includedirs then
121139
result.includedirs = table.unique(result.includedirs)
140+
if #result.includedirs == 0 then
141+
result.includedirs = nil
142+
end
143+
end
144+
if result.libfiles then
145+
result.libfiles = table.unique(result.libfiles)
146+
if #result.libfiles == 0 then
147+
result.libfiles = nil
148+
end
122149
end
123150
end
124151
return result

0 commit comments

Comments
 (0)