Skip to content

Commit

Permalink
pack xmake install to srpm
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 21, 2023
1 parent 17733b5 commit 6417898
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/xpack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ xpack("xmakesrc")
if format == "runself" then
batchcmds:runv("./scripts/get.sh", {"__local__"})
elseif format == "srpm" then
batchcmds:runv("make", {"install", "PREFIX=%{buildroot}"})
batchcmds:runv("make", {"install", path(package:install_rootdir(), function (p) return "PREFIX=" .. p end)})
end
end)
25 changes: 19 additions & 6 deletions xmake/plugins/pack/batchcmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ function _on_target_installcmd_headeronly(target, batchcmds_, opt)
_install_headers(target, batchcmds_, includedir)
end

-- on install source target command
function _on_target_installcmd_source(target, batchcmds_, opt)
local package = opt.package
batchcmds_:vrunv("xmake", {"install", "-o", path(package:install_rootdir()), target:name()})
end

-- on build target command
function _on_target_buildcmd(target, batchcmds_, opt)
local package = opt.package
Expand All @@ -192,6 +198,10 @@ end
-- on install target command
function _on_target_installcmd(target, batchcmds_, opt)
local package = opt.package
if package:from_source() then
_on_target_installcmd_source(target, batchcmds_, opt)
return
end

-- install target binaries
local scripts = {
Expand Down Expand Up @@ -278,9 +288,18 @@ function _on_target_uninstallcmd_headeronly(target, batchcmds_, opt)
_uninstall_headers(target, batchcmds_, includedir)
end

-- on uninstall source target command
function _on_target_uninstallcmd_source(target, batchcmds_, opt)
-- TODO
end

-- on uninstall target command
function _on_target_uninstallcmd(target, batchcmds_, opt)
local package = opt.package
if package:from_source() then
_on_target_uninstallcmd_source(target, batchcmds_, opt)
return
end

-- uninstall target binaries
local scripts = {
Expand Down Expand Up @@ -412,9 +431,6 @@ end

-- on install command
function _on_installcmd(package, batchcmds_)
if not package:from_binary() then
return
end
local srcfiles, dstfiles = package:installfiles()
for idx, srcfile in ipairs(srcfiles) do
batchcmds_:cp(srcfile, dstfiles[idx])
Expand All @@ -426,9 +442,6 @@ end

-- on uninstall command
function _on_uninstallcmd(package, batchcmds_)
if not package:from_binary() then
return
end
local _, dstfiles = package:installfiles()
for _, dstfile in ipairs(dstfiles) do
batchcmds_:rm(dstfile, {emptydirs = true})
Expand Down
1 change: 1 addition & 0 deletions xmake/plugins/pack/srpm/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function _get_customcmd(package, installcmds, cmd)
local dir = _translate_filepath(package, cmd.dir)
table.insert(installcmds, string.format("mkdir -p \"%s\"", dir))
elseif cmd.program then
-- TODO translate path
table.insert(installcmds, string.format("%s", os.args(table.join(cmd.program, cmd.argv))))
end
end
Expand Down

0 comments on commit 6417898

Please sign in to comment.