xmake.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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")
  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. io.writefile("xmake.lua", [[
  20. add_rules("mode.debug", "mode.release")
  21. add_requires("wgpu-native", "glfw")
  22. target("glfw3webgpu")
  23. set_kind("$(kind)")
  24. set_languages("c11")
  25. add_headerfiles("glfw3webgpu.h")
  26. add_mxflags("-fno-objc-arc")
  27. add_packages("wgpu-native")
  28. add_packages("glfw")
  29. if is_plat("iphoneos", "macosx") then
  30. add_frameworks("Metal", "Foundation")
  31. add_files("glfw3webgpu.m")
  32. else
  33. add_files("glfw3webgpu.c")
  34. end
  35. if is_plat("windows") and is_kind("shared") then
  36. add_rules("utils.symbols.export_all")
  37. end
  38. ]])
  39. import("package.tools.xmake").install(package)
  40. end)
  41. on_test(function (package)
  42. if package:version() and package:version():minor() >= 3 then
  43. assert(package:has_cfuncs("glfwCreateWindowWGPUSurface", {includes = "glfw3webgpu.h"}))
  44. else
  45. assert(package:has_cfuncs("glfwGetWGPUSurface", {includes = "glfw3webgpu.h"}))
  46. end
  47. end)