diff options
| author | ruki <[email protected]> | 2023-02-11 19:39:17 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-11 19:39:17 +0800 |
| commit | 5239207aa34a2d89501f298e21c298c92a7b0e45 (patch) | |
| tree | 095371b5abaeff256e861c84a842067235294c41 | |
| parent | c34ac1c6921f5a52eb9721fcc77725eac9217450 (diff) | |
add xrepo clean --cache
| -rw-r--r-- | xmake/actions/require/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/clean.lua | 30 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/clean.lua | 4 |
3 files changed, 26 insertions, 11 deletions
diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua index 150bba51f..527fd03c8 100644 --- a/xmake/actions/require/xmake.lua +++ b/xmake/actions/require/xmake.lua @@ -45,6 +45,9 @@ task("require") "e.g.", " $ xmake require --clean", " $ xmake require --clean zlib tbox pcr*" } + , {nil, "clean_modes","kv", nil, "Set the modes of cleaning packages.", + "e.g.", + " $ xmake require --clean --clean_modes=cache,package" } , {'f', "force", "k", nil, "Force to reinstall all package dependencies." } , {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs." } diff --git a/xmake/modules/private/action/require/clean.lua b/xmake/modules/private/action/require/clean.lua index 57b549810..d7eae0f31 100644 --- a/xmake/modules/private/action/require/clean.lua +++ b/xmake/modules/private/action/require/clean.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.hashset") import("core.package.package") import("core.cache.localcache") import("private.action.require.impl.remove_packages") @@ -27,21 +28,28 @@ import("private.action.require.impl.remove_packages") -- clean the given or all package caches function main(package_names) - -- trace - print("clearing packages ..") + local clean_modes = option.get("clean_modes") + if clean_modes then + clean_modes = hashset.from(clean_modes:split(",")) + else + clean_modes = hashset.of("cache", "package") + end -- clear all unused packages - remove_packages(package_names, {clean = true}) - - -- trace - print("clearing caches ..") + if clean_modes:has("package") then + print("clearing packages ..") + remove_packages(package_names, {clean = true}) + end -- clear cache directory - os.rm(package.cachedir()) + if clean_modes:has("cache") then + print("clearing caches ..") + os.rm(package.cachedir()) - -- clear require cache - local require_cache = localcache.cache("package") - require_cache:clear() - require_cache:save() + -- clear require cache + local require_cache = localcache.cache("package") + require_cache:clear() + require_cache:save() + end end diff --git a/xmake/modules/private/xrepo/action/clean.lua b/xmake/modules/private/xrepo/action/clean.lua index efc1ed6a4..25e44db39 100644 --- a/xmake/modules/private/xrepo/action/clean.lua +++ b/xmake/modules/private/xrepo/action/clean.lua @@ -30,6 +30,7 @@ function menu_options() -- menu options local options = { + {nil, "cache", "k", nil, "Just clean packages cache."}, {nil, "packages", "vs", nil, "The packages list (support lua pattern).", "e.g.", " - xrepo clean", @@ -84,6 +85,9 @@ function _clean_packages(packages) if option.get("diagnosis") then table.insert(require_argv, "-D") end + if option.get("cache") then + table.insert(require_argv, "--clean_modes=cache") + end if packages then table.join2(require_argv, packages) end |
