2
0

build_package_image.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. from pathlib import Path
  9. from tempfile import TemporaryDirectory
  10. import argparse
  11. import sys
  12. sys.path.append(str(Path(__file__).parent.parent.parent / 'Scripts'))
  13. from builders.vcpkgbuilder import VcpkgBuilder
  14. import builders.monkeypatch_tempdir_cleanup
  15. def main():
  16. parser = argparse.ArgumentParser()
  17. parser.add_argument(
  18. '--platform-name',
  19. dest='platformName',
  20. choices=['windows', 'android', 'mac', 'ios', 'linux'],
  21. default=VcpkgBuilder.defaultPackagePlatformName(),
  22. )
  23. args = parser.parse_args()
  24. packageSystemDir = Path(__file__).resolve().parents[1]
  25. opensslPackageSourceDir = packageSystemDir / 'OpenSSL'
  26. outputDir = packageSystemDir / f'OpenSSL-{args.platformName}'
  27. opensslPatch = opensslPackageSourceDir / 'set_openssl_port_to_1_1_1_b.patch'
  28. enableStdioOnIOS = opensslPackageSourceDir / 'enable-stdio-on-iOS.patch'
  29. cmakeFindFile = opensslPackageSourceDir / f'FindOpenSSL_{args.platformName}.cmake.template'
  30. if not cmakeFindFile.exists():
  31. cmakeFindFile = opensslPackageSourceDir / 'FindOpenSSL.cmake.template'
  32. cmakeFindFileTemplate = cmakeFindFile.open().read()
  33. useStaticLibsForPlatform = {
  34. 'linux': False,
  35. 'android': True,
  36. 'mac': True,
  37. 'ios': True,
  38. 'windows': True,
  39. }
  40. with TemporaryDirectory() as tempdir:
  41. tempdir = Path(tempdir)
  42. builder = VcpkgBuilder(packageName='OpenSSL', portName='openssl', vcpkgDir=tempdir, targetPlatform=args.platformName, static=useStaticLibsForPlatform[args.platformName])
  43. builder.cloneVcpkg('f44fb85b341b8f58815b95c84d8488126b251570')
  44. builder.bootstrap()
  45. builder.patch(opensslPatch)
  46. builder.patch(enableStdioOnIOS)
  47. builder.build()
  48. builder.copyBuildOutputTo(
  49. outputDir,
  50. extraFiles={
  51. next(builder.vcpkgDir.glob(f'buildtrees/openssl/{builder.triplet}-rel/**/LICENSE')): outputDir / builder.packageName / 'LICENSE',
  52. })
  53. builder.writePackageInfoFile(
  54. outputDir,
  55. settings={
  56. 'PackageName': f'OpenSSL-1.1.1b-rev2-{args.platformName}',
  57. 'URL': 'https://github.com/openssl/openssl',
  58. 'License': 'OpenSSL',
  59. 'LicenseFile': 'OpenSSL/LICENSE'
  60. },
  61. )
  62. extraLibs = []
  63. compileDefs = []
  64. if args.platformName == 'windows':
  65. extraLibs.append('crypt32.lib')
  66. builder.writeCMakeFindFile(
  67. outputDir,
  68. template=cmakeFindFileTemplate,
  69. templateEnv={
  70. 'CUSTOM_ADDITIONAL_LIBRARIES':extraLibs,
  71. 'CUSTOM_ADDITIONAL_COMPILE_DEFINITIONS':compileDefs,
  72. },
  73. )
  74. if __name__ == '__main__':
  75. main()