fetch.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import("lib.detect.find_path")
  2. import("lib.detect.find_library")
  3. -- http://www.slproweb.com/products/Win32OpenSSL.html
  4. function _find_package_on_windows(package, opt)
  5. local bits = package:is_plat("x86") and "32" or "64"
  6. local paths = {"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL %(" .. bits .. "-bit%)_is1;Inno Setup: App Path)",
  7. "$(env PROGRAMFILES)/OpenSSL",
  8. "$(env PROGRAMFILES)/OpenSSL-Win" .. bits,
  9. "C:/OpenSSL",
  10. "C:/OpenSSL-Win" .. bits}
  11. local result = {links = {}, linkdirs = {}, includedirs = {}}
  12. for _, name in ipairs({"libssl", "libcrypto"}) do
  13. local linkinfo = find_library(name, paths, {suffixes = "lib"})
  14. if linkinfo then
  15. table.insert(result.links, linkinfo.link)
  16. table.insert(result.linkdirs, linkinfo.linkdir)
  17. end
  18. end
  19. if #result.links ~= 2 then
  20. return
  21. end
  22. table.insert(result.includedirs, find_path(path.translate("openssl/ssl.h"), paths, {suffixes = "include"}))
  23. return result
  24. end
  25. function main(package, opt)
  26. if opt.system and package.find_package then
  27. local result
  28. if package:is_plat("windows", "mingw", "msys") and is_host("windows") then
  29. result = _find_package_on_windows(package, opt)
  30. else
  31. result = package:find_package("openssl", opt)
  32. end
  33. return result or false
  34. end
  35. end