build_package_image.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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', 'linux'],
  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_b.patch'
  29. enableStdioOnIOS = opensslPackageSourceDir / 'enable-stdio-on-iOS.patch'
  30. cmakeFindFile = opensslPackageSourceDir / f'FindOpenSSL_{args.platformName}.cmake.template'
  31. if not cmakeFindFile.exists():
  32. cmakeFindFile = opensslPackageSourceDir / 'FindOpenSSL.cmake.template'
  33. cmakeFindFileTemplate = cmakeFindFile.open().read()
  34. useStaticLibsForPlatform = {
  35. 'linux': False,
  36. 'android': True,
  37. 'mac': True,
  38. 'ios': True,
  39. 'windows': True,
  40. }
  41. with TemporaryDirectory() as tempdir:
  42. tempdir = Path(tempdir)
  43. builder = VcpkgBuilder(packageName='OpenSSL', portName='openssl', vcpkgDir=tempdir, targetPlatform=args.platformName, static=useStaticLibsForPlatform[args.platformName])
  44. builder.cloneVcpkg('f44fb85b341b8f58815b95c84d8488126b251570')
  45. builder.bootstrap()
  46. builder.patch(opensslPatch)
  47. builder.patch(enableStdioOnIOS)
  48. builder.build()
  49. builder.copyBuildOutputTo(
  50. outputDir,
  51. extraFiles={
  52. next(builder.vcpkgDir.glob(f'buildtrees/openssl/{builder.triplet}-rel/**/LICENSE')): outputDir / builder.packageName / 'LICENSE',
  53. })
  54. builder.writePackageInfoFile(
  55. outputDir,
  56. settings={
  57. 'PackageName': f'OpenSSL-1.1.1b-rev2-{args.platformName}',
  58. 'URL': 'https://github.com/openssl/openssl',
  59. 'License': 'OpenSSL',
  60. 'LicenseFile': 'OpenSSL/LICENSE'
  61. },
  62. )
  63. extraLibs = []
  64. compileDefs = []
  65. if args.platformName == 'windows':
  66. extraLibs.append('crypt32.lib')
  67. builder.writeCMakeFindFile(
  68. outputDir,
  69. template=cmakeFindFileTemplate,
  70. templateEnv={
  71. 'CUSTOM_ADDITIONAL_LIBRARIES':extraLibs,
  72. 'CUSTOM_ADDITIONAL_COMPILE_DEFINITIONS':compileDefs,
  73. },
  74. )
  75. if __name__ == '__main__':
  76. main()