xmake.lua 3.3 KB

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