Revision | 1b2ff3a1820afe193f571f9cd268632cf6073b51 (tree) |
---|---|
Time | 2022-11-13 21:09:29 |
Author | Fs <Fsu0413@vip....> |
Commiter | Fs |
macOS unified OpenSSL builds
Signed-off-by: Fs <Fsu0413@vip.qq.com>
@@ -510,20 +510,55 @@ conf.OpenSSL.generateConfTable = function(self, host, job) | ||
510 | 510 | -- dirty hack end |
511 | 511 | ret.download = {} |
512 | 512 | |
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. | |
515 | 542 | -- 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) | |
519 | 554 | ret.OPENSSLDIRFUNCTION = "" |
520 | 555 | |
521 | 556 | local repl = {} |
522 | 557 | repl.arch = {} |
523 | 558 | |
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" | |
527 | 562 | table.insert(repl.arch, arch) |
528 | 563 | end |
529 | 564 |
@@ -539,33 +574,6 @@ conf.OpenSSL.generateConfTable = function(self, host, job) | ||
539 | 574 | ret.INSTALLCOMMANDLINE = " " |
540 | 575 | table.insert(ret.download, confDetail["sourcePackageUrl" .. confHost.makefileTemplate]) |
541 | 576 | |
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 | - | |
569 | 577 | ret.envSet = {} |
570 | 578 | |
571 | 579 | local repl = {} |
@@ -75,6 +75,8 @@ for %%i in (aria2c curl wget) do ( | ||
75 | 75 | ) |
76 | 76 | ) |
77 | 77 | |
78 | +rem TODO - set --no-conf parameter to aria2c | |
79 | + | |
78 | 80 | set pd=o |
79 | 81 | if "!DOWNLOADTOOL!" == "wget" set pd=O |
80 | 82 |
@@ -186,6 +188,8 @@ for %%i in (aria2c curl wget) do ( | ||
186 | 188 | ) |
187 | 189 | ) |
188 | 190 | |
191 | +rem TODO - set --no-conf parameter to aria2c | |
192 | + | |
189 | 193 | set pd=o |
190 | 194 | if "!DOWNLOADTOOL!" == "wget" set pd=O |
191 | 195 |
@@ -275,8 +279,11 @@ gen.unix.download = "$DOWNLOADTOOL -$DOWNLOADP" | ||
275 | 279 | -- EXTRAINSTALL |
276 | 280 | -- INSTALLPATHWITHDATE |
277 | 281 | gen.unix.template4Qt = [[ |
282 | + | |
278 | 283 | set -x |
279 | 284 | |
285 | +unset JAVA_HOME | |
286 | + | |
280 | 287 | DOWNLOADTOOL= |
281 | 288 | |
282 | 289 | for i in aria2c wget curl; do |
@@ -295,6 +302,10 @@ if [ "x$DOWNLOADTOOL" = "x" ]; then | ||
295 | 302 | exit 1 |
296 | 303 | fi |
297 | 304 | |
305 | +if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then | |
306 | + DOWNLOADTOOL="aria2c --no-conf" | |
307 | +fi | |
308 | + | |
298 | 309 | DOWNLOADP="o" |
299 | 310 | if [ "x$DOWNLOADTOOL" = "xwget" ]; then |
300 | 311 | DOWNLOADP="O" |
@@ -420,6 +431,8 @@ popd | ||
420 | 431 | gen.unix.template4OpenSSL = [[ |
421 | 432 | set -x |
422 | 433 | |
434 | +unset JAVA_HOME | |
435 | + | |
423 | 436 | DOWNLOADTOOL= |
424 | 437 | |
425 | 438 | for i in aria2c wget curl; do |
@@ -438,6 +451,10 @@ if [ "x$DOWNLOADTOOL" = "x" ]; then | ||
438 | 451 | exit 1 |
439 | 452 | fi |
440 | 453 | |
454 | +if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then | |
455 | + DOWNLOADTOOL="aria2c --no-conf" | |
456 | +fi | |
457 | + | |
441 | 458 | DOWNLOADP="o" |
442 | 459 | if [ "x$DOWNLOADTOOL" = "xwget" ]; then |
443 | 460 | DOWNLOADP="O" |
@@ -520,9 +537,11 @@ exit 0 | ||
520 | 537 | -- WORKSPACE |
521 | 538 | -- INSTALLROOT |
522 | 539 | -- INSTALLPATH |
523 | -gen.unix.template4OpenSSLAndroidAll = [[ | |
540 | +gen.unix.template4OpenSSLUnifyAndroid = [[ | |
524 | 541 | set -x |
525 | 542 | |
543 | +unset JAVA_HOME | |
544 | + | |
526 | 545 | DOWNLOADTOOL= |
527 | 546 | |
528 | 547 | for i in aria2c wget curl; do |
@@ -541,6 +560,10 @@ if [ "x$DOWNLOADTOOL" = "x" ]; then | ||
541 | 560 | exit 1 |
542 | 561 | fi |
543 | 562 | |
563 | +if [ "x$DOWNLOADTOOL" = "xaria2c" ]; then | |
564 | + DOWNLOADTOOL="aria2c --no-conf" | |
565 | +fi | |
566 | + | |
544 | 567 | DOWNLOADP="o" |
545 | 568 | if [ "x$DOWNLOADTOOL" = "xwget" ]; then |
546 | 569 | DOWNLOADP="O" |
@@ -575,8 +598,8 @@ done | ||
575 | 598 | &DELETEUNCOMPRESSED& |
576 | 599 | |
577 | 600 | getOpenSSLDir() { |
578 | -&OPENSSLDIRFUNCTION& | |
579 | -return 0 | |
601 | + &OPENSSLDIRFUNCTION& | |
602 | + return 0 | |
580 | 603 | } |
581 | 604 | |
582 | 605 | &PATHSET& |
@@ -587,23 +610,156 @@ rm -rf &INSTALLROOT& | ||
587 | 610 | mkdir &INSTALLROOT& |
588 | 611 | cd &INSTALLROOT& |
589 | 612 | |
590 | -mkdir lib | |
591 | -mkdir bin | |
613 | +mkdir lib bin | |
592 | 614 | |
593 | 615 | for ar in &ARCHITECTURES&; do |
594 | 616 | getOpenSSLDir "$ar" |
595 | 617 | if [ $? -ne 0 ]; then |
596 | 618 | exit 1 |
597 | 619 | fi |
620 | + # It is certain that we built OpenSSL to static library | |
621 | + # so all we need are following files | |
598 | 622 | cp ../$CURRENTARCHDIR/lib/libssl.a ./lib/libssl_$ar.a |
599 | 623 | cp ../$CURRENTARCHDIR/lib/libcrypto.a ./lib/libcrypto_$ar.a |
600 | 624 | 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 | |
602 | 744 | cp -R ../$CURRENTARCHDIR/include ./include |
745 | + fi | |
746 | + if ! [ -d ssl ]; then | |
603 | 747 | cp -R ../$CURRENTARCHDIR/ssl ./ssl |
604 | 748 | fi |
605 | 749 | done |
606 | 750 | |
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 | + | |
607 | 763 | cd &INSTALLROOT&/.. |
608 | 764 | |
609 | 765 | $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) | ||
655 | 811 | return |
656 | 812 | end |
657 | 813 | |
658 | - if template == "OpenSSLAndroidAll" then | |
814 | + if string.sub(template, 1, 12) == "OpenSSLUnify" then | |
659 | 815 | if para.template ~= "unix" then |
660 | 816 | print("[Generate.generate] ERROR: Generation of OpenSSL Android All builds is not available in para.template ~= \"unix\"") |
661 | 817 | os.exit(1) |
@@ -338,7 +338,8 @@ conf.o1aalnl = { | ||
338 | 338 | name = "OpenSSL1.1.1s-Android-ALL-NDKr21eAPI21", |
339 | 339 | opensslVersion = "1.1.1s", |
340 | 340 | host = "CentOS8", |
341 | - opensslAndroidAll = { | |
341 | + opensslUnifyType = "Android", | |
342 | + opensslUnifyArch = { | |
342 | 343 | ["armeabi-v7a"] = "o1aa3nl", |
343 | 344 | ["arm64-v8a"] = "o1aa6nl", |
344 | 345 | ["x86"] = "o1ax3nl", |
@@ -441,7 +442,8 @@ conf.o1aaln321 = { | ||
441 | 442 | name = "OpenSSL1.1.1s-Android-ALL-NDKr23cAPI21", |
442 | 443 | opensslVersion = "1.1.1s", |
443 | 444 | host = "CentOS8", |
444 | - opensslAndroidAll = { | |
445 | + opensslUnifyType = "Android", | |
446 | + opensslUnifyArch = { | |
445 | 447 | ["armeabi-v7a"] = "o1aa3n321", |
446 | 448 | ["arm64-v8a"] = "o1aa6n321", |
447 | 449 | ["x86"] = "o1ax3n321", |
@@ -605,10 +607,11 @@ conf.o3wx6s5 = { | ||
605 | 607 | |
606 | 608 | -------------------------------------------------------------------- |
607 | 609 | |
610 | +-- cross build this configuration for easy unify | |
608 | 611 | conf.o3mx6 = { |
609 | 612 | name = "OpenSSL3.0.7-macOS-x86_64-AppleClang&TARGETTOOLVERSION&", |
610 | 613 | opensslVersion = "3.0.7", |
611 | - host = "macOS1015", | |
614 | + host = "macOSM1", | |
612 | 615 | libPath = { "lib/libssl.3.dylib", "lib/libcrypto.3.dylib" }, |
613 | 616 | staticlibPath = { "lib/libssl.a", "lib/libcrypto.a" }, |
614 | 617 | configureParameter = [[ |
@@ -639,6 +642,19 @@ conf.o3ma6 = { | ||
639 | 642 | ]], |
640 | 643 | } |
641 | 644 | |
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 | + | |
642 | 658 | -------------------------------------------------------------------- |
643 | 659 | |
644 | 660 | conf.o3aa3n324 = { |
@@ -734,7 +750,8 @@ conf.o3aaln324 = { | ||
734 | 750 | name = "OpenSSL3.0.7-Android-ALL-NDKr23cAPI24", |
735 | 751 | opensslVersion = "3.0.7", |
736 | 752 | host = "CentOS8", |
737 | - opensslAndroidAll = { | |
753 | + opensslUnifyType = "Android", | |
754 | + opensslUnifyArch = { | |
738 | 755 | ["armeabi-v7a"] = "o3aa3n324", |
739 | 756 | ["arm64-v8a"] = "o3aa6n324", |
740 | 757 | ["x86"] = "o3ax3n324", |
@@ -836,7 +853,8 @@ conf.o3aaln527 = { | ||
836 | 853 | name = "OpenSSL3.0.7-Android-ALL-NDKr25API27", |
837 | 854 | opensslVersion = "3.0.7", |
838 | 855 | host = "Rocky9", |
839 | - opensslAndroidAll = { | |
856 | + opensslUnifyType = "Android", | |
857 | + opensslUnifyArch = { | |
840 | 858 | ["armeabi-v7a"] = "o3aa3n527", |
841 | 859 | ["arm64-v8a"] = "o3aa6n527", |
842 | 860 | ["x86"] = "o3ax3n527", |