xmake.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package("boringssl")
  2. set_homepage("https://boringssl.googlesource.com/boringssl")
  3. set_description("BoringSSL is a fork of OpenSSL that is designed to meet Google's needs.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/google/boringssl/archive/refs/tags/$(version).tar.gz", {
  6. version = function (version)
  7. if version:ge("2024.09.13") then
  8. return format("0.%s.0", version:gsub("%.", ""))
  9. else
  10. return "fips-" .. version:gsub("%.", "")
  11. end
  12. end})
  13. add_urls("https://github.com/google/boringssl.git",
  14. "https://boringssl.googlesource.com/boringssl.git", {alias = "git"})
  15. add_versions("2025.11.24", "d47f89b894bf534c82071d7426c5abf1e5bd044fee242def53cd5d3d0f656c09")
  16. add_versions("2022.06.13", "a343962da2fbb10d8fa2cd9a2832839a23045a197c0ff306dc0fa0abb85759b3")
  17. add_versions("2021.12.29", "d80f17d5c94b21c4fb2e82ee527bfe001b3553f2")
  18. add_versions("git:2025.11.24", "0.20251124.0")
  19. add_patches("2022.06.13", path.join(os.scriptdir(), "patches", "2022.06.13", "cmake.patch"), "c44e5c2b4b4f010a6fab1c0bce22a50feb5d85f37a870cf9a71f8d58bdfbd169")
  20. add_patches("2021.12.29", path.join(os.scriptdir(), "patches", "2021.12.29", "cmake.patch"), "d8bb6312b87b8aad434ea3f9f4275f769af3cdbaab78adf400e8e3907443b505")
  21. if is_plat("linux") then
  22. add_syslinks("pthread", "dl", "m")
  23. elseif is_plat("windows", "mingw") then
  24. add_syslinks("ws2_32", "advapi32")
  25. end
  26. add_links("ssl", "crypto")
  27. add_deps("cmake", "go")
  28. if is_plat("windows", "mingw") then
  29. add_deps("nasm")
  30. end
  31. on_load("windows", function (package)
  32. if package:is_plat("windows") and package:version():ge("2022.06.13") and (not package:is_precompiled()) then
  33. package:add("deps", "strawberry-perl")
  34. end
  35. end)
  36. on_install("!mingw and (!windows or windows|!arm64)", function (package)
  37. import("net.fasturl")
  38. local configs = {}
  39. local proxyurls = {"https://goproxy.cn", "https://proxy.golang.org"}
  40. fasturl.add(proxyurls)
  41. proxyurls = fasturl.sort(proxyurls)
  42. if #proxyurls > 0 then
  43. os.setenv("GOPROXY", proxyurls[1])
  44. end
  45. io.replace("CMakeLists.txt", "-WX", "", {plain = true})
  46. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  47. if package:is_plat("wasm") then
  48. io.replace("CMakeLists.txt", "-Wa,-g", "", {plain = true})
  49. end
  50. local configs = {"-DBUILD_TESTING=OFF"}
  51. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  52. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  53. if package:version() and package:version():ge("2022.06.13") then
  54. import("package.tools.cmake").install(package, configs)
  55. if package:is_plat("windows") then
  56. os.mv(package:installdir("lib/*.dll"), package:installdir("bin"))
  57. end
  58. else
  59. -- we need suppress "hidden symbol ... is referenced by DSO"
  60. local cxflags
  61. if not package:config("shared") and package:is_plat("linux") then
  62. cxflags = "-DBORINGSSL_SHARED_LIBRARY"
  63. end
  64. import("package.tools.cmake").install(package, configs, {cxflags = cxflags, buildir = "build"})
  65. os.cp("include", package:installdir())
  66. if package:config("shared") then
  67. if package:is_plat("windows") then
  68. os.cp("build/ssl/*/ssl.dll", package:installdir("bin"))
  69. os.cp("build/ssl/*/ssl.lib", package:installdir("lib"))
  70. os.cp("build/crypto/*/crypto.dll", package:installdir("bin"))
  71. os.cp("build/crypto/*/crypto.lib", package:installdir("lib"))
  72. elseif package:is_plat("macosx") then
  73. os.cp("build/ssl/libssl.dylib", package:installdir("lib"))
  74. os.cp("build/crypto/libcrypto.dylib", package:installdir("lib"))
  75. else
  76. os.cp("build/ssl/libssl.so", package:installdir("lib"))
  77. os.cp("build/crypto/libcrypto.so", package:installdir("lib"))
  78. end
  79. elseif package:is_plat("windows") then
  80. os.cp("build/ssl/*/ssl.lib", package:installdir("lib"))
  81. os.cp("build/crypto/*/crypto.lib", package:installdir("lib"))
  82. else
  83. os.cp("build/ssl/libssl.a", package:installdir("lib"))
  84. os.cp("build/crypto/libcrypto.a", package:installdir("lib"))
  85. end
  86. end
  87. end)
  88. on_test(function (package)
  89. assert(package:has_cfuncs("SSL_new", {includes = "openssl/ssl.h"}))
  90. end)