Skip to content

Commit

Permalink
benchmark: support more platform (#5732)
Browse files Browse the repository at this point in the history
* benchmark: support more platform

* add check
  • Loading branch information
star-hengxing authored Nov 11, 2024
1 parent 1eed70a commit 9e19731
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions packages/b/benchmark/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e19731

Please sign in to comment.