xmake.lua 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package("glfw3webgpu")
  2. set_description("An extension for the GLFW library for using WebGPU native.")
  3. set_homepage("https://github.com/eliemichel/glfw3webgpu")
  4. set_license("MIT")
  5. add_urls("https://github.com/eliemichel/glfw3webgpu/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/eliemichel/glfw3webgpu.git")
  7. add_versions("v1.3.0-alpha", "608386a158a22636756dd44932f25675a68f190552481f48d45d63573edd5f2b")
  8. add_versions("v1.2.0", "28387b960aff573728bde2bf0fa876c33608cdadaca8d23f4a46cd31920ab633")
  9. add_versions("v1.1.0", "307ba86a724adc84a875e8bd2374baad0fabc77797f20f9a1779eef8d9ffe95a")
  10. add_versions("v1.0.1", "b98c63f1905f0e4cf99229de8b7e5c2693fdf3b8d684b5a43d60f21f67d33e6b")
  11. add_deps("wgpu-native", "glfw")
  12. if is_plat("macosx", "iphoneos") then
  13. add_frameworks("Metal", "Foundation", "QuartzCore")
  14. end
  15. on_install("windows|x64", "windows|x86", "linux|x86_64", "macosx|x86_64", "macosx|arm64", function (package)
  16. if package:is_plat("macosx", "iphoneos") then
  17. os.mv("glfw3webgpu.c", "glfw3webgpu.m")
  18. end
  19. local configs = {}
  20. local glfw = package:dep("glfw")
  21. if glfw then
  22. if glfw:config("x11") then
  23. configs.x11 = true
  24. end
  25. if glfw:config("wayland") then
  26. configs.wayland = true
  27. end
  28. end
  29. io.writefile("xmake.lua", [[
  30. add_rules("mode.debug", "mode.release")
  31. option("x11", {default = false})
  32. option("wayland", {default = false})
  33. add_requires("wgpu-native", "glfw")
  34. target("glfw3webgpu")
  35. set_kind("$(kind)")
  36. set_languages("c11")
  37. add_headerfiles("glfw3webgpu.h")
  38. add_mxflags("-fno-objc-arc")
  39. add_packages("wgpu-native")
  40. add_packages("glfw")
  41. if is_plat("iphoneos", "macosx") then
  42. add_frameworks("Metal", "Foundation", "QuartzCore")
  43. add_files("glfw3webgpu.m")
  44. else
  45. add_files("glfw3webgpu.c")
  46. end
  47. if is_plat("windows") and is_kind("shared") then
  48. add_rules("utils.symbols.export_all")
  49. end
  50. if is_plat("windows") then
  51. add_defines("GLFW_EXPOSE_NATIVE_WIN32")
  52. elseif is_plat("macosx", "iphoneos") then
  53. add_defines("GLFW_EXPOSE_NATIVE_COCOA")
  54. end
  55. if has_config("x11") then
  56. add_defines("GLFW_EXPOSE_NATIVE_X11")
  57. elseif has_config("wayland") then
  58. add_defines("GLFW_EXPOSE_NATIVE_WAYLAND")
  59. end
  60. ]])
  61. import("package.tools.xmake").install(package, configs)
  62. end)
  63. on_test(function (package)
  64. if package:version() and package:version():minor() >= 3 then
  65. assert(package:has_cfuncs("glfwCreateWindowWGPUSurface", {includes = "glfw3webgpu.h"}))
  66. else
  67. assert(package:has_cfuncs("glfwGetWGPUSurface", {includes = "glfw3webgpu.h"}))
  68. end
  69. end)