xmake.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package("boringssl")
  2. set_homepage("https://boringssl.googlesource.com/boringssl")
  3. set_description("A fork of OpenSSL that is designed to meet Google's needs.")
  4. add_urls("https://github.com/google/boringssl.git")
  5. add_versions("2021.12.29", "d80f17d5c94b21c4fb2e82ee527bfe001b3553f2")
  6. add_patches("2021.12.29", path.join(os.scriptdir(), "patches", "2021.12.29", "cmake.patch"), "d8bb6312b87b8aad434ea3f9f4275f769af3cdbaab78adf400e8e3907443b505")
  7. add_deps("cmake", "go")
  8. if is_plat("linux") then
  9. add_syslinks("pthread", "dl", "m")
  10. elseif is_plat("windows") then
  11. add_syslinks("advapi32")
  12. add_deps("nasm")
  13. end
  14. add_links("ssl", "crypto")
  15. on_install("linux", "macosx", "windows", function (package)
  16. import("net.fasturl")
  17. local configs = {}
  18. local proxyurls = {"https://goproxy.cn", "https://proxy.golang.org"}
  19. fasturl.add(proxyurls)
  20. proxyurls = fasturl.sort(proxyurls)
  21. if #proxyurls > 0 then
  22. os.setenv("GOPROXY", proxyurls[1])
  23. end
  24. -- we need suppress "hidden symbol ... is referenced by DSO"
  25. local cxflags
  26. if not package:config("shared") and package:is_plat("linux") then
  27. cxflags = "-DBORINGSSL_SHARED_LIBRARY"
  28. end
  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. io.replace("CMakeLists.txt", "-WX", "", {plain = true})
  32. import("package.tools.cmake").install(package, configs, {cxflags = cxflags, buildir = "build"})
  33. os.cp("include", package:installdir())
  34. if package:config("shared") then
  35. if package:is_plat("windows") then
  36. os.cp("build/ssl/*/ssl.dll", package:installdir("bin"))
  37. os.cp("build/ssl/*/ssl.lib", package:installdir("lib"))
  38. os.cp("build/crypto/*/crypto.dll", package:installdir("bin"))
  39. os.cp("build/crypto/*/crypto.lib", package:installdir("lib"))
  40. elseif package:is_plat("macosx") then
  41. os.cp("build/ssl/libssl.dylib", package:installdir("lib"))
  42. os.cp("build/crypto/libcrypto.dylib", package:installdir("lib"))
  43. else
  44. os.cp("build/ssl/libssl.so", package:installdir("lib"))
  45. os.cp("build/crypto/libcrypto.so", package:installdir("lib"))
  46. end
  47. elseif package:is_plat("windows") then
  48. os.cp("build/ssl/*/ssl.lib", package:installdir("lib"))
  49. os.cp("build/crypto/*/crypto.lib", package:installdir("lib"))
  50. else
  51. os.cp("build/ssl/libssl.a", package:installdir("lib"))
  52. os.cp("build/crypto/libcrypto.a", package:installdir("lib"))
  53. end
  54. end)
  55. on_test(function (package)
  56. assert(package:has_cfuncs("SSL_new", {includes = "openssl/ssl.h"}))
  57. end)