xmake.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package("pdcursesmod")
  2. set_homepage("https://projectpluto.com/win32a.htm")
  3. set_description("PDCurses Modified - a curses library modified and extended from the 'official' pdcurses")
  4. add_urls("https://github.com/Bill-Gray/PDCursesMod/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/Bill-Gray/PDCursesMod.git")
  6. add_versions("v4.4.0", "a53bf776623decb9e4b2c2ffe43e52d83fe4455ffd20229b4ba36c92918f67dd")
  7. add_versions("v4.3.4", "abbd099a51612200d1bfe236d764e0f0748ee71c3a6bc2c4069447d907d55b82")
  8. if not is_plat("windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. add_configs("port", {description = "Set the target port.", default = "sdl2", values = {"sdl2", "wincon"}})
  12. add_configs("utf8", {description = "Treat all narrow characters as UTF-8.", default = true, type = "boolean"})
  13. if is_plat("windows", "mingw") then
  14. add_syslinks("user32", "advapi32", "winmm")
  15. end
  16. on_load(function (package)
  17. if package:config("port") == "sdl2" then
  18. package:add("deps", "libsdl")
  19. if package:config("utf8") then
  20. package:add("deps", "libsdl_ttf")
  21. end
  22. end
  23. if package:config("utf8") then
  24. package:add("defines", "PDC_WIDE", "PDC_FORCE_UTF8")
  25. end
  26. if package:config("shared") then
  27. package:add("defines", "PDC_DLL_BUILD")
  28. end
  29. end)
  30. on_install("linux", "macosx", "mingw", "windows", function (package)
  31. io.writefile("xmake.lua", [[
  32. add_rules("mode.debug", "mode.release")
  33. option("port", {description = "Set the target port."})
  34. option("utf8", {description = "Treat all narrow characters as UTF-8."})
  35. add_defines("PDC_WIDE", "PDC_FORCE_UTF8")
  36. if is_config("port", "sdl2") then
  37. add_requires("libsdl")
  38. if has_config("utf8") then
  39. add_requires("libsdl_ttf")
  40. end
  41. end
  42. target("pdcursesmod")
  43. set_kind("$(kind)")
  44. add_files("pdcurses/*.c", "$(port)/*.c")
  45. add_includedirs(".", "$(port)")
  46. add_headerfiles("*.h", "$(port)/*.h")
  47. if is_kind("shared") then
  48. add_defines("PDC_DLL_BUILD")
  49. end
  50. add_packages("libsdl", "libsdl_ttf")
  51. if is_plat("windows", "mingw") then
  52. add_syslinks("user32", "advapi32", "winmm")
  53. end
  54. ]])
  55. local configs = {}
  56. if package:config("shared") then
  57. configs.kind = "shared"
  58. end
  59. configs.port = package:config("port")
  60. configs.utf8 = package:config("utf8")
  61. import("package.tools.xmake").install(package, configs)
  62. end)
  63. on_test(function (package)
  64. assert(package:check_csnippets([[
  65. void test(void) {
  66. initscr();
  67. printw("Hello, world!");
  68. refresh();
  69. endwin();
  70. }
  71. ]], {includes = "curses.h"}))
  72. end)