• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision1b2ff3a1820afe193f571f9cd268632cf6073b51 (tree)
Time2022-11-13 21:09:29
AuthorFs <Fsu0413@vip....>
CommiterFs

Log Message

macOS unified OpenSSL builds

Signed-off-by: Fs <Fsu0413@vip.qq.com>

Change Summary

Incremental Difference

--- a/Compile/lib/Configuration.lua
+++ b/Compile/lib/Configuration.lua
@@ -510,20 +510,55 @@ conf.OpenSSL.generateConfTable = function(self, host, job)
510510 -- dirty hack end
511511 ret.download = {}
512512
513- if confDetail.opensslAndroidAll then
514- -- currently this part of script runs only on whatever Linux host (CentOS8 / Rocky9 on my build environment) and no Windows compatibility is made.
513+ -- DO REMEMBER TO USE tostring IF A VERSION STRING IS NEEDED!!
514+ local hostToolchainVersion, targetToolchainVersion
515+ local hostToolchainVersionQueryFuncName = "gcc"
516+ local hostToolchainVersionQueryPath
517+ local hostToolchainExecutableName = confHost.defaultToolchainExecutableName
518+
519+ if confDetail.toolchain ~= "PATH" then
520+ local paths = confHost.toolchainPath[confDetail.toolchain]
521+ if type(confHost.toolchainPath[confDetail.toolchain]) == "string" then
522+ paths = {confHost.toolchainPath[confDetail.toolchain]}
523+ end
524+ hostToolchainVersionQueryPath = paths[1]
525+ if string.sub(confDetail.toolchain, 1, 4) == "MSVC" then
526+ hostToolchainVersionQueryFuncName = "msvc"
527+ ret.msvcBat = paths[1]
528+ table.remove(paths, 1)
529+ elseif string.sub(confDetail.toolchain, 1, 9) == "MinGWLLVM" then
530+ hostToolchainVersionQueryPath = paths[2]
531+ hostToolchainExecutableName = "clang"
532+ end
533+ for _, x in ipairs(paths) do
534+ table.insert(ret.path, x)
535+ end
536+ end
537+
538+ hostToolchainVersion = compilerVer[hostToolchainVersionQueryFuncName](confHost.makefileTemplate == "win", hostToolchainVersionQueryPath, hostToolchainExecutableName)
539+
540+ if confDetail.opensslUnifyType then
541+ -- This part of script runs only on whatever Unix-like host (CentOS8 / Rocky9 / macOS on my build environment) and no Windows compatibility is made.
515542 -- no plan for Windows support.
516- ret.buildContent = "OpenSSLAndroidAll"
517- ret.INSTALLROOT = ret.WORKSPACE .. confHost.pathSep .. "buildDir" .. confHost.pathSep .. confDetail.name
518- ret.INSTALLPATH = confDetail.name
543+
544+ -- Useful for building a unified package for Android / macOS
545+
546+ if confDetail.opensslUnifyType == "macOS" then
547+ -- macOS build uses unified clang
548+ targetToolchainVersion = hostToolchainVersion
549+ end
550+
551+ ret.buildContent = "OpenSSLUnify" .. confDetail.opensslUnifyType
552+ ret.INSTALLROOT = ret.WORKSPACE .. confHost.pathSep .. "buildDir" .. confHost.pathSep .. replaceVersion(confDetail.name, hostToolchainVersion, targetToolchainVersion)
553+ ret.INSTALLPATH = replaceVersion(confDetail.name, hostToolchainVersion, targetToolchainVersion)
519554 ret.OPENSSLDIRFUNCTION = ""
520555
521556 local repl = {}
522557 repl.arch = {}
523558
524- for arch, androidConf in pairs(confDetail.opensslAndroidAll) do
525- table.insert(ret.download, conf.OpenSSL:binaryFileDownloadPath(confHost, androidConf))
526- ret.OPENSSLDIRFUNCTION = ret.OPENSSLDIRFUNCTION .. "if [ \"x$1\" = \"x" .. arch .. "\" ]; then\n" .. "CURRENTARCHDIR=\"" .. conf.OpenSSL.configurations[androidConf].name .. "\"\nexport CURRENTARCHDIR\nel"
559+ for arch, unifiedConf in pairs(confDetail.opensslUnifyArch) do
560+ table.insert(ret.download, conf.OpenSSL:binaryFileDownloadPath(confHost, unifiedConf, targetToolchainVersion))
561+ ret.OPENSSLDIRFUNCTION = ret.OPENSSLDIRFUNCTION .. "if [ \"x$1\" = \"x" .. arch .. "\" ]; then\n" .. "CURRENTARCHDIR=\"" .. replaceVersion(conf.OpenSSL.configurations[unifiedConf].name, hostToolchainVersion, targetToolchainVersion) .. "\"\nexport CURRENTARCHDIR\nel"
527562 table.insert(repl.arch, arch)
528563 end
529564
@@ -539,33 +574,6 @@ conf.OpenSSL.generateConfTable = function(self, host, job)
539574 ret.INSTALLCOMMANDLINE = " "
540575 table.insert(ret.download, confDetail["sourcePackageUrl" .. confHost.makefileTemplate])
541576
542- -- DO REMEMBER TO USE tostring IF A VERSION STRING IS NEEDED!!
543- local hostToolchainVersion, targetToolchainVersion
544- local hostToolchainVersionQueryFuncName = "gcc"
545- local hostToolchainVersionQueryPath
546- local hostToolchainExecutableName = confHost.defaultToolchainExecutableName
547-
548- if confDetail.toolchain ~= "PATH" then
549- local paths = confHost.toolchainPath[confDetail.toolchain]
550- if type(confHost.toolchainPath[confDetail.toolchain]) == "string" then
551- paths = {confHost.toolchainPath[confDetail.toolchain]}
552- end
553- hostToolchainVersionQueryPath = paths[1]
554- if string.sub(confDetail.toolchain, 1, 4) == "MSVC" then
555- hostToolchainVersionQueryFuncName = "msvc"
556- ret.msvcBat = paths[1]
557- table.remove(paths, 1)
558- elseif string.sub(confDetail.toolchain, 1, 9) == "MinGWLLVM" then
559- hostToolchainVersionQueryPath = paths[2]
560- hostToolchainExecutableName = "clang"
561- end
562- for _, x in ipairs(paths) do
563- table.insert(ret.path, x)
564- end
565- end
566-
567- hostToolchainVersion = compilerVer[hostToolchainVersionQueryFuncName](confHost.makefileTemplate == "win", hostToolchainVersionQueryPath, hostToolchainExecutableName)
568-
569577 ret.envSet = {}
570578
571579 local repl = {}
--- a/Compile/lib/Generate.lua
+++ b/Compile/lib/Generate.lua
@@ -75,6 +75,8 @@ for %%i in (aria2c curl wget) do (
7575 )
7676 )
7777
78+rem TODO - set --no-conf parameter to aria2c
79+
7880 set pd=o
7981 if "!DOWNLOADTOOL!" == "wget" set pd=O
8082
@@ -186,6 +188,8 @@ for %%i in (aria2c curl wget) do (
186188 )
187189 )
188190
191+rem TODO - set --no-conf parameter to aria2c
192+
189193 set pd=o
190194 if "!DOWNLOADTOOL!" == "wget" set pd=O
191195
@@ -275,8 +279,11 @@ gen.unix.download = "$DOWNLOADTOOL -$DOWNLOADP"
275279 -- EXTRAINSTALL
276280 -- INSTALLPATHWITHDATE
277281 gen.unix.template4Qt = [[
282+
278283 set -x
279284
285+unset JAVA_HOME
286+
280287 DOWNLOADTOOL=
281288
282289 for i in aria2c wget curl; do
@@ -295,6 +302,10 @@ if [ "x$DOWNLOADTOOL" = "x" ]; then
295302 exit 1
296303 fi
297304
305+if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then
306+ DOWNLOADTOOL="aria2c --no-conf"
307+fi
308+
298309 DOWNLOADP="o"
299310 if [ "x$DOWNLOADTOOL" = "xwget" ]; then
300311 DOWNLOADP="O"
@@ -420,6 +431,8 @@ popd
420431 gen.unix.template4OpenSSL = [[
421432 set -x
422433
434+unset JAVA_HOME
435+
423436 DOWNLOADTOOL=
424437
425438 for i in aria2c wget curl; do
@@ -438,6 +451,10 @@ if [ "x$DOWNLOADTOOL" = "x" ]; then
438451 exit 1
439452 fi
440453
454+if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then
455+ DOWNLOADTOOL="aria2c --no-conf"
456+fi
457+
441458 DOWNLOADP="o"
442459 if [ "x$DOWNLOADTOOL" = "xwget" ]; then
443460 DOWNLOADP="O"
@@ -520,9 +537,11 @@ exit 0
520537 -- WORKSPACE
521538 -- INSTALLROOT
522539 -- INSTALLPATH
523-gen.unix.template4OpenSSLAndroidAll = [[
540+gen.unix.template4OpenSSLUnifyAndroid = [[
524541 set -x
525542
543+unset JAVA_HOME
544+
526545 DOWNLOADTOOL=
527546
528547 for i in aria2c wget curl; do
@@ -541,6 +560,10 @@ if [ "x$DOWNLOADTOOL" = "x" ]; then
541560 exit 1
542561 fi
543562
563+if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then
564+ DOWNLOADTOOL="aria2c --no-conf"
565+fi
566+
544567 DOWNLOADP="o"
545568 if [ "x$DOWNLOADTOOL" = "xwget" ]; then
546569 DOWNLOADP="O"
@@ -575,8 +598,8 @@ done
575598 &DELETEUNCOMPRESSED&
576599
577600 getOpenSSLDir() {
578-&OPENSSLDIRFUNCTION&
579-return 0
601+ &OPENSSLDIRFUNCTION&
602+ return 0
580603 }
581604
582605 &PATHSET&
@@ -587,23 +610,156 @@ rm -rf &INSTALLROOT&
587610 mkdir &INSTALLROOT&
588611 cd &INSTALLROOT&
589612
590-mkdir lib
591-mkdir bin
613+mkdir lib bin
592614
593615 for ar in &ARCHITECTURES&; do
594616 getOpenSSLDir "$ar"
595617 if [ $? -ne 0 ]; then
596618 exit 1
597619 fi
620+ # It is certain that we built OpenSSL to static library
621+ # so all we need are following files
598622 cp ../$CURRENTARCHDIR/lib/libssl.a ./lib/libssl_$ar.a
599623 cp ../$CURRENTARCHDIR/lib/libcrypto.a ./lib/libcrypto_$ar.a
600624 cp ../$CURRENTARCHDIR/bin/openssl ./bin/openssl_$ar
601- if [ "x$ar" = "xarm64-v8a" ]; then
625+ if ! [ -d include ]; then
626+ cp -R ../$CURRENTARCHDIR/include ./include
627+ fi
628+ if ! [ -d ssl ]; then
629+ cp -R ../$CURRENTARCHDIR/ssl ./ssl
630+ fi
631+done
632+
633+cd &INSTALLROOT&/..
634+
635+$TAR -cf - &INSTALLPATH& | $SEVENZIP a -txz -m0=LZMA2:d256m:fb273 -mmt=3 -myx -si -- &INSTALLPATH&.tar.xz
636+$SEVENZIP a -t7z -m0=LZMA2:d256m:fb273 -mmt=3 -myx -mqs -ms=on -- &INSTALLPATH&.7z &INSTALLPATH&
637+
638+exit 0
639+
640+]]
641+
642+-- PATHSET
643+-- ENVSET
644+-- OPENSSLDIRFUNCTION
645+-- ARCHITECTURES
646+-- WORKSPACE
647+-- INSTALLROOT
648+-- INSTALLPATH
649+gen.unix.template4OpenSSLUnifymacOS = [[
650+set -x
651+
652+unset JAVA_HOME
653+
654+DOWNLOADTOOL=
655+
656+for i in aria2c wget curl; do
657+ p="--help"
658+ if [ x$i = xaria2c ]; then
659+ p="-h"
660+ fi
661+ if $i $p >/dev/null 2>/dev/null; then
662+ DOWNLOADTOOL=$i
663+ break
664+ fi
665+done
666+
667+if [ "x$DOWNLOADTOOL" = "x" ]; then
668+ echo "no download tool" >&2
669+ exit 1
670+fi
671+
672+if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then
673+ DOWNLOADTOOL="aria2c --no-conf"
674+fi
675+
676+DOWNLOADP="o"
677+if [ "x$DOWNLOADTOOL" = "xwget" ]; then
678+ DOWNLOADP="O"
679+fi
680+
681+&DOWNLOADPACKAGE&
682+
683+TAR=
684+
685+for i in bsdtar tar; do
686+ if $i --help; then
687+ TAR=$i
688+ break
689+ fi
690+done
691+
692+if [ "x$TAR" = "x" ]; then
693+ echo "tar not found" >&2
694+ exit 1
695+fi
696+
697+SEVENZIP=
698+
699+for i in 7zr 7za 7z; do
700+ if $i >/dev/null 2>/dev/null; then
701+ SEVENZIP=$i
702+ break
703+ fi
704+done
705+
706+&UNCOMPRESSPACKAGE&
707+&DELETEUNCOMPRESSED&
708+
709+getOpenSSLDir() {
710+ &OPENSSLDIRFUNCTION&
711+ return 0
712+}
713+
714+MakeOpenSSLLibLinks()
715+{
716+ while [ "$#" -gt 0 ]; do
717+ ln -s "$1" "$2"
718+ shift
719+ shift
720+ done
721+}
722+
723+&PATHSET&
724+
725+&ENVSET&
726+
727+rm -rf &INSTALLROOT&
728+mkdir &INSTALLROOT&
729+cd &INSTALLROOT&
730+
731+# We builds only OpenSSL 3 on macOS so following are only for OpenSSL 3.
732+
733+mkdir lib bin
734+mkdir lib/ossl-modules
735+
736+LIPONAMES="bin/openssl lib/libssl.3.dylib lib/libcrypto.3.dylib lib/libssl.a lib/libcrypto.a lib/ossl-modules/legacy.dylib"
737+
738+for ar in &ARCHITECTURES&; do
739+ getOpenSSLDir "$ar"
740+ if [ $? -ne 0 ]; then
741+ exit 1
742+ fi
743+ if ! [ -d include ]; then
602744 cp -R ../$CURRENTARCHDIR/include ./include
745+ fi
746+ if ! [ -d ssl ]; then
603747 cp -R ../$CURRENTARCHDIR/ssl ./ssl
604748 fi
605749 done
606750
751+for n in $LIPONAMES; do
752+ EXECUTABLELIST=
753+ for ar in &ARCHITECTURES&; do
754+ getOpenSSLDir "$ar"
755+ EXECUTABLELIST=$EXECUTABLELIST\ "../$CURRENTARCHDIR/$n"
756+ done
757+
758+ lipo $EXECUTABLELIST -create -output "$n"
759+done
760+
761+MakeOpenSSLLibLinks libssl.3.dylib lib/libssl.dylib libcrypto.3.dylib lib/libcrypto.dylib
762+
607763 cd &INSTALLROOT&/..
608764
609765 $TAR -cf - &INSTALLPATH& | $SEVENZIP a -txz -m0=LZMA2:d256m:fb273 -mmt=3 -myx -si -- &INSTALLPATH&.tar.xz
@@ -655,7 +811,7 @@ gen.generate = function(self, para)
655811 return
656812 end
657813
658- if template == "OpenSSLAndroidAll" then
814+ if string.sub(template, 1, 12) == "OpenSSLUnify" then
659815 if para.template ~= "unix" then
660816 print("[Generate.generate] ERROR: Generation of OpenSSL Android All builds is not available in para.template ~= \"unix\"")
661817 os.exit(1)
--- a/Compile/lib/opensslCompile/conf.lua
+++ b/Compile/lib/opensslCompile/conf.lua
@@ -338,7 +338,8 @@ conf.o1aalnl = {
338338 name = "OpenSSL1.1.1s-Android-ALL-NDKr21eAPI21",
339339 opensslVersion = "1.1.1s",
340340 host = "CentOS8",
341- opensslAndroidAll = {
341+ opensslUnifyType = "Android",
342+ opensslUnifyArch = {
342343 ["armeabi-v7a"] = "o1aa3nl",
343344 ["arm64-v8a"] = "o1aa6nl",
344345 ["x86"] = "o1ax3nl",
@@ -441,7 +442,8 @@ conf.o1aaln321 = {
441442 name = "OpenSSL1.1.1s-Android-ALL-NDKr23cAPI21",
442443 opensslVersion = "1.1.1s",
443444 host = "CentOS8",
444- opensslAndroidAll = {
445+ opensslUnifyType = "Android",
446+ opensslUnifyArch = {
445447 ["armeabi-v7a"] = "o1aa3n321",
446448 ["arm64-v8a"] = "o1aa6n321",
447449 ["x86"] = "o1ax3n321",
@@ -605,10 +607,11 @@ conf.o3wx6s5 = {
605607
606608 --------------------------------------------------------------------
607609
610+-- cross build this configuration for easy unify
608611 conf.o3mx6 = {
609612 name = "OpenSSL3.0.7-macOS-x86_64-AppleClang&TARGETTOOLVERSION&",
610613 opensslVersion = "3.0.7",
611- host = "macOS1015",
614+ host = "macOSM1",
612615 libPath = { "lib/libssl.3.dylib", "lib/libcrypto.3.dylib" },
613616 staticlibPath = { "lib/libssl.a", "lib/libcrypto.a" },
614617 configureParameter = [[
@@ -639,6 +642,19 @@ conf.o3ma6 = {
639642 ]],
640643 }
641644
645+conf.o3mal = {
646+ name = "OpenSSL3.0.7-macOS-ALL-AppleClang&TARGETTOOLVERSION&",
647+ opensslVersion = "3.0.7",
648+ host = "macOSM1",
649+ libPath = { "lib/libssl.3.dylib", "lib/libcrypto.3.dylib" },
650+ staticlibPath = { "lib/libssl.a", "lib/libcrypto.a" },
651+ opensslUnifyType = "macOS",
652+ opensslUnifyArch = {
653+ ["arm64"] = "o3ma6",
654+ ["x86_64"] = "o3mx6",
655+ },
656+}
657+
642658 --------------------------------------------------------------------
643659
644660 conf.o3aa3n324 = {
@@ -734,7 +750,8 @@ conf.o3aaln324 = {
734750 name = "OpenSSL3.0.7-Android-ALL-NDKr23cAPI24",
735751 opensslVersion = "3.0.7",
736752 host = "CentOS8",
737- opensslAndroidAll = {
753+ opensslUnifyType = "Android",
754+ opensslUnifyArch = {
738755 ["armeabi-v7a"] = "o3aa3n324",
739756 ["arm64-v8a"] = "o3aa6n324",
740757 ["x86"] = "o3ax3n324",
@@ -836,7 +853,8 @@ conf.o3aaln527 = {
836853 name = "OpenSSL3.0.7-Android-ALL-NDKr25API27",
837854 opensslVersion = "3.0.7",
838855 host = "Rocky9",
839- opensslAndroidAll = {
856+ opensslUnifyType = "Android",
857+ opensslUnifyArch = {
840858 ["armeabi-v7a"] = "o3aa3n527",
841859 ["arm64-v8a"] = "o3aa6n527",
842860 ["x86"] = "o3ax3n527",