xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("libsdl_ttf")
  2. set_homepage("https://www.libsdl.org/projects/SDL_ttf/")
  3. set_description("Simple DirectMedia Layer text rendering library")
  4. if is_plat("windows", "mingw") then
  5. set_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-$(version)-VC.zip")
  6. add_versions("2.0.15", "aab0d81f1aa6fe654be412efc85829f2b188165dca6c90eb4b12b673f93e054b")
  7. else
  8. set_urls("https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).zip")
  9. add_versions("2.0.15", "cdb72b5b1c3b27795fa128af36f369fee5d3e38a96c350855da0b81880555dbc")
  10. end
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::SDL2_ttf")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::sdl2_ttf", "apt::libsdl2-ttf-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::sdl2_ttf")
  17. end
  18. add_deps("libsdl")
  19. if is_plat("linux", "macosx") then
  20. add_deps("freetype")
  21. end
  22. add_links("SDL2_ttf")
  23. add_includedirs("include", "include/SDL2")
  24. on_install("windows", "mingw", function (package)
  25. local arch = package:arch()
  26. if package:is_plat("mingw") then
  27. arch = (arch == "x86_64") and "x64" or "x86"
  28. end
  29. os.cp("include/*", package:installdir("include/SDL2"))
  30. os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
  31. os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
  32. end)
  33. on_install("macosx", "linux", function (package)
  34. local configs = {}
  35. if package:config("shared") then
  36. table.insert(configs, "--enable-shared=yes")
  37. else
  38. table.insert(configs, "--enable-shared=no")
  39. end
  40. if package:is_plat("linux") and package:config("pic") ~= false then
  41. table.insert(configs, "--with-pic")
  42. end
  43. local libsdl = package:dep("libsdl")
  44. if libsdl and not libsdl:is_system() then
  45. table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
  46. end
  47. import("package.tools.autoconf").install(package, configs)
  48. end)
  49. on_test(function (package)
  50. assert(package:has_cfuncs("TTF_Init", {includes = "SDL2/SDL_ttf.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
  51. end)