diff options
| author | ruki <[email protected]> | 2020-10-24 21:05:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-24 21:05:26 +0800 |
| commit | 9615bc9e463084033a3e8d5d5cca101140e261a3 (patch) | |
| tree | 5cea10b74c68092cf6a9946896efb9596b7bbc7c | |
| parent | 02e22fee1e166b95778c51d7322591905bb6ad9d (diff) | |
add clean packages
| -rw-r--r-- | xmake/modules/private/xrepo/action/clean.lua | 99 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/export.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/fetch.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/info.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/list-repo.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/rm-repo.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/search.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/update-repo.lua | 2 |
8 files changed, 106 insertions, 7 deletions
diff --git a/xmake/modules/private/xrepo/action/clean.lua b/xmake/modules/private/xrepo/action/clean.lua new file mode 100644 index 000000000..c02d9c200 --- /dev/null +++ b/xmake/modules/private/xrepo/action/clean.lua @@ -0,0 +1,99 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file clean.lua +-- + +-- imports +import("core.base.option") + +-- get menu options +function menu_options() + + -- description + local description = "Clear all package caches and remove all not-referenced packages." + + -- menu options + local options = + { + {nil, "packages", "vs", nil, "The packages list (support lua pattern).", + "e.g.", + " - xrepo clean", + " - xrepo clean zlib", + " - xrepo clean zlib bo*"} + } + + -- show menu options + local function show_options() + + -- show usage + cprint("${bright}Usage: $${clear cyan}xrepo clean [options] [packages]") + + -- show description + print("") + print(description) + + -- show options + option.show_options(options, "clean") + end + return options, show_options, description +end + +-- clean packages +function _clean_packages(packages) + + -- enter working project directory + local workdir = path.join(os.tmpdir(), "xrepo", "working") + if not os.isdir(workdir) then + os.mkdir(workdir) + os.cd(workdir) + os.vrunv("xmake", {"create", "-P", "."}) + else + os.cd(workdir) + end + + -- do configure first + local config_argv = {"f", "-c"} + if option.get("verbose") then + table.insert(config_argv, "-v") + end + if option.get("diagnosis") then + table.insert(config_argv, "-D") + end + os.vrunv("xmake", config_argv) + + -- do clean + local require_argv = {"require", "--clean"} + if option.get("yes") then + table.insert(require_argv, "-y") + end + if option.get("verbose") then + table.insert(require_argv, "-v") + end + if option.get("diagnosis") then + table.insert(require_argv, "-D") + end + if packages then + table.join2(require_argv, packages) + end + os.vexecv("xmake", require_argv) +end + +-- main entry +function main() + _clean_packages(option.get("packages")) +end diff --git a/xmake/modules/private/xrepo/action/export.lua b/xmake/modules/private/xrepo/action/export.lua index 5405b70e9..c9fd20a99 100644 --- a/xmake/modules/private/xrepo/action/export.lua +++ b/xmake/modules/private/xrepo/action/export.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "export the given packages." + local description = "Export the given packages." -- menu options local options = diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua index 503c09e15..6b79928ad 100644 --- a/xmake/modules/private/xrepo/action/fetch.lua +++ b/xmake/modules/private/xrepo/action/fetch.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "fetch library information of the given installed packages." + local description = "Fetch library information of the given installed packages." -- menu options local options = diff --git a/xmake/modules/private/xrepo/action/info.lua b/xmake/modules/private/xrepo/action/info.lua index 52333e14f..cd34c2add 100644 --- a/xmake/modules/private/xrepo/action/info.lua +++ b/xmake/modules/private/xrepo/action/info.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "show information of the given packages." + local description = "Show information of the given packages." -- menu options local options = diff --git a/xmake/modules/private/xrepo/action/list-repo.lua b/xmake/modules/private/xrepo/action/list-repo.lua index 27858be9c..a8c2ced44 100644 --- a/xmake/modules/private/xrepo/action/list-repo.lua +++ b/xmake/modules/private/xrepo/action/list-repo.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "list all remote repositories." + local description = "List all remote repositories." -- menu options local options = {} diff --git a/xmake/modules/private/xrepo/action/rm-repo.lua b/xmake/modules/private/xrepo/action/rm-repo.lua index bbb1c0ebb..2b17d5a2d 100644 --- a/xmake/modules/private/xrepo/action/rm-repo.lua +++ b/xmake/modules/private/xrepo/action/rm-repo.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "remove the given remote repository." + local description = "Remove the given remote repository." -- menu options local options = diff --git a/xmake/modules/private/xrepo/action/search.lua b/xmake/modules/private/xrepo/action/search.lua index c19b6c9ed..5b4521afe 100644 --- a/xmake/modules/private/xrepo/action/search.lua +++ b/xmake/modules/private/xrepo/action/search.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "search the given packages." + local description = "Search the given packages." -- menu options local options = diff --git a/xmake/modules/private/xrepo/action/update-repo.lua b/xmake/modules/private/xrepo/action/update-repo.lua index 073522535..e27d528f5 100644 --- a/xmake/modules/private/xrepo/action/update-repo.lua +++ b/xmake/modules/private/xrepo/action/update-repo.lua @@ -25,7 +25,7 @@ import("core.base.option") function menu_options() -- description - local description = "update all local repositories from remote." + local description = "Update all local repositories from remote." -- menu options local options = {} |
