xmake.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.7.1", "17d2b292f21be3892b704dddff29327b3564f96099a1c53b00edc23160c71327")
  8. add_versions("v1.3.0", "192eeff84596ff09efb6b01835a066f2df7cd7985e0991c79595688e6b36444e")
  9. add_deps("cmake")
  10. if is_plat("macosx", "iphoneos") then
  11. add_frameworks("CoreFoundation", "Security")
  12. add_syslinks("iconv", "z")
  13. else
  14. add_deps("openssl", "zlib")
  15. end
  16. if is_plat("linux") then
  17. add_deps("pcre")
  18. add_syslinks("pthread", "dl")
  19. elseif is_plat("windows") then
  20. add_syslinks("ole32", "rpcrt4", "winhttp", "ws2_32", "user32", "crypt32", "advapi32")
  21. end
  22. on_install("macosx", "linux", "windows|x64", "windows|x86", "iphoneos", function (package)
  23. local configs = {"-DBUILD_TESTS=OFF",
  24. "-DBUILD_CLAR=OFF",
  25. "-DBUILD_EXAMPLES=OFF",
  26. "-DBUILD_FUZZERS=OFF",
  27. "-DBUILD_CLI=OFF",
  28. "-DUSE_SSH=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. if package:is_plat("android", "iphoneos") then
  32. table.insert(configs, "-DUSE_HTTPS=OFF")
  33. elseif package:is_plat("windows") then
  34. if package:config("vs_runtime"):startswith("MT") then
  35. table.insert(configs, "-DSTATIC_CRT=ON")
  36. else
  37. table.insert(configs, "-DSTATIC_CRT=OFF")
  38. end
  39. io.replace("CMakeLists.txt", "/GL", "", {plain = true})
  40. if package:version():eq("1.7.1") then
  41. io.replace("cmake/DefaultCFlags.cmake", "/GL", "", {plain = true})
  42. end
  43. end
  44. import("package.tools.cmake").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("git_repository_init", {includes = "git2.h"}))
  48. end)