summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-12-21 23:06:18 +0800
committerruki <[email protected]>2023-12-21 23:06:18 +0800
commit16271a7919d9ee12203f1ba5774d73f720b79451 (patch)
tree645d98803e6eeaefb80e3c8c0f4284c171a3cf7c
parent4296189fb104b1632c939b6bdef5cf86f610fd40 (diff)
add buildrequires
-rw-r--r--xmake/includes/xpack/xmake.lua2
-rw-r--r--xmake/plugins/pack/srpm/main.lua42
-rw-r--r--xmake/scripts/xpack/srpm/srpm.spec2
3 files changed, 28 insertions, 18 deletions
diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua
index 76df1a7b6..5b8580172 100644
--- a/xmake/includes/xpack/xmake.lua
+++ b/xmake/includes/xpack/xmake.lua
@@ -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
diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua
index 949b99516..2c9a0cb1b 100644
--- a/xmake/plugins/pack/srpm/main.lua
+++ b/xmake/plugins/pack/srpm/main.lua
@@ -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
diff --git a/xmake/scripts/xpack/srpm/srpm.spec b/xmake/scripts/xpack/srpm/srpm.spec
index 778afcfb0..a0b403dd1 100644
--- a/xmake/scripts/xpack/srpm/srpm.spec
+++ b/xmake/scripts/xpack/srpm/srpm.spec
@@ -13,8 +13,6 @@ License: ${PACKAGE_LICENSE}
URL: ${PACKAGE_HOMEPAGE}
Source0: ${PACKAGE_ARCHIVEFILE}
-BuildRequires: gcc
-BuildRequires: gcc-c++
${PACKAGE_BUILDREQUIRES}
%description