diff options
| author | ruki <[email protected]> | 2023-12-21 23:04:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-12-21 23:04:56 +0800 |
| commit | 4296189fb104b1632c939b6bdef5cf86f610fd40 (patch) | |
| tree | 78ce07417d9412fef8abd43bdd1e375da34c9d84 | |
| parent | 1976625c2296c156511922d6792df6f2da8a1b23 (diff) | |
add build requires
| -rw-r--r-- | tests/plugins/pack/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/plugins/pack/srpm/main.lua | 23 | ||||
| -rw-r--r-- | xmake/scripts/xpack/srpm/srpm.spec | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index abf67234c..fc45c7fad 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -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") diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua index a65f3b4f6..949b99516 100644 --- a/xmake/plugins/pack/srpm/main.lua +++ b/xmake/plugins/pack/srpm/main.lua @@ -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") @@ -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 diff --git a/xmake/scripts/xpack/srpm/srpm.spec b/xmake/scripts/xpack/srpm/srpm.spec index d32052900..778afcfb0 100644 --- a/xmake/scripts/xpack/srpm/srpm.spec +++ b/xmake/scripts/xpack/srpm/srpm.spec @@ -15,6 +15,7 @@ Source0: ${PACKAGE_ARCHIVEFILE} BuildRequires: gcc BuildRequires: gcc-c++ +${PACKAGE_BUILDREQUIRES} %description ${PACKAGE_DESCRIPTION} |
