summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-08 22:48:05 +0800
committerruki <[email protected]>2024-11-08 22:48:05 +0800
commit0e8dbee986b542012984b5cccb453d5f06e684b5 (patch)
tree27c341dd07a32b7c1f2964850dacbe6c47efb48c /xmake/modules
parentc2b956073bfd299974e42cdf708c436ffa7775d3 (diff)
improve to package target #5796
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/target/action/install/main.lua12
-rw-r--r--xmake/modules/target/action/uninstall/main.lua12
2 files changed, 20 insertions, 4 deletions
diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua
index 5ac99278c..48e97e4cc 100644
--- a/xmake/modules/target/action/install/main.lua
+++ b/xmake/modules/target/action/install/main.lua
@@ -41,6 +41,14 @@ function _get_target_bindir(target, opt)
return path.join(opt.installdir, opt.bindir)
end
+function _get_target_includedir(target, opt)
+ if not opt.installdir then
+ return target:includedir()
+ end
+ assert(opt.includedir, "opt.includedir is missing")
+ return path.join(opt.installdir, opt.includedir)
+end
+
-- we need to get all deplibs, e.g. app -> libfoo.so -> libbar.so ...
-- @see https://github.com/xmake-io/xmake/issues/5325#issuecomment-2242597732
function _get_target_package_deplibs(binaryfile, depends, libfiles, opt)
@@ -147,14 +155,14 @@ end
-- install headers
function _install_headers(target, opt)
- local srcheaders, dstheaders = target:headerfiles(target:includedir(), {installonly = true})
+ local srcheaders, dstheaders = target:headerfiles(_get_target_includedir(target, opt), {installonly = true})
if srcheaders and dstheaders then
for idx, srcheader in ipairs(srcheaders) do
os.vcp(srcheader, dstheaders[idx])
end
end
for _, dep in ipairs(target:orderdeps()) do
- local srcfiles, dstfiles = dep:headerfiles(dep:includedir(), {installonly = true, interface = true})
+ local srcfiles, dstfiles = dep:headerfiles(_get_target_includedir(dep, opt), {installonly = true, interface = true})
if srcfiles and dstfiles then
for idx, srcfile in ipairs(srcfiles) do
os.vcp(srcfile, dstfiles[idx])
diff --git a/xmake/modules/target/action/uninstall/main.lua b/xmake/modules/target/action/uninstall/main.lua
index c4228f23c..d095f0aee 100644
--- a/xmake/modules/target/action/uninstall/main.lua
+++ b/xmake/modules/target/action/uninstall/main.lua
@@ -41,6 +41,14 @@ function _get_target_bindir(target, opt)
return path.join(opt.installdir, opt.bindir)
end
+function _get_target_includedir(target, opt)
+ if not opt.installdir then
+ return target:includedir()
+ end
+ assert(opt.includedir, "opt.includedir is missing")
+ return path.join(opt.installdir, opt.includedir)
+end
+
-- we need to get all deplibs, e.g. app -> libfoo.so -> libbar.so ...
-- @see https://github.com/xmake-io/xmake/issues/5325#issuecomment-2242597732
function _get_target_package_deplibs(binaryfile, depends, libfiles, opt)
@@ -141,12 +149,12 @@ end
-- uninstall headers
function _uninstall_headers(target, opt)
- local _, dstheaders = target:headerfiles(target:includedir(), {installonly = true})
+ local _, dstheaders = target:headerfiles(_get_target_includedir(target, opt), {installonly = true})
for _, dstheader in ipairs(dstheaders) do
remove_files(dstheader, {emptydir = true})
end
for _, dep in ipairs(target:orderdeps()) do
- local _, dstfiles = dep:headerfiles(dep:includedir(), {installonly = true, interface = true})
+ local _, dstfiles = dep:headerfiles(_get_target_includedir(dep, opt), {installonly = true, interface = true})
for _, dstfile in ipairs(dstfiles) do
remove_files(dstfile, {emptydir = true})
end