From 9e19731fd3f055479d78b46221fbe68c6ed56924 Mon Sep 17 00:00:00 2001 From: star9029 Date: Tue, 12 Nov 2024 00:24:41 +0800 Subject: [PATCH] benchmark: support more platform (#5732) * benchmark: support more platform * add check --- packages/b/benchmark/xmake.lua | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/b/benchmark/xmake.lua b/packages/b/benchmark/xmake.lua index 1641c56f9..216039731 100644 --- a/packages/b/benchmark/xmake.lua +++ b/packages/b/benchmark/xmake.lua @@ -29,33 +29,47 @@ package("benchmark") add_extsources("brew::google-benchmark") end - if is_plat("linux") then + if is_plat("linux", "bsd") then add_syslinks("pthread") elseif is_plat("windows", "mingw") then add_syslinks("shlwapi") end - if is_plat("mingw") then - add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true}) - end + add_configs("exceptions", {description = "Enable exception", default = true, type = "boolean"}) add_deps("cmake") add_links("benchmark_main", "benchmark") - on_load("windows", function (package) + if on_check then + on_check("android", function (package) + if package:is_plat("android") and package:is_arch("armeabi-v7a") then + local ndk_sdkver = package:toolchain("ndk"):config("ndk_sdkver") + if ndk_sdkver and tonumber(ndk_sdkver) < 24 then + raise("package(benchmark) require ndk api >= 24") + end + end + end) + end + + on_load(function (package) if not package:config("shared") then package:add("defines", "BENCHMARK_STATIC_DEFINE") end end) - on_install("macosx", "linux", "windows", "mingw", function (package) - if package:is_plat("windows") then - os.mkdir(path.join(package:buildir(), "src/pdb")) - end - - local configs = {"-DBENCHMARK_ENABLE_TESTING=OFF", "-DBENCHMARK_INSTALL_DOCS=OFF"} + on_install(function (package) + local configs = { + "-DBENCHMARK_ENABLE_TESTING=OFF", + "-DBENCHMARK_INSTALL_DOCS=OFF", + "-DBENCHMARK_ENABLE_WERROR=OFF", + } table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DBENCHMARK_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF")) + table.insert(configs, "-DBENCHMARK_ENABLE_EXCEPTIONS=" .. (package:config("exceptions") and "ON" or "OFF")) + if package:is_plat("windows") then + table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''") + end import("package.tools.cmake").install(package, configs) if package:is_plat("windows") and package:is_debug() then