xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package("chipmunk2d")
  2. set_homepage("https://chipmunk-physics.net/")
  3. set_description("A fast and lightweight 2D game physics library.")
  4. set_license("MIT")
  5. add_urls("https://github.com/slembcke/Chipmunk2D/archive/Chipmunk-$(version).tar.gz", {alias = "archive"})
  6. add_urls("https://github.com/slembcke/Chipmunk2D.git", {alias = "github"})
  7. add_versions("archive:7.0.3", "1e6f093812d6130e45bdf4cb80280cb3c93d1e1833d8cf989d554d7963b7899a")
  8. add_versions("github:7.0.3", "87340c216bf97554dc552371bbdecf283f7c540e")
  9. add_patches("7.0.3", path.join(os.scriptdir(), "patches", "7.0.3", "android.patch"), "08e80020880e9bf3c61b48d41537d953e7bf6a63797eb8bcd6b78ba038b79d8f")
  10. if is_plat("mingw") and is_subhost("msys") then
  11. add_extsources("pacman::chipmunk")
  12. elseif is_plat("linux") then
  13. add_extsources("pacman::chipmunk", "apt::libchipmunk-dev")
  14. elseif is_plat("macosx") then
  15. add_extsources("brew::chipmunk")
  16. end
  17. add_deps("cmake")
  18. if is_plat("linux") then
  19. add_syslinks("pthread", "m")
  20. end
  21. on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", "wasm", function (package)
  22. local configs = {"-DBUILD_DEMOS=OFF"}
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  24. if package:config("shared") then
  25. table.insert(configs, "-DBUILD_SHARED=ON")
  26. table.insert(configs, "-DBUILD_STATIC=OFF")
  27. table.insert(configs, "-DINSTALL_STATIC=OFF")
  28. else
  29. table.insert(configs, "-DBUILD_SHARED=OFF")
  30. table.insert(configs, "-DBUILD_STATIC=ON")
  31. end
  32. import("package.tools.cmake").install(package, configs)
  33. os.vcp("include/chipmunk", package:installdir("include"))
  34. end)
  35. on_test(function (package)
  36. assert(package:check_cxxsnippets({test = [[
  37. void test() {
  38. cpSpace* space = cpSpaceNew();
  39. cpSpaceFree(space);
  40. }
  41. ]]}, {includes = {"chipmunk/chipmunk.h"}}))
  42. end)