2
0
Эх сурвалжийг харах

openssl3: use jom instead nmake (#4741)

* openssl3: use jom instead nmake

* openssl3: update xmake.lua

* Update xmake.lua

* openssl3: fix android@windows

* openssl3: fix path on windows

---------

Co-authored-by: ruki <[email protected]>
Bai Miao 1 жил өмнө
parent
commit
5556f4069b

+ 40 - 12
packages/o/openssl3/xmake.lua

@@ -17,11 +17,21 @@ package("openssl3")
     on_fetch("fetch")
 
     on_load(function (package)
-        if package:is_plat("windows") and (not package.is_built or package:is_built()) then
-            package:add("deps", "nasm")
-            -- the perl executable found in GitForWindows will fail to build OpenSSL
-            -- see https://github.com/openssl/openssl/blob/master/NOTES-PERL.md#perl-on-windows
-            package:add("deps", "strawberry-perl", {system = false})
+        if not package:is_precompiled() then
+            if package:is_plat("windows") then
+                package:add("deps", "nasm")
+                -- the perl executable found in GitForWindows will fail to build OpenSSL
+                -- see https://github.com/openssl/openssl/blob/master/NOTES-PERL.md#perl-on-windows
+                package:add("deps", "strawberry-perl", {system = false})
+                -- check xmake tool jom
+                import("package.tools.jom", {try = true})
+                if jom then
+                    package:add("deps", "jom", {private = true})
+                end
+            elseif package:is_plat("android") and is_subhost("windows") and os.arch() == "x64" then
+                -- when building for android on windows, use msys2 perl instead of strawberry-perl to avoid configure issue
+                package:add("deps", "msys2", {configs = {msystem = "MINGW64", base_devel = true}, private = true})
+            end
         end
 
         -- @note we must use package:is_plat() instead of is_plat in description for supporting add_deps("openssl", {host = true}) in python
@@ -35,7 +45,7 @@ package("openssl3")
         elseif package:is_plat("linux", "cross") then
             package:add("syslinks", "pthread", "dl")
         end
-        if package:is_plat("linux", "mingw", "bsd") and package:is_arch("x86_64") then
+        if package:is_plat("linux", "mingw") and package:is_arch("x86_64") then
             package:add("linkdirs", "lib64")
         end
         if package:is_plat("linux") then
@@ -44,6 +54,8 @@ package("openssl3")
     end)
 
     on_install("windows", function (package)
+        import("package.tools.jom", {try = true})
+        import("package.tools.nmake")
         local configs = {"Configure", "no-tests"}
         local target
         if package:is_arch("x86", "i386") then
@@ -59,11 +71,19 @@ package("openssl3")
         table.insert(configs, package:config("shared") and "shared" or "no-shared")
         table.insert(configs, "--prefix=" .. package:installdir())
         table.insert(configs, "--openssldir=" .. package:installdir())
+        if jom then
+            table.insert(configs, "no-makedepend")
+            table.insert(configs, "/FS")
+        end
         os.vrunv("perl", configs)
 
-        local runenvs = import("package.tools.nmake").buildenvs(package)
-        local nmake = import("lib.detect.find_tool")("nmake", {envs = runenvs})
-        os.vrunv(nmake.program, {"install_sw"}, {envs = runenvs})
+        if jom then
+            jom.build(package)
+            jom.make(package, {"install_sw"})
+        else
+            nmake.build(package)
+            nmake.make(package, {"install_sw"})
+        end
     end)
 
     on_install("mingw", function (package)
@@ -139,10 +159,18 @@ package("openssl3")
                          "-DOPENSSL_NO_HEARTBEATS",
                          "no-shared",
                          "no-threads",
-                         "--openssldir=" .. package:installdir(),
-                         "--prefix=" .. package:installdir()}
+                         "--openssldir=" .. package:installdir():gsub("\\", "/"),
+                         "--prefix=" .. package:installdir():gsub("\\", "/")}
         local buildenvs = import("package.tools.autoconf").buildenvs(package)
-        os.vrunv("./Configure", configs, {envs = buildenvs})
+        if package:is_cross() and package:is_plat("android") and is_subhost("windows") then
+            buildenvs.CFLAGS = buildenvs.CFLAGS:gsub("\\", "/")
+            buildenvs.CXXFLAGS = buildenvs.CXXFLAGS:gsub("\\", "/")
+            buildenvs.CPPFLAGS = buildenvs.CPPFLAGS:gsub("\\", "/")
+            buildenvs.ASFLAGS = buildenvs.ASFLAGS:gsub("\\", "/")
+            os.vrunv("perl", table.join("./Configure", configs), {envs = buildenvs})
+        else
+            os.vrunv("./Configure", configs, {envs = buildenvs})
+        end
         local makeconfigs = {CFLAGS = buildenvs.CFLAGS, ASFLAGS = buildenvs.ASFLAGS}
         import("package.tools.make").build(package, makeconfigs)
         import("package.tools.make").make(package, {"install_sw"})