xmake.lua 3.2 KB

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