xmake.lua 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package("cryptopp")
  2. set_homepage("https://cryptopp.com/")
  3. set_description("free C++ class library of cryptographic schemes")
  4. add_urls("https://github.com/weidai11/cryptopp/archive/CRYPTOPP_$(version).tar.gz", {version = function (version) return version:gsub("%.", "_") end})
  5. add_versions("8.9.0", "ab5174b9b5c6236588e15a1aa1aaecb6658cdbe09501c7981ac8db276a24d9ab")
  6. add_versions("8.7.0", "8d6a4064b8e9f34cd3e838f5a12c40067ee7b95ee37d9173ec273cb0913e7ca2")
  7. add_versions("8.6.0", "9304625f4767a13e0a5f26d0f019d78cf9375604a33e5391c3bf2e81399dfeb8")
  8. add_versions("8.5.0", "8f64cf09cf4f61d5d74bca53574b8cc9959186cc0f072a2e6597e4999d6ad5db")
  9. add_versions("8.4.0", "6687dfc1e33b084aeab48c35a8550b239ee5f73a099a3b6a0918d70b8a89e654")
  10. add_resources("8.9.0", "cryptopp_cmake", "https://github.com/abdes/cryptopp-cmake/archive/CRYPTOPP_8_9_0.tar.gz", "191d69061c56602de1610ebf03b44dcf75636006e7e60ef8105bee6472ec0caf")
  11. add_resources("8.7.0", "cryptopp_cmake", "https://github.com/abdes/cryptopp-cmake/archive/CRYPTOPP_8_7_0_1.tar.gz", "49800456bec6432eff4a798d37f6c7760b887adc9f8928e66f44bcb8bf81f157")
  12. add_resources("8.6.0", "cryptopp_cmake", "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_6_0.tar.gz", "970b20d55dbf9d6335485e72c9f8967d878bf64bbd3de6aa28436beb6799c493")
  13. add_resources("8.5.0", "cryptopp_cmake", "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_5_0.tar.gz", "10685209405e676993873fcf638ade5f8f99d7949afa6b2045289ce9cc6d90ac")
  14. add_resources("8.4.0", "cryptopp_cmake", "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_4_0.tar.gz", "b850070141f6724fce640e4e2cfde433ec5b2d99d4386d29ba9255167bc4b4f0")
  15. add_deps("cmake")
  16. if is_plat("windows") then
  17. -- cryptocpp_cmake does not support shared libraries as of 8.7
  18. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  19. end
  20. on_install("windows", "macosx", "linux", "bsd", "iphoneos", function (package)
  21. local cryptopp_cmake = package:resourcedir("cryptopp_cmake")
  22. os.cp(path.join(cryptopp_cmake, "*", "CMakeLists.txt"), ".")
  23. if package:version():le("8.6") then
  24. os.cp(path.join(cryptopp_cmake, "*", "cryptopp-config.cmake"), ".")
  25. else
  26. os.cp(path.join(cryptopp_cmake, "*", "CMakePresets.json"), ".")
  27. os.cp(path.join(cryptopp_cmake, "*", "cmake"), ".")
  28. os.cp(path.join(cryptopp_cmake, "*", "cryptopp"), ".")
  29. os.cp(path.join(cryptopp_cmake, "*", "test"), ".")
  30. end
  31. -- fix unresolved external symbol PadLastBlock
  32. -- @see https://github.com/weidai11/cryptopp/issues/358
  33. io.replace("iterhash.h", "CRYPTOPP_NO_VTABLE", "CRYPTOPP_DLL CRYPTOPP_NO_VTABLE")
  34. local configs = {"-DBUILD_TESTING=OFF"}
  35. table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  36. table.insert(configs, "-DBUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  37. local cxflags
  38. if package:is_plat("windows") and package:config("shared") then
  39. cxflags = "-DCRYPTOPP_EXPORTS"
  40. end
  41. import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
  42. end)
  43. on_test(function (package)
  44. assert(package:check_cxxsnippets({test = [[
  45. #include <cryptopp/cryptlib.h>
  46. #include <cryptopp/aes.h>
  47. #include <cryptopp/modes.h>
  48. using namespace CryptoPP;
  49. void test() {
  50. unsigned char key[] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, 0x01,0x02, 0x03,0x04,0x05,0x06,0x07,0x08};
  51. unsigned char iv[] = {0x01,0x02,0x03,0x03,0x03,0x03,0x03,0x03, 0x03,0x03, 0x01,0x02,0x03,0x03,0x03,0x03};
  52. CTR_Mode<AES>::Encryption Encryptor2(key, 16, iv);
  53. }
  54. ]]}, {configs = {languages = "c++11"}}))
  55. end)