summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-01-15 20:56:05 +0800
committerruki <[email protected]>2022-01-15 20:56:05 +0800
commita6f9bfb2f9ab4a452766d7d75fc5c0908e0e5d94 (patch)
treeaecac3060fa71b9f9bc2268b04e4026611883bb2
parent909b14dd4774e651d778a575a0e99dcfdd22b41b (diff)
add --json for xrepo fetch
-rw-r--r--xmake/modules/private/action/require/fetch.lua3
-rw-r--r--xmake/modules/private/xrepo/action/fetch.lua4
2 files changed, 7 insertions, 0 deletions
diff --git a/xmake/modules/private/action/require/fetch.lua b/xmake/modules/private/action/require/fetch.lua
index e64b7f0b0..01a5bf5ab 100644
--- a/xmake/modules/private/action/require/fetch.lua
+++ b/xmake/modules/private/action/require/fetch.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.hashset")
+import("core.base.json")
import("core.project.project")
import("core.package.package", {alias = "core_package"})
import("core.tool.linker")
@@ -86,6 +87,8 @@ function main(requires_raw)
end
if #flags > 0 then
print(os.args(flags))
+ elseif fetchmodes and fetchmodes:has("json") then
+ print(json.encode(fetchinfos))
else
print(fetchinfos)
end
diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua
index 57e56c71b..d94d0d215 100644
--- a/xmake/modules/private/xrepo/action/fetch.lua
+++ b/xmake/modules/private/xrepo/action/fetch.lua
@@ -45,6 +45,7 @@ function menu_options()
{nil, "cflags", "k", nil, "Fetch cflags of the given packages." },
{nil, "ldflags", "k", nil, "Fetch ldflags of the given packages."},
{'e', "external", "k", nil, "Show cflags as external packages with -isystem."},
+ {nil, "json", "k", nil, "Output package info as json format." },
{},
{nil, "packages", "vs", nil, "The packages list.",
"e.g.",
@@ -139,6 +140,9 @@ function _fetch_packages(packages)
if option.get("external") then
table.insert(fetchmodes, "external")
end
+ if option.get("json") then
+ table.insert(fetchmodes, "json")
+ end
if #fetchmodes > 0 then
table.insert(require_argv, "--fetch_modes=" .. table.concat(fetchmodes, ','))
end