ruki 4 лет назад
Родитель
Сommit
20ce441fec
3 измененных файлов с 44 добавлено и 1 удалено
  1. 1 1
      packages/f/freetype/xmake.lua
  2. 41 0
      packages/o/openssl/fetch.lua
  3. 2 0
      packages/o/openssl/xmake.lua

+ 1 - 1
packages/f/freetype/xmake.lua

@@ -21,7 +21,7 @@ package("freetype")
 
     if on_fetch then
         on_fetch("linux", "macosx", function (package, opt)
-            if opt.system then
+            if opt.system and not package:is_cross() then
                 return find_package("pkgconfig::freetype2")
             end
         end)

+ 41 - 0
packages/o/openssl/fetch.lua

@@ -0,0 +1,41 @@
+import("lib.detect.find_path")
+import("lib.detect.find_library")
+
+-- http://www.slproweb.com/products/Win32OpenSSL.html
+function _find_package_on_windows(package, opt)
+    local bits = package:is_plat("x86") and "32" or "64"
+    local paths = {"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL %(" .. bits .. "-bit%)_is1;Inno Setup: App Path)",
+                    "$(env PROGRAMFILES)/OpenSSL",
+                    "$(env PROGRAMFILES)/OpenSSL-Win" .. bits,
+                    "C:/OpenSSL",
+                    "C:/OpenSSL-Win" .. bits}
+
+    local result = {links = {}, linkdirs = {}, includedirs = {}}
+    for _, name in ipairs({"libssl", "libcrypto"}) do
+        local linkinfo = find_library(name, paths, {suffixes = "lib"})
+        if linkinfo then
+            table.insert(result.links, linkinfo.link)
+            table.insert(result.linkdirs, linkinfo.linkdir)
+        end
+    end
+    if #result.links ~= 2 then
+        return
+    end
+    table.insert(result.includedirs, find_path("openssl/ssl.h", paths, {suffixes = "include"}))
+    return result
+end
+
+function main(package, opt)
+    if opt.system and not package:is_cross() and package.find_package then
+        local result
+        if package:is_plat("windows", "mingw", "msys") and is_host("windows") then
+            result = _find_package_on_windows(package, opt)
+        else
+            result = package:find_package("openssl", opt)
+            if not result and package:is_plat("linux") then
+                result = package:find_package("apt::libssl-dev", opt)
+            end
+        end
+        return result or false
+    end
+end

+ 2 - 0
packages/o/openssl/xmake.lua

@@ -24,6 +24,8 @@ package("openssl")
         add_links("ssl", "crypto")
     end
 
+    on_fetch("fetch")
+
     on_install("windows", function (package)
         local args = {"Configure"}
         table.insert(args, (package:is_arch("x86") and "VC-WIN32" or "VC-WIN64A"))