build_package_image.py 2.8 KB

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