|
@@ -53,8 +53,8 @@ function _check_package_is_supported()
|
|
|
end
|
|
|
end
|
|
|
|
|
|
--- require packages
|
|
|
-function _require_packages(argv, packages)
|
|
|
+-- config packages
|
|
|
+function _config_packages(argv, packages)
|
|
|
local config_argv = {"f", "-c"}
|
|
|
if argv.verbose then
|
|
|
table.insert(config_argv, "-v")
|
|
@@ -128,6 +128,56 @@ function _require_packages(argv, packages)
|
|
|
table.insert(config_argv, "--ldflags=" .. argv.ldflags)
|
|
|
end
|
|
|
os.vexecv(os.programfile(), config_argv)
|
|
|
+end
|
|
|
+
|
|
|
+-- get extra string
|
|
|
+function _get_extra_str(argv)
|
|
|
+ local extra = {}
|
|
|
+ if argv.mode == "debug" then
|
|
|
+ extra.debug = true
|
|
|
+ end
|
|
|
+ -- Some packages set shared=true as default, so we need to force set
|
|
|
+ -- shared=false to test static build.
|
|
|
+ extra.configs = extra.configs or {}
|
|
|
+ extra.configs.shared = argv.kind == "shared"
|
|
|
+ local configs = argv.configs
|
|
|
+ if configs then
|
|
|
+ extra.system = false
|
|
|
+ extra.configs = extra.configs or {}
|
|
|
+ local extra_configs, errors = ("{" .. configs .. "}"):deserialize()
|
|
|
+ if extra_configs then
|
|
|
+ table.join2(extra.configs, extra_configs)
|
|
|
+ else
|
|
|
+ raise(errors)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ return string.serialize(extra, {indent = false, strip = true})
|
|
|
+end
|
|
|
+
|
|
|
+-- load packages
|
|
|
+function _load_packages(argv, packages)
|
|
|
+ _config_packages(argv, packages)
|
|
|
+ local info_argv = {"require", "-f", "-y", "--info"}
|
|
|
+ if argv.verbose then
|
|
|
+ table.insert(info_argv, "-v")
|
|
|
+ end
|
|
|
+ if argv.diagnosis then
|
|
|
+ table.insert(info_argv, "-D")
|
|
|
+ end
|
|
|
+ local extra_str = _get_extra_str(argv)
|
|
|
+ table.insert(info_argv, "--extra=" .. extra_str)
|
|
|
+
|
|
|
+ -- call `xrepo info` to test on_load
|
|
|
+ if #packages > 0 then
|
|
|
+ print("testing to load packages ...")
|
|
|
+ print(" > if it causes errors, please remove assert/raise() to on_check.")
|
|
|
+ os.vexecv(os.programfile(), table.join(info_argv, packages))
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+-- require packages
|
|
|
+function _require_packages(argv, packages)
|
|
|
+ _config_packages(argv, packages)
|
|
|
local require_argv = {"require", "-f", "-y"}
|
|
|
local check_argv = {"require", "-f", "-y", "--check"}
|
|
|
if not argv.precompiled then
|
|
@@ -158,31 +208,14 @@ function _require_packages(argv, packages)
|
|
|
if argv.fetch then
|
|
|
table.insert(require_argv, "--fetch")
|
|
|
end
|
|
|
- local extra = {}
|
|
|
- if argv.mode == "debug" then
|
|
|
- extra.debug = true
|
|
|
- end
|
|
|
- -- Some packages set shared=true as default, so we need to force set
|
|
|
- -- shared=false to test static build.
|
|
|
- extra.configs = extra.configs or {}
|
|
|
- extra.configs.shared = argv.kind == "shared"
|
|
|
- local configs = argv.configs
|
|
|
- if configs then
|
|
|
- extra.system = false
|
|
|
- extra.configs = extra.configs or {}
|
|
|
- local extra_configs, errors = ("{" .. configs .. "}"):deserialize()
|
|
|
- if extra_configs then
|
|
|
- table.join2(extra.configs, extra_configs)
|
|
|
- else
|
|
|
- raise(errors)
|
|
|
- end
|
|
|
- end
|
|
|
- local extra_str = string.serialize(extra, {indent = false, strip = true})
|
|
|
+ local extra_str = _get_extra_str(argv)
|
|
|
table.insert(require_argv, "--extra=" .. extra_str)
|
|
|
table.insert(check_argv, "--extra=" .. extra_str)
|
|
|
|
|
|
+ -- test on_check
|
|
|
local install_packages = {}
|
|
|
if _check_package_is_supported() then
|
|
|
+ print("testing to check packages ...")
|
|
|
for _, package in ipairs(packages) do
|
|
|
local ok = os.vexecv(os.programfile(), table.join(check_argv, package), {try = true})
|
|
|
if ok == 0 then
|
|
@@ -192,7 +225,10 @@ function _require_packages(argv, packages)
|
|
|
else
|
|
|
install_packages = packages
|
|
|
end
|
|
|
+
|
|
|
+ -- test installation
|
|
|
if #install_packages > 0 then
|
|
|
+ print("testing to install packages ...")
|
|
|
os.vexecv(os.programfile(), table.join(require_argv, install_packages))
|
|
|
else
|
|
|
print("no testable packages on %s or you're using lower version xmake!", argv.plat or os.subhost())
|
|
@@ -215,6 +251,7 @@ function _package_is_supported(argv, packagename)
|
|
|
arch = os.subarch()
|
|
|
end
|
|
|
for _, package_arch in ipairs(package.archs) do
|
|
|
+ print(package_arch, package.archs)
|
|
|
if arch == package_arch then
|
|
|
return true
|
|
|
end
|
|
@@ -266,6 +303,7 @@ function main(...)
|
|
|
end
|
|
|
|
|
|
-- remove unsupported packages
|
|
|
+ local packages_original = table.clone(packages)
|
|
|
for idx, package in irpairs(packages) do
|
|
|
assert(package == package:lower(), "package(%s) must be lower case!", package)
|
|
|
if not _package_is_supported(argv, package) then
|
|
@@ -305,9 +343,15 @@ function main(...)
|
|
|
os.execv(os.programfile(), {"repo", "--add", "local-repo", repodir})
|
|
|
os.execv(os.programfile(), {"repo", "-l"})
|
|
|
|
|
|
+ -- load packages
|
|
|
+ _load_packages(argv, packages_original)
|
|
|
+
|
|
|
+ -- no unsupported packages
|
|
|
+ if #packages == 0 then
|
|
|
+ print("no testable packages on %s!", argv.plat or os.subhost())
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
-- require packages
|
|
|
_require_packages(argv, packages)
|
|
|
- --[[for _, package in ipairs(packages) do
|
|
|
- _require_packages(argv, package)
|
|
|
- end]]
|
|
|
end
|