xmake.lua 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.5.4", "d5efc7f2b7107abe382bdf8bac0a9bfd8e716facbca2bb9cf12dfeb8e1122c4b")
  7. add_versions("v4.5.3", "5be1c4a1ba42c958deb219e6fe45fd3315444bc47cfe0c89f5ac0d8c00cc5930")
  8. add_versions("v4.5.2", "bd61d0026826b40ac43265c1f9a462a1903fef76f3ee231265ba22d528cf5ae3")
  9. add_versions("v4.4.0", "a53bf776623decb9e4b2c2ffe43e52d83fe4455ffd20229b4ba36c92918f67dd")
  10. add_versions("v4.3.4", "abbd099a51612200d1bfe236d764e0f0748ee71c3a6bc2c4069447d907d55b82")
  11. if not is_plat("windows") then
  12. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  13. end
  14. add_configs("port", {description = "Set the target port.", default = "sdl2", values = {"sdl2", "wincon"}})
  15. add_configs("utf8", {description = "Treat all narrow characters as UTF-8.", default = true, type = "boolean"})
  16. if is_plat("windows", "mingw") then
  17. add_syslinks("user32", "advapi32", "winmm")
  18. end
  19. on_load(function (package)
  20. if package:config("port") == "sdl2" then
  21. package:add("deps", "libsdl2")
  22. if package:config("utf8") then
  23. package:add("deps", "libsdl2_ttf")
  24. end
  25. end
  26. if package:config("utf8") then
  27. package:add("defines", "PDC_WIDE", "PDC_FORCE_UTF8")
  28. end
  29. if package:config("shared") then
  30. package:add("defines", "PDC_DLL_BUILD")
  31. end
  32. end)
  33. on_install("linux", "macosx", "mingw", "windows", function (package)
  34. io.writefile("xmake.lua", [[
  35. add_rules("mode.debug", "mode.release")
  36. option("port", {description = "Set the target port."})
  37. option("utf8", {description = "Treat all narrow characters as UTF-8."})
  38. add_defines("PDC_WIDE", "PDC_FORCE_UTF8")
  39. if is_config("port", "sdl2") then
  40. add_requires("libsdl2")
  41. if has_config("utf8") then
  42. add_requires("libsdl2_ttf")
  43. end
  44. end
  45. target("pdcursesmod")
  46. set_kind("$(kind)")
  47. add_files("pdcurses/*.c", "$(port)/*.c")
  48. add_includedirs(".", "$(port)")
  49. add_headerfiles("*.h", "$(port)/*.h")
  50. if is_kind("shared") then
  51. add_defines("PDC_DLL_BUILD")
  52. end
  53. add_packages("libsdl2", "libsdl2_ttf")
  54. if is_plat("windows", "mingw") then
  55. add_syslinks("user32", "advapi32", "winmm")
  56. end
  57. ]])
  58. local configs = {}
  59. if package:config("shared") then
  60. configs.kind = "shared"
  61. end
  62. configs.port = package:config("port")
  63. configs.utf8 = package:config("utf8")
  64. import("package.tools.xmake").install(package, configs)
  65. end)
  66. on_test(function (package)
  67. assert(package:check_csnippets([[
  68. void test(void) {
  69. initscr();
  70. printw("Hello, world!");
  71. refresh();
  72. endwin();
  73. }
  74. ]], {includes = "curses.h"}))
  75. end)