xmake.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("libgit2")
  2. set_homepage("https://libgit2.org/")
  3. set_description("A cross-platform, linkable library implementation of Git that you can use in your application.")
  4. set_license("GPL-2.0-only")
  5. set_urls("https://github.com/libgit2/libgit2/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libgit2/libgit2.git")
  7. add_versions("v1.8.1", "8c1eaf0cf07cba0e9021920bfba9502140220786ed5d8a8ec6c7ad9174522f8e")
  8. add_versions("v1.8.0", "9e1d6a880d59026b675456fbb1593c724c68d73c34c0d214d6eb848e9bbd8ae4")
  9. add_versions("v1.7.1", "17d2b292f21be3892b704dddff29327b3564f96099a1c53b00edc23160c71327")
  10. add_versions("v1.3.0", "192eeff84596ff09efb6b01835a066f2df7cd7985e0991c79595688e6b36444e")
  11. add_deps("cmake")
  12. if is_plat("macosx", "iphoneos") then
  13. add_frameworks("CoreFoundation", "Security")
  14. add_syslinks("iconv", "z")
  15. else
  16. add_deps("openssl", "zlib")
  17. end
  18. if is_plat("linux") then
  19. add_deps("pcre")
  20. add_syslinks("pthread", "dl")
  21. elseif is_plat("windows") then
  22. add_syslinks("ole32", "rpcrt4", "winhttp", "ws2_32", "user32", "crypt32", "advapi32")
  23. end
  24. on_install("macosx", "linux", "windows|x64", "windows|x86", "iphoneos", function (package)
  25. local configs = {"-DBUILD_TESTS=OFF",
  26. "-DBUILD_CLAR=OFF",
  27. "-DBUILD_EXAMPLES=OFF",
  28. "-DBUILD_FUZZERS=OFF",
  29. "-DBUILD_CLI=OFF",
  30. "-DUSE_SSH=OFF"}
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  33. if package:is_plat("android", "iphoneos") then
  34. table.insert(configs, "-DUSE_HTTPS=OFF")
  35. elseif package:is_plat("windows") then
  36. if package:config("vs_runtime"):startswith("MT") then
  37. table.insert(configs, "-DSTATIC_CRT=ON")
  38. else
  39. table.insert(configs, "-DSTATIC_CRT=OFF")
  40. end
  41. io.replace("CMakeLists.txt", "/GL", "", {plain = true})
  42. if package:version():eq("1.7.1") then
  43. io.replace("cmake/DefaultCFlags.cmake", "/GL", "", {plain = true})
  44. end
  45. end
  46. import("package.tools.cmake").install(package, configs)
  47. end)
  48. on_test(function (package)
  49. assert(package:has_cfuncs("git_repository_init", {includes = "git2.h"}))
  50. end)