xmake.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package("libsdl2_gfx")
  2. set_homepage("https://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/")
  3. set_description("Simple DirectMedia Layer primitives drawing library")
  4. if is_plat("windows") then
  5. set_urls("https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$(version).zip", {alias = "ferzkopp"})
  6. add_urls("https://sourceforge.net/projects/sdl2gfx/files/SDL2_gfx-$(version).tar.gz", {alias = "sourceforge"})
  7. add_versions("ferzkopp:1.0.4", "b6da07583b7fb8f4d8cee97cac9176b97a287f56a8112e22f38183ecf47b9dcb")
  8. add_versions("sourceforge:1.0.4", "63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262")
  9. add_patches("1.0.4", path.join(os.scriptdir(), "patches", "1.0.4", "lrint_fix.patch"), "9fb928306fb25293720214377bff2f605f60ea26f43ea5346cf1268c504aff1a")
  10. elseif is_plat("macosx", "linux") then
  11. set_urls("https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-$(version).tar.gz")
  12. add_urls("https://sourceforge.net/projects/sdl2gfx/files/SDL2_gfx-$(version).tar.gz")
  13. add_versions("1.0.4", "63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262")
  14. end
  15. if is_plat("mingw") and is_subhost("msys") then
  16. add_extsources("pacman::SDL2_gfx")
  17. elseif is_plat("linux") then
  18. add_extsources("pacman::sdl2_gfx", "apt::libsdl2-gfx-dev")
  19. elseif is_plat("macosx") then
  20. add_extsources("brew::sdl2_gfx")
  21. end
  22. if is_plat("wasm") then
  23. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  24. end
  25. add_includedirs("include", "include/SDL2")
  26. on_load(function (package)
  27. package:add("deps", "libsdl2", { configs = { shared = package:config("shared") }})
  28. end)
  29. on_install("windows|x86", "windows|x64", "macosx", "linux", function(package)
  30. io.writefile("xmake.lua", [[
  31. add_rules("mode.debug", "mode.release")
  32. if is_kind("shared") then
  33. add_requires("libsdl2", {configs = {shared = true}})
  34. else
  35. add_requires("libsdl2")
  36. end
  37. target("SDL2_gfx")
  38. set_kind("$(kind)")
  39. add_files("*.c")
  40. add_headerfiles("*.h", {prefixdir = "SDL2"})
  41. add_packages("libsdl2")
  42. add_rules("utils.install.pkgconfig_importfiles")
  43. if is_plat("windows") and is_kind("shared") then
  44. add_defines("DLL_EXPORT")
  45. end
  46. if is_arch("x86", "i386") then
  47. add_defines("USE_MMX")
  48. end
  49. ]])
  50. local configs = {}
  51. if package:config("shared") then
  52. configs.kind = "shared"
  53. end
  54. import("package.tools.xmake").install(package, configs)
  55. end)
  56. on_test(function (package)
  57. local ldflags
  58. if package:is_plat("windows") then
  59. if package:has_tool("cxx", "cl", "clang-cl") then
  60. ldflags = "-subsystem:console"
  61. elseif package:has_tool("cxx", "clang", "clangxx") then
  62. ldflags = "-Wl,/subsystem:console"
  63. end
  64. end
  65. assert(package:has_cfuncs("aacircleRGBA", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_gfxPrimitives.h"}, configs = {ldflags = ldflags}}))
  66. assert(package:has_cfuncs("SDL_initFramerate", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_framerate.h"}, configs = {ldflags = ldflags}}))
  67. assert(package:has_cfuncs("rotozoomSurface", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_rotozoom.h"}, configs = {ldflags = ldflags}}))
  68. assert(package:has_cfuncs("SDL_imageFilterAdd", {includes = {"SDL2/SDL_main.h", "SDL2/SDL2_imageFilter.h"}, configs = {ldflags = ldflags}}))
  69. end)