Explorar el Código

Add check support (#4010)

* Add check support

* check each packages

* add logs

* improve logs
ruki hace 1 año
padre
commit
d0a4451f59
Se han modificado 3 ficheros con 32 adiciones y 6 borrados
  1. 10 1
      packages/c/cpp-httplib/xmake.lua
  2. 5 3
      scripts/packages.lua
  3. 17 2
      scripts/test.lua

+ 10 - 1
packages/c/cpp-httplib/xmake.lua

@@ -19,7 +19,7 @@ package("cpp-httplib")
     add_versions("0.15.1", "8d6a4a40ee8fd3f553b7e895882e60e674bd910883fc1857587dbbabee3cdb91")
     add_versions("0.15.1", "8d6a4a40ee8fd3f553b7e895882e60e674bd910883fc1857587dbbabee3cdb91")
     add_versions("0.15.2", "4afbcf4203249d2cbcb698e46e1f6fb61b479013a84844d6bb1c044e233cab6a")
     add_versions("0.15.2", "4afbcf4203249d2cbcb698e46e1f6fb61b479013a84844d6bb1c044e233cab6a")
     add_versions("0.15.3", "2121bbf38871bb2aafb5f7f2b9b94705366170909f434428352187cb0216124e")
     add_versions("0.15.3", "2121bbf38871bb2aafb5f7f2b9b94705366170909f434428352187cb0216124e")
-    
+
     add_configs("ssl",  { description = "Requires OpenSSL", default = false, type = "boolean"})
     add_configs("ssl",  { description = "Requires OpenSSL", default = false, type = "boolean"})
     add_configs("zlib",  { description = "Requires Zlib", default = false, type = "boolean"})
     add_configs("zlib",  { description = "Requires Zlib", default = false, type = "boolean"})
     add_configs("brotli",  { description = "Requires Brotli", default = false, type = "boolean"})
     add_configs("brotli",  { description = "Requires Brotli", default = false, type = "boolean"})
@@ -42,6 +42,15 @@ package("cpp-httplib")
         end
         end
     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)
     on_install(function (package)
         if package:is_plat("android") then
         if package:is_plat("android") then
             import("core.tool.toolchain")
             import("core.tool.toolchain")

+ 5 - 3
scripts/packages.lua

@@ -11,10 +11,12 @@ function is_supported(instance, plat, arch, opt)
         return false
         return false
     end
     end
 
 
-    -- get script
+    -- has install script?
     local script = instance:get("install")
     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
 end
 
 
 -- load package
 -- load package

+ 17 - 2
scripts/test.lua

@@ -110,14 +110,17 @@ function _require_packages(argv, packages)
     end
     end
     os.vexecv("xmake", config_argv)
     os.vexecv("xmake", config_argv)
     local require_argv = {"require", "-f", "-y"}
     local require_argv = {"require", "-f", "-y"}
+    local check_argv = {"require", "-f", "-y", "--check"}
     if not argv.precompiled then
     if not argv.precompiled then
         table.insert(require_argv, "--build")
         table.insert(require_argv, "--build")
     end
     end
     if argv.verbose then
     if argv.verbose then
         table.insert(require_argv, "-v")
         table.insert(require_argv, "-v")
+        table.insert(check_argv, "-v")
     end
     end
     if argv.diagnosis then
     if argv.diagnosis then
         table.insert(require_argv, "-D")
         table.insert(require_argv, "-D")
+        table.insert(check_argv, "-D")
     end
     end
     local is_debug = false
     local is_debug = false
     if argv.debugdir then
     if argv.debugdir then
@@ -157,8 +160,20 @@ function _require_packages(argv, packages)
     end
     end
     local extra_str = string.serialize(extra, {indent = false, strip = true})
     local extra_str = string.serialize(extra, {indent = false, strip = true})
     table.insert(require_argv, "--extra=" .. extra_str)
     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
 end
 
 
 -- the given package is supported?
 -- the given package is supported?