improve mimalloc (#166)

* improve mimalloc

* fix install
pull/171/head
yecate 4 years ago committed by GitHub
parent 952def7f80
commit 16a681b734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      packages/m/mimalloc/xmake.lua

@ -2,9 +2,9 @@ package("mimalloc")
set_homepage("https://github.com/microsoft/mimalloc")
set_description("mimalloc (pronounced 'me-malloc') is a general purpose allocator with excellent performance characteristics.")
set_license("MIT")
set_urls("https://github.com/microsoft/mimalloc/archive/v$(version).zip")
add_versions("1.6.7", "5a12aac020650876615a2ce3dd8adc8b208cdcee4d9e6bcfc33b3fbe307f0dbf")
add_configs("secure", {description = "Use a secured version of mimalloc", default = false, type = "boolean"})
@ -12,28 +12,36 @@ package("mimalloc")
add_deps("cmake")
if is_plat("windows") then
add_syslinks("advapi32")
add_syslinks("advapi32", "bcrypt")
elseif is_plat("linux") then
add_syslinks("pthread")
elseif is_plat("android") then
add_syslinks("atomic")
end
on_install("macosx", "windows", "linux", function (package)
on_install("macosx", "windows", "linux", "android", function (package)
local configs = {"-DMI_OVERRIDE=OFF"}
table.insert(configs, "-DMI_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
table.insert(configs, "-DMI_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DMI_SECURE=" .. (package:config("secure") and "ON" or "OFF"))
table.insert(configs, "-DMI_BUILD_TESTS=OFF")
table.insert(configs, "-DMI_BUILD_OBJECT=OFF")
import("package.tools.cmake").install(package, configs, {buildir = "build"})
os.cp(path.join("build", package:debug() and "Debug" or "Release", "*"), package:installdir("lib"))
os.cp(path.join("build", "*.a"), package:installdir("lib"))
os.cp("include/mimalloc.h", package:installdir("include"), {rootdir = "include"})
os.cp("include/mimalloc-new-delete.h", package:installdir("include"), {rootdir = "include"})
os.cp("include/mimalloc-override.h", package:installdir("include"), {rootdir = "include"})
--x64:mimalloc-redirect.lib/dll x86:mimalloc-redirect32.lib/dll
if package:config("shared") and package:is_plat("windows") and package:is_arch("x86") then
io.gsub("CMakeLists.txt", "-redirect", "-redirect32")
end
import("package.tools.cmake").build(package, configs, {buildir = "build"})
if package:is_plat("windows") then
os.trycp("build/**.dll", package:installdir("bin"))
os.trycp("build/**.lib", package:installdir("lib"))
else
os.trycp("build/*.so", package:installdir("lib"))
os.trycp("build/*.a", package:installdir("lib"))
end
os.cp("include", package:installdir())
end)
on_test(function (package)
assert(package:has_cfuncs("mi_malloc", {includes = "mimalloc.h"}))
end)
on_test(function (package)
assert(package:has_cfuncs("mi_malloc", {includes = "mimalloc.h"}))
end)
Loading…
Cancel
Save