add mimalloc
This commit is contained in:
parent
fdcb5b70ff
commit
47243a120f
@ -1,33 +0,0 @@
|
|||||||
package("mimalloc-cmake")
|
|
||||||
set_homepage("https://github.com/microsoft/mimalloc")
|
|
||||||
set_description("A general purpose allocator with high performance and small memory footprint")
|
|
||||||
add_versions("2.1.7", "...")
|
|
||||||
add_configs("secure", {description = "Use a secured version of mimalloc", default = false, type = "boolean"})
|
|
||||||
add_configs("installdir", {description = "malloc source install dir", default = nil})
|
|
||||||
-- 定义安装 mimalloc 的过程
|
|
||||||
set_sourcedir(path.join(os.scriptdir(), "latest"))
|
|
||||||
on_install(function (package, target)
|
|
||||||
local installdir = package:config("installdir")
|
|
||||||
print(installdir, package:installdir())
|
|
||||||
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")
|
|
||||||
-- 使用 CMake 从源码构建 mimalloc
|
|
||||||
import("package.tools.cmake").build(package, configs,{buildir = "build"})
|
|
||||||
local function get_dir(path)
|
|
||||||
if not os.isdir(path) then
|
|
||||||
os.mkdir(path)
|
|
||||||
end
|
|
||||||
return path
|
|
||||||
end
|
|
||||||
local lib = get_dir(path.join(installdir, "lib"))
|
|
||||||
if package:is_plat("windows") then
|
|
||||||
os.trycp("build/**.dll", lib)
|
|
||||||
os.trycp("build/**.lib", lib)
|
|
||||||
end
|
|
||||||
os.cp("include", installdir)
|
|
||||||
os.cp("src", installdir)
|
|
||||||
end)
|
|
||||||
19
packages/m/mimalloc/mimalloc_build.lua
Normal file
19
packages/m/mimalloc/mimalloc_build.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
function main(package)
|
||||||
|
os.cd(package:sourcedir())
|
||||||
|
local mode = package:config("debug") and "build/Debug" or "build/Realease"
|
||||||
|
if os.isdir(mode) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
print("is_shared = ",package:config("shared"))
|
||||||
|
print("is_debug = ",package:config("debug"))
|
||||||
|
print("begin build--------")
|
||||||
|
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_TRACK_ETW=" .. (package:config("debug") 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")
|
||||||
|
-- 使用 CMake 从源码构建 mimalloc
|
||||||
|
import("package.tools.cmake").build(package, configs,{buildir = "build"})
|
||||||
|
end
|
||||||
19
packages/m/mimalloc/xmake.lua
Normal file
19
packages/m/mimalloc/xmake.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package("mimalloc")
|
||||||
|
set_homepage("https://github.com/microsoft/mimalloc")
|
||||||
|
set_description("A general purpose allocator with high performance and small memory footprint")
|
||||||
|
add_versions("2.1.7", "...")
|
||||||
|
add_configs("secure", {description = "Use a secured version of mimalloc", default = false, type = "boolean"})
|
||||||
|
-- 定义安装 mimalloc 的过程
|
||||||
|
set_sourcedir(path.join(os.scriptdir(), "latest"))
|
||||||
|
on_fetch(function(package, opt)
|
||||||
|
import("mimalloc_build")
|
||||||
|
mimalloc_build(package)
|
||||||
|
local root = package:sourcedir()
|
||||||
|
local includedirs = {path.join(root, "include")}
|
||||||
|
local mode = package:config("debug") and "Debug" or "Realease"
|
||||||
|
local linkdirs = {path.join(root, "build/" .. mode)}
|
||||||
|
local links = {"mimalloc"}
|
||||||
|
return {
|
||||||
|
includedirs = includedirs, linkdirs = linkdirs, links = links
|
||||||
|
}
|
||||||
|
end)
|
||||||
Loading…
Reference in New Issue
Block a user