Skip to content

Commit

Permalink
add build requires
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 21, 2023
1 parent 1976625 commit 4296189
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/plugins/pack/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ xpack("test")
add_targets("test", "foo")
add_installfiles("src/(assets/*.png)", {prefixdir = "images"})
add_sourcefiles("(src/**)")
add_sourcefiles("xmake.lua")
set_iconfile("src/assets/xmake.ico")
add_components("LongPath")

Expand Down
23 changes: 23 additions & 0 deletions xmake/plugins/pack/srpm/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.semver")
import("core.base.hashset")
import("lib.detect.find_tool")
import("utils.archive")
import("private.action.require.impl.packagenv")
Expand Down Expand Up @@ -144,6 +145,28 @@ function _get_specvars(package)
_get_buildcmds(package, buildcmds, batchcmds.get_buildcmds(package):cmds())
return table.concat(buildcmds, "\n")
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)
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
return table.concat(requires, "\n")
end

return specvars
end
Expand Down
1 change: 1 addition & 0 deletions xmake/scripts/xpack/srpm/srpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Source0: ${PACKAGE_ARCHIVEFILE}

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

%description
${PACKAGE_DESCRIPTION}
Expand Down

0 comments on commit 4296189

Please sign in to comment.