Browse Source

cpuinfo: add clog (#4191)

* cpuinfo: add clog

* improve on_check
star9029 1 year ago
parent
commit
e4242b048a
2 changed files with 21 additions and 2 deletions
  1. 10 0
      packages/c/cpuinfo/clog.lua
  2. 11 2
      packages/c/cpuinfo/xmake.lua

+ 10 - 0
packages/c/cpuinfo/clog.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

+ 11 - 2
packages/c/cpuinfo/xmake.lua

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