2
0

xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("sdl2webgpu")
  2. set_description("An extension for the SDL2 library for using WebGPU native.")
  3. set_homepage("https://github.com/eliemichel/sdl2webgpu")
  4. set_license("MIT")
  5. -- Version 1.0.0 is too old for the current wgpu-native, we have to fetch a newer version from a more recent commit
  6. add_urls("https://github.com/eliemichel/sdl2webgpu.git")
  7. add_versions("2025.04.18", "eda8bedcb78a755f42c5efa00b732c62e89c23cb")
  8. add_deps("wgpu-native", "libsdl2")
  9. if is_plat("macosx", "iphoneos") then
  10. add_frameworks("CoreVideo", "IOKit", "QuartzCore", is_plat("macosx") and "Cocoa" or "UIKit")
  11. end
  12. on_install("windows|x64", "windows|x86", "linux|x86_64", "macosx|x86_64", "macosx|arm64", function (package)
  13. if package:is_plat("macosx", "iphoneos") then
  14. os.mv("sdl2webgpu.c", "sdl2webgpu.m")
  15. end
  16. io.writefile("xmake.lua", [[
  17. add_rules("mode.debug", "mode.release")
  18. add_requires("wgpu-native", "libsdl2")
  19. target("sdl2webgpu")
  20. set_kind("$(kind)")
  21. set_languages("c11")
  22. add_headerfiles("sdl2webgpu.h")
  23. add_mxflags("-fno-objc-arc")
  24. add_packages("wgpu-native")
  25. add_packages("libsdl2")
  26. if is_plat("macosx", "iphoneos") then
  27. add_frameworks("CoreVideo", "IOKit", "QuartzCore", is_plat("macosx") and "Cocoa" or "UIKit")
  28. add_files("sdl2webgpu.m")
  29. else
  30. add_files("sdl2webgpu.c")
  31. end
  32. if is_plat("windows") and is_kind("shared") then
  33. add_rules("utils.symbols.export_all")
  34. end
  35. ]])
  36. import("package.tools.xmake").install(package, configs)
  37. end)
  38. on_test(function (package)
  39. assert(package:has_cfuncs("SDL_GetWGPUSurface", {includes = "sdl2webgpu.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
  40. end)