2
0

xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("wolfssl")
  2. set_homepage("https://www.wolfssl.com")
  3. set_description("The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3!")
  4. set_license("GPL-2.0")
  5. add_urls("https://github.com/wolfSSL/wolfssl/archive/refs/tags/v$(version)-stable.tar.gz",
  6. "https://github.com/wolfSSL/wolfssl.git")
  7. add_versions("5.6.6", "3d2ca672d41c2c2fa667885a80d6fa03c3e91f0f4f72f87aef2bc947e8c87237")
  8. add_versions("5.6.4", "031691906794ff45e1e792561cf31759f5d29ac74936bc8dffb8b14f16d820b4")
  9. add_versions("5.6.3", "2e74a397fa797c2902d7467d500de904907666afb4ff80f6464f6efd5afb114a")
  10. add_versions("5.6.2", "eb252f6ca8d8dcc2a05926dfafbc42250fea78e5e07b4689c3fc26ad69d2dd73")
  11. add_versions("5.3.0", "1a3bb310dc01d3e73d9ad91b6ea8249d081016f8eef4ae8f21d3421f91ef1de9")
  12. add_configs("openssl_extra", {description = "WOLFSSL_OPENSSLEXTRA", default = false, type = "boolean"})
  13. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  14. add_deps("cmake")
  15. on_install("windows", function (package)
  16. local configs = {"wolfssl64.sln"}
  17. local mode = package:debug() and "Debug" or "Release"
  18. local arch = package:is_arch("x64") and "x64" or "Win32"
  19. table.insert(configs, "/p:Configuration=" .. mode)
  20. table.insert(configs, "/p:Platform=" .. arch)
  21. table.insert(configs, "-t:wolfssl")
  22. import("package.tools.msbuild").build(package, configs, {upgrade = {"wolfssl64.sln", "wolfssl.vcxproj"}})
  23. os.cp("wolfssl", package:installdir("include"))
  24. os.cp(path.join(mode, arch, "*"), package:installdir("lib"))
  25. end)
  26. on_install("linux", "macos", "mingw", function (package)
  27. local cmake_cflags = 'set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Werror ${CMAKE_C_FLAGS}")'
  28. local new_cmake_cflags = 'set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused ${CMAKE_C_FLAGS}")'
  29. io.replace("CMakeLists.txt", cmake_cflags, new_cmake_cflags, {plain = true})
  30. local configs = {"-DWOLFSSL_EXAMPLES=no", "-DWOLFSSL_CRYPT_TESTS=no"}
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  33. table.insert(configs, "-DWOLFSSL_OPENSSLEXTRA=" .. (package:config("openssl_extra") and "yes" or "no"))
  34. local ldflags
  35. if package:is_plat("android") then
  36. ldflags = "-llog"
  37. end
  38. import("package.tools.cmake").install(package, configs, {ldflags = ldflags})
  39. end)
  40. on_test(function (package)
  41. assert(package:has_cincludes("wolfssl/ssl.h"))
  42. end)