From d0a4451f59a134d3a9c6b43fbf20758548e8fd06 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 11 May 2024 11:46:39 +0800 Subject: [PATCH] Add check support (#4010) * Add check support * check each packages * add logs * improve logs --- packages/c/cpp-httplib/xmake.lua | 11 ++++++++++- scripts/packages.lua | 8 +++++--- scripts/test.lua | 19 +++++++++++++++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/c/cpp-httplib/xmake.lua b/packages/c/cpp-httplib/xmake.lua index 17a591f7f..7496eb217 100644 --- a/packages/c/cpp-httplib/xmake.lua +++ b/packages/c/cpp-httplib/xmake.lua @@ -19,7 +19,7 @@ package("cpp-httplib") add_versions("0.15.1", "8d6a4a40ee8fd3f553b7e895882e60e674bd910883fc1857587dbbabee3cdb91") add_versions("0.15.2", "4afbcf4203249d2cbcb698e46e1f6fb61b479013a84844d6bb1c044e233cab6a") add_versions("0.15.3", "2121bbf38871bb2aafb5f7f2b9b94705366170909f434428352187cb0216124e") - + add_configs("ssl", { description = "Requires OpenSSL", default = false, type = "boolean"}) add_configs("zlib", { description = "Requires Zlib", default = false, type = "boolean"}) add_configs("brotli", { description = "Requires Brotli", default = false, type = "boolean"}) @@ -42,6 +42,15 @@ package("cpp-httplib") end end) + if on_check then + on_check("android", function (package) + import("core.tool.toolchain") + local ndk = toolchain.load("ndk", {plat = package:plat(), arch = package:arch()}) + local ndk_sdkver = ndk:config("ndk_sdkver") + assert(ndk_sdkver and tonumber(ndk_sdkver) >= 24, "package(httplib): need ndk api level >= 24 for android") + end) + end + on_install(function (package) if package:is_plat("android") then import("core.tool.toolchain") diff --git a/scripts/packages.lua b/scripts/packages.lua index dc6c6b470..1b9b1ce03 100644 --- a/scripts/packages.lua +++ b/scripts/packages.lua @@ -11,10 +11,12 @@ function is_supported(instance, plat, arch, opt) return false end - -- get script + -- has install script? local script = instance:get("install") - local result = select_script(script, {plat = plat, arch = arch}) - return result + if not select_script(script, {plat = plat, arch = arch}) then + return false + end + return true end -- load package diff --git a/scripts/test.lua b/scripts/test.lua index a3b04ea81..2020c5d74 100644 --- a/scripts/test.lua +++ b/scripts/test.lua @@ -110,14 +110,17 @@ function _require_packages(argv, packages) end os.vexecv("xmake", config_argv) local require_argv = {"require", "-f", "-y"} + local check_argv = {"require", "-f", "-y", "--check"} if not argv.precompiled then table.insert(require_argv, "--build") end if argv.verbose then table.insert(require_argv, "-v") + table.insert(check_argv, "-v") end if argv.diagnosis then table.insert(require_argv, "-D") + table.insert(check_argv, "-D") end local is_debug = false if argv.debugdir then @@ -157,8 +160,20 @@ function _require_packages(argv, packages) end local extra_str = string.serialize(extra, {indent = false, strip = true}) table.insert(require_argv, "--extra=" .. extra_str) - table.join2(require_argv, packages) - os.vexecv("xmake", require_argv) + table.insert(check_argv, "--extra=" .. extra_str) + + local install_packages = {} + for _, package in ipairs(packages) do + local ok = os.vexecv("xmake", table.join(check_argv, package), {try = true}) + if ok == 0 then + table.insert(install_packages, package) + end + end + if #install_packages > 0 then + os.vexecv("xmake", 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()) + end end -- the given package is supported?