summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-19 22:58:13 +0800
committerruki <[email protected]>2024-07-19 22:58:13 +0800
commit835d8e7bc6e5488c5e9fcb88b8fa56f4f4694e38 (patch)
tree5b200030e5a34791738dcacaa1b8f8b2ddf69f66
parent5169dfdf8677bad2aaf1b74b73176578f8b390af (diff)
fix os.rm and uninstall modules
-rw-r--r--xmake/core/sandbox/modules/os.lua16
-rw-r--r--xmake/rules/c++/modules/modules_support/compiler_support.lua2
-rw-r--r--xmake/rules/c++/modules/xmake.lua9
3 files changed, 17 insertions, 10 deletions
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 9004f66ee..d626d0372 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -102,21 +102,21 @@ function sandbox_os.cp(srcpath, dstpath, opt)
end
-- move file or directory
-function sandbox_os.mv(srcpath, dstpath)
+function sandbox_os.mv(srcpath, dstpath, opt)
assert(srcpath and dstpath)
srcpath = tostring(srcpath)
dstpath = tostring(dstpath)
- local ok, errors = os.mv(vformat(srcpath), vformat(dstpath))
+ local ok, errors = os.mv(vformat(srcpath), vformat(dstpath), opt)
if not ok then
os.raise(errors)
end
end
-- remove files or directories
-function sandbox_os.rm(filepath)
+function sandbox_os.rm(filepath, opt)
assert(filepath)
filepath = tostring(filepath)
- local ok, errors = os.rm(vformat(filepath))
+ local ok, errors = os.rm(vformat(filepath), opt)
if not ok then
os.raise(errors)
end
@@ -161,12 +161,12 @@ function sandbox_os.vrm(filepath, opt)
end
-- link file or directory with the verbose info
-function sandbox_os.vln(srcpath, dstpath)
+function sandbox_os.vln(srcpath, dstpath, opt)
assert(srcpath and dstpath)
if option.get("verbose") then
utils.cprint("${dim}> link %s to %s", srcpath, dstpath)
end
- return sandbox_os.ln(srcpath, dstpath)
+ return sandbox_os.ln(srcpath, dstpath, opt)
end
-- try to copy file or directory
@@ -176,9 +176,9 @@ function sandbox_os.trycp(srcpath, dstpath, opt)
end
-- try to move file or directory
-function sandbox_os.trymv(srcpath, dstpath)
+function sandbox_os.trymv(srcpath, dstpath, opt)
assert(srcpath and dstpath)
- return os.mv(vformat(srcpath), vformat(dstpath))
+ return os.mv(vformat(srcpath), vformat(dstpath), opt)
end
-- try to remove files or directories
diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/modules_support/compiler_support.lua
index 72e7b93fd..a005dc80d 100644
--- a/xmake/rules/c++/modules/modules_support/compiler_support.lua
+++ b/xmake/rules/c++/modules/modules_support/compiler_support.lua
@@ -293,7 +293,7 @@ function get_provided_module(module)
return name, provide, cppfile
end
-function install_module_target(target)
+function add_installfiles_for_modules(target)
local sourcebatch = target:sourcebatches()["c++.build.modules.install"]
if sourcebatch and sourcebatch.sourcefiles then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index 90ba66c81..d658815aa 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -227,6 +227,13 @@ rule("c++.build.modules.install")
local modules = compiler_support.localcache():get2(target:name(), "c++.modules")
builder.generate_metadata(target, modules)
- compiler_support.install_module_target(target)
+ compiler_support.add_installfiles_for_modules(target)
+ end
+ end)
+
+ before_uninstall(function (target)
+ import("modules_support.compiler_support")
+ if compiler_support.contains_modules(target) then
+ compiler_support.add_installfiles_for_modules(target)
end
end)