Skip to content

Commit

Permalink
add buildrequires
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 21, 2023
1 parent 4296189 commit 16271a7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
2 changes: 2 additions & 0 deletions xmake/includes/xpack/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ local apis = {
"xpack.set_includedir",
-- set prefix directory, e.g. prefixdir/bin, prefixdir/lib ..
"xpack.set_prefixdir",
-- add build requires for source inputkind
"xpack.add_buildrequires",
-- set nsis display icon
"xpack.set_nsis_displayicon",
-- set package component title
Expand Down
42 changes: 26 additions & 16 deletions xmake/plugins/pack/srpm/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,37 @@ function _get_specvars(package)
end
specvars.PACKAGE_BUILDREQUIRES = function ()
local requires = {}
local programs = hashset.new()
for _, cmd in ipairs(batchcmds.get_buildcmds(package):cmds()) do
local program = cmd.program
if program then
programs:insert(program)
local buildrequires = package:get("buildrequires")
if buildrequires then
for _, buildrequire in ipairs(buildrequires) do
table.insert(requires, "BuildRequires: " .. buildrequire)
end
end
local map = {
xmake = "xmake",
cmake = "cmake",
make = "make"
}
for _, program in programs:keys() do
local requirename = map[program]
if requirename then
table.insert(requires, "BuildRequires: " .. requirename)
else
local programs = hashset.new()
for _, cmd in ipairs(batchcmds.get_buildcmds(package):cmds()) do
local program = cmd.program
if program then
programs:insert(program)
end
end
local map = {
xmake = "xmake",
cmake = "cmake",
make = "make"
}
for _, program in programs:keys() do
local requirename = map[program]
if requirename then
table.insert(requires, "BuildRequires: " .. requirename)
end
end
if #requires > 0 then
table.insert(requires, "BuildRequires: gcc")
table.insert(requires, "BuildRequires: gcc-c++")
end
end
return table.concat(requires, "\n")
end

return specvars
end

Expand Down
2 changes: 0 additions & 2 deletions xmake/scripts/xpack/srpm/srpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ License: ${PACKAGE_LICENSE}
URL: ${PACKAGE_HOMEPAGE}
Source0: ${PACKAGE_ARCHIVEFILE}

BuildRequires: gcc
BuildRequires: gcc-c++
${PACKAGE_BUILDREQUIRES}

%description
Expand Down

0 comments on commit 16271a7

Please sign in to comment.