diff options
| author | ruki <[email protected]> | 2019-03-16 00:42:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-15 22:17:14 +0800 |
| commit | e5c057bac9799f8b7f94a2f5f7d5c14a53b675e6 (patch) | |
| tree | c3aa40276cf3a0c25ff3c21fe1f751dc364a1f2b | |
| parent | db331ebb4595ec4380f24931163e55d587bed5b2 (diff) | |
add package references
| -rw-r--r-- | xmake/actions/require/info.lua | 15 | ||||
| -rw-r--r-- | xmake/actions/require/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/package/manager/xmake/find_package.lua | 9 |
4 files changed, 37 insertions, 1 deletions
diff --git a/xmake/actions/require/info.lua b/xmake/actions/require/info.lua index 5cbc81a23..d35f503cf 100644 --- a/xmake/actions/require/info.lua +++ b/xmake/actions/require/info.lua @@ -129,6 +129,12 @@ function main(package_names) end end + -- show repository + local repo = instance:repo() + if repo then + cprint(" -> ${magenta}repo${clear}: %s %s %s", repo:name(), repo:url(), repo:branch() or "") + end + -- show deps local deps = instance:orderdeps() if deps and #deps > 0 then @@ -226,6 +232,15 @@ function main(package_names) end end + -- show references + local references = instance:references() + if references then + cprint(" -> ${magenta}references${clear}:") + for projectdir, refdate in pairs(references) do + cprint(" -> %s: %s%s", refdate, projectdir, os.isdir(projectdir) and "" or " ${red}(not found)${clear}") + end + end + -- end print("") end diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua index c9cf9452f..06147576a 100644 --- a/xmake/actions/require/xmake.lua +++ b/xmake/actions/require/xmake.lua @@ -45,7 +45,7 @@ task("require") -- options , options = { - {'c', "clear", "k", nil, "Clear all installed package caches." } + {'c', "clean", "k", nil, "Clear all package caches and uninstall all not-referenced packages." } , {'f', "force", "k", nil, "Force to reinstall all package dependencies." } , {'l', "list", "k", nil, "List all package dependencies." } , { } diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 9589767ab..9d605d615 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -230,6 +230,18 @@ function _instance:installdir(...) return dir end +-- get the references info of this package +function _instance:references() + local references_file = path.join(self:installdir(), "references.txt") + if os.isfile(references_file) then + local references, errors = io.load(references_file) + if not references then + os.raise(errors) + end + return references + end +end + -- get the manifest file of this package function _instance:manifest_file() return path.join(self:installdir(), "manifest.txt") diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua index 915552257..1264e72a6 100644 --- a/xmake/modules/package/manager/xmake/find_package.lua +++ b/xmake/modules/package/manager/xmake/find_package.lua @@ -132,6 +132,15 @@ function _find_package_from_repo(name, opt) end end + -- update the project references file + local projectdir = os.projectdir() + if projectdir and os.isdir(projectdir) then + local references_file = path.join(installdir, "references.txt") + local references = os.isfile(references_file) and io.load(references_file) or {} + references[projectdir] = os.date("%y%m%d") + io.save(references_file, references) + end + -- get version result.version = manifest.version or path.filename(path.directory(path.directory(manifest_file))) return result |
