summaryrefslogtreecommitdiff
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
parent5f3ed1310bf369c12d6fe0e3d93325f2a3f8b7f9 (diff)
improve tools/xmake
-rw-r--r--xmake/core/package/repository.lua2
-rw-r--r--xmake/modules/package/tools/xmake.lua20
2 files changed, 13 insertions, 9 deletions
diff --git a/xmake/core/package/repository.lua b/xmake/core/package/repository.lua
index 736517d00..6485b426f 100644
--- a/xmake/core/package/repository.lua
+++ b/xmake/core/package/repository.lua
@@ -184,7 +184,7 @@ function repository.load(name, url, branch, is_global)
end
-- the repository directory
- local repodir = os.isdir(url) and url or path.join(repository.directory(is_global), name)
+ local repodir = os.isdir(url) and path.absolute(url) or path.join(repository.directory(is_global), name)
-- new an instance
local instance, errors = _instance.new(name, url, branch, repodir, is_global)
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