xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("gklib")
  2. set_homepage("https://github.com/KarypisLab/GKlib")
  3. set_description("A library of various helper routines and frameworks used by many of the lab's software")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/KarypisLab/GKlib.git")
  6. add_versions("2023.03.26", "8bd6bad750b2b0d90800c632cf18e8ee93ad72d7")
  7. add_configs("regex", {description = "Enable GKREGEX support", default = false, type = "boolean"})
  8. add_configs("rand", {description = "Enable GKRAND support", default = false, type = "boolean"})
  9. add_configs("openmp", {description = "Enable openmp", default = false, type = "boolean"})
  10. if is_plat("linux", "bsd") then
  11. add_syslinks("m")
  12. elseif is_plat("windows") then
  13. add_defines("USE_GKREGEX", "__thread=__declspec(thread)")
  14. elseif is_plat("mingw") then
  15. add_defines("USE_GKREGEX")
  16. end
  17. on_install("!iphoneos", function (package)
  18. local configs = {
  19. openmp = package:config("openmp"),
  20. regex = package:config("regex"),
  21. rand = package:config("rand")
  22. }
  23. if configs.regex then
  24. package:add("defines", "USE_GKREGEX")
  25. end
  26. io.replace("gk_arch.h", "gk_ms_stdint.h", "stdint.h", {plain = true})
  27. io.replace("gk_arch.h", "gk_ms_inttypes.h", "inttypes.h", {plain = true})
  28. io.replace("gk_arch.h", "LINUX", "__linux__", {plain = true})
  29. for _, file in ipairs({"timers.c", "gk_arch.h", "error.c", "string.c"}) do
  30. io.replace(file, "WIN32", "_WIN32", {plain = true})
  31. end
  32. if configs.openmp then
  33. for _, file in ipairs({"GKlib.h", "timers.c", "gk_proto.h"}) do
  34. io.replace(file, "__OPENMP__", "_OPENMP", {plain = true})
  35. end
  36. end
  37. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  38. import("package.tools.xmake").install(package, configs)
  39. end)
  40. on_test(function (package)
  41. assert(package:has_cfuncs("gk_strstr_replace", {includes = "GKlib.h"}))
  42. end)