xmake.lua 3.1 KB

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