xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("libsdl_image")
  2. set_homepage("http://www.libsdl.org/projects/SDL_image/")
  3. set_description("Simple DirectMedia Layer image loading library")
  4. if is_plat("windows", "mingw") then
  5. set_urls("https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-$(version)-VC.zip")
  6. add_versions("2.0.5", "a180f9b75c4d3fbafe02af42c42463cc7bc488e763cfd1ec2ffb75678b4387ac")
  7. else
  8. set_urls("https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$(version).zip")
  9. add_versions("2.0.5", "eee0927d1e7819d57c623fe3e2b3c6761c77c474fe9bc425e8674d30ac049b1c")
  10. end
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::SDL2_image")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::sdl2_image", "apt::libsdl2-image-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::sdl2_image")
  17. end
  18. if is_plat("macosx") then
  19. add_frameworks("CoreFoundation", "CoreGraphics", "ImageIO", "CoreServices")
  20. end
  21. if is_plat("macosx", "linux") then
  22. add_deps("automake", "autoconf")
  23. end
  24. add_deps("libsdl")
  25. add_links("SDL2_image")
  26. add_includedirs("include", "include/SDL2")
  27. on_install("windows", "mingw", function (package)
  28. local arch = package:arch()
  29. if package:is_plat("mingw") then
  30. arch = (arch == "x86_64") and "x64" or "x86"
  31. end
  32. os.cp("include/*", package:installdir("include/SDL2"))
  33. os.cp(path.join("lib", arch, "*.lib"), package:installdir("lib"))
  34. os.cp(path.join("lib", arch, "*.dll"), package:installdir("bin"))
  35. end)
  36. on_install("macosx", "linux", function (package)
  37. local configs = {}
  38. if package:config("shared") then
  39. table.insert(configs, "--enable-shared=yes")
  40. else
  41. table.insert(configs, "--enable-shared=no")
  42. end
  43. if package:is_plat("linux") and package:config("pic") ~= false then
  44. table.insert(configs, "--with-pic")
  45. end
  46. local libsdl = package:dep("libsdl")
  47. if libsdl and not libsdl:is_system() then
  48. table.insert(configs, "--with-sdl-prefix=" .. libsdl:installdir())
  49. end
  50. io.replace("Makefile.am", "noinst_PROGRAMS = showimage", "")
  51. os.rm("./configure")
  52. import("package.tools.autoconf").install(package, configs)
  53. end)
  54. on_test(function (package)
  55. assert(package:has_cfuncs("IMG_Init", {includes = "SDL2/SDL_image.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
  56. end)