cpuinfo: add clog (#4191)

* cpuinfo: add clog

* improve on_check
pull/4194/head
star9029 6 months ago committed by GitHub
parent 2f6415728f
commit e4242b048a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      packages/c/cpuinfo/clog.lua
  2. 13
      packages/c/cpuinfo/xmake.lua

@ -0,0 +1,10 @@
function main(package)
os.cd("deps/clog")
local configs = {"-DCLOG_BUILD_TESTS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DCLOG_RUNTIME_TYPE=" .. (package:config("shared") and "shared" or "static"))
if package:config("shared") and package:is_plat("windows") then
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
end
import("package.tools.cmake").install(package, configs)
end

@ -10,6 +10,7 @@ package("cpuinfo")
if is_plat("windows") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end
add_configs("clog", {description = "Build clog library.", default = false, type = "boolean"})
add_deps("cmake")
if is_plat("windows") then
@ -18,12 +19,12 @@ package("cpuinfo")
add_syslinks("pthread")
end
on_check("windows|arm.*", function (package)
on_check("windows", function (package)
import("core.tool.toolchain")
import("core.base.semver")
local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()})
if msvc then
if msvc and package:is_arch("arm.*") then
local vs_sdkver = msvc:config("vs_sdkver")
assert(vs_sdkver and semver.match(vs_sdkver):gt("10.0.19041"), "package(cpuinfo): need vs_sdkver > 10.0.19041.0")
end
@ -57,6 +58,10 @@ package("cpuinfo")
end
end
import("package.tools.cmake").install(package, configs)
if package:config("clog") then
import("clog")(package)
end
end)
on_test(function (package)
@ -67,4 +72,8 @@ package("cpuinfo")
std::cout << "Running on CPU " << cpuinfo_get_package(0)->name;
}
]]}, {configs = {languages = "c++11"}, includes = "cpuinfo.h"}))
if package:config("clog") then
assert(package:has_cfuncs("clog_vlog_info", {includes = "clog.h"}))
end
end)

Loading…
Cancel
Save