xmake.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package("abseil")
  2. set_homepage("https://abseil.io")
  3. set_description("C++ Common Libraries")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/abseil/abseil-cpp/archive/$(version).tar.gz",
  6. "https://github.com/abseil/abseil-cpp.git")
  7. add_versions("20200225.1", "0db0d26f43ba6806a8a3338da3e646bb581f0ca5359b3a201d8fb8e4752fd5f8")
  8. add_versions("20210324.1", "441db7c09a0565376ecacf0085b2d4c2bbedde6115d7773551bc116212c2a8d6")
  9. add_versions("20210324.2", "59b862f50e710277f8ede96f083a5bb8d7c9595376146838b9580be90374ee1f")
  10. add_versions("20211102.0", "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4")
  11. add_versions("20220623.0", "4208129b49006089ba1d6710845a45e31c59b0ab6bff9e5788a87f55c5abd602")
  12. add_versions("20230125.2", "9a2b5752d7bfade0bdeee2701de17c9480620f8b237e1964c1b9967c75374906")
  13. add_versions("20230802.1", "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed")
  14. add_deps("cmake")
  15. if is_plat("macosx") then
  16. add_frameworks("CoreFoundation")
  17. end
  18. on_load(function (package)
  19. if package:is_plat("windows") and package:config("shared") then
  20. package:add("defines", "ABSL_CONSUME_DLL")
  21. end
  22. end)
  23. on_install("macosx", "linux", "windows", "mingw", "cross", function (package)
  24. if package:version() and package:version():eq("20230802.1") and package:is_plat("mingw") then
  25. io.replace(path.join("absl", "synchronization", "internal", "pthread_waiter.h"), "#ifndef _WIN32", "#if !defined(_WIN32) && !defined(__MINGW32__)", {plain = true})
  26. io.replace(path.join("absl", "synchronization", "internal", "win32_waiter.h"), "#if defined(_WIN32) && _WIN32_WINNT >= _WIN32_WINNT_VISTA", "#if defined(_WIN32) && !defined(__MINGW32__) && _WIN32_WINNT >= _WIN32_WINNT_VISTA", {plain = true})
  27. end
  28. local configs = {"-DCMAKE_CXX_STANDARD=17"}
  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. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  32. -- get links and ensure link order
  33. import("core.base.graph")
  34. local dag = graph.new(true)
  35. local pkgconfigdir = package:installdir("lib", "pkgconfig")
  36. for _, pcfile in ipairs(os.files(path.join(pkgconfigdir, "*.pc"))) do
  37. local link = path.basename(pcfile)
  38. local content = io.readfile(pcfile)
  39. for _, line in ipairs(content:split("\n")) do
  40. if line:startswith("Requires: ") then
  41. local requires = line:sub(10):split(",")
  42. for _, dep in ipairs(requires) do
  43. dep = dep:split("=")[1]:trim()
  44. dag:add_edge(link, dep)
  45. end
  46. end
  47. end
  48. end
  49. local links = dag:topological_sort()
  50. package:add("links", links)
  51. local cycle = dag:find_cycle()
  52. if cycle then
  53. wprint("cycle links found", cycle)
  54. end
  55. end)
  56. on_test(function (package)
  57. assert(package:check_cxxsnippets({test = [[
  58. #include <iostream>
  59. #include <string>
  60. #include <vector>
  61. #include "absl/strings/numbers.h"
  62. #include "absl/strings/str_join.h"
  63. void test () {
  64. std::vector<std::string> v = {"foo","bar","baz"};
  65. std::string s = absl::StrJoin(v, "-");
  66. int result = 0;
  67. auto a = absl::SimpleAtoi("123", &result);
  68. std::cout << "Joined string: " << s << "\\n";
  69. }
  70. ]]}, {configs = {languages = "cxx17"}}))
  71. end)