summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-06 20:59:07 +0800
committerruki <[email protected]>2021-03-06 20:59:07 +0800
commit30d9de30489ddd9bbf9b7db15a8c5625194710b9 (patch)
treed8d76934607d24d796b44dee925276da044bc57e /xmake/modules/package/tools/xmake.lua
parent5f3ed1310bf369c12d6fe0e3d93325f2a3f8b7f9 (diff)
improve tools/xmake
Diffstat (limited to 'xmake/modules/package/tools/xmake.lua')
-rw-r--r--xmake/modules/package/tools/xmake.lua20
1 files changed, 12 insertions, 8 deletions
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index e3df396de..e67952b52 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -92,9 +92,8 @@ function _get_configs(package, configs)
return configs
end
--- init arguments and inherit some global options from the parent xmake
-function _init_argv(package, ...)
- local argv = {...}
+-- set some builtin global options from the parent xmake
+function _set_builtin_argv(argv)
for _, name in ipairs({"diagnosis", "verbose", "quiet", "yes", "confirm", "root"}) do
local value = option.get(name)
if type(value) == "boolean" then
@@ -103,7 +102,6 @@ function _init_argv(package, ...)
table.insert(argv, "--" .. name .. "=" .. value)
end
end
- return argv
end
-- get require info of package
@@ -164,11 +162,15 @@ function install(package, configs, opt)
-- pass local repositories
opt = opt or {}
for _, repo in ipairs(repository.repositories()) do
- os.vrunv("xmake", {"repo", "--add", repo:name(), repo:url(), repo:branch()})
+ local repo_argv = {"repo"}
+ _set_builtin_argv(repo_argv)
+ table.join2(repo_argv, {"--add", repo:name(), repo:directory()})
+ os.vrunv("xmake", repo_argv)
end
-- pass configurations
- local argv = _init_argv(package, "f", "-y", "-c")
+ local argv = {"f", "-y", "-c"}
+ _set_builtin_argv(argv)
for name, value in pairs(_get_configs(package, configs)) do
value = tostring(value):trim()
if type(name) == "number" then
@@ -187,10 +189,12 @@ function install(package, configs, opt)
os.vrunv("xmake", argv, {envs = envs})
-- do build
- argv = _init_argv(package)
+ argv = {}
+ _set_builtin_argv(argv)
os.vrunv("xmake", argv, {envs = envs})
-- do install
- argv = _init_argv(package, "install", "-y", "-o", package:installdir())
+ argv = {"install", "-y", "-o", package:installdir()}
+ _set_builtin_argv(argv)
os.vrunv("xmake", argv, {envs = envs})
end