gklib: add package (#4151)

* gklib: add package

* fix arm
pull/4150/head
star9029 8 months ago committed by GitHub
parent 311675e760
commit f43d0f9cfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 53
      packages/g/gklib/port/xmake.lua
  2. 51
      packages/g/gklib/xmake.lua

@ -0,0 +1,53 @@
option("openmp", {showmenu = true, default = false})
option("regex", {showmenu = true, default = false})
option("rand", {showmenu = true, default = false})
add_rules("mode.debug", "mode.release")
if has_config("openmp") then
add_requires("openmp")
add_packages("openmp")
end
if has_config("regex") then
add_defines("USE_GKREGEX", {public = true})
end
if has_config("rand") then
add_defines("USE_GKRAND")
end
includes("@builtin/check")
configvar_check_cincludes("HAVE_EXECINFO_H", "execinfo.h")
configvar_check_cfuncs("HAVE_GETLINE", "getline")
target("gklib")
set_kind("$(kind)")
add_files("*.c")
add_headerfiles("*.h")
add_includedirs(".")
add_vectorexts("all")
if is_plat("windows") then
add_files("win32/*.c")
add_headerfiles("(win32/adapt.h)")
add_defines("_CRT_SECURE_NO_DEPRECATE", "USE_GKREGEX", "__thread=__declspec(thread)", {public = true})
if is_kind("shared") then
add_rules("utils.symbols.export_all")
end
elseif is_plat("mingw") then
add_defines("USE_GKREGEX")
elseif is_plat("linux") then
add_syslinks("m")
add_defines("_FILE_OFFSET_BITS=64")
elseif is_plat("bsd") then
add_syslinks("m")
end
on_config(function (target)
if not target:check_csnippets({test = "extern __thread int x;"}) then
target:add("defines", "__thread")
end
end)

@ -0,0 +1,51 @@
package("gklib")
set_homepage("https://github.com/KarypisLab/GKlib")
set_description("A library of various helper routines and frameworks used by many of the lab's software")
set_license("Apache-2.0")
add_urls("https://github.com/KarypisLab/GKlib.git")
add_versions("2023.03.26", "8bd6bad750b2b0d90800c632cf18e8ee93ad72d7")
add_configs("regex", {description = "Enable GKREGEX support", default = false, type = "boolean"})
add_configs("rand", {description = "Enable GKRAND support", default = false, type = "boolean"})
add_configs("openmp", {description = "Enable openmp", default = false, type = "boolean"})
if is_plat("linux", "bsd") then
add_syslinks("m")
elseif is_plat("windows") then
add_defines("USE_GKREGEX", "__thread=__declspec(thread)")
elseif is_plat("mingw") then
add_defines("USE_GKREGEX")
end
on_install("!iphoneos", function (package)
local configs = {
openmp = package:config("openmp"),
regex = package:config("regex"),
rand = package:config("rand")
}
if configs.regex then
package:add("defines", "USE_GKREGEX")
end
io.replace("gk_arch.h", "gk_ms_stdint.h", "stdint.h", {plain = true})
io.replace("gk_arch.h", "gk_ms_inttypes.h", "inttypes.h", {plain = true})
io.replace("gk_arch.h", "LINUX", "__linux__", {plain = true})
for _, file in ipairs({"timers.c", "gk_arch.h", "error.c", "string.c"}) do
io.replace(file, "WIN32", "_WIN32", {plain = true})
end
if configs.openmp then
for _, file in ipairs({"GKlib.h", "timers.c", "gk_proto.h"}) do
io.replace(file, "__OPENMP__", "_OPENMP", {plain = true})
end
end
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("gk_strstr_replace", {includes = "GKlib.h"}))
end)
Loading…
Cancel
Save