123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #!/usr/bin/env python3
- #
- # 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.
- #
- # SPDX-License-Identifier: Apache-2.0 OR MIT
- #
- #
- from pathlib import Path
- from tempfile import TemporaryDirectory
- import argparse
- import os
- import subprocess
- import sys
- sys.path.append(str(Path(__file__).parent.parent.parent / 'Scripts'))
- from builders.vcpkgbuilder import VcpkgBuilder
- import builders.monkeypatch_tempdir_cleanup
- def main():
- parser = argparse.ArgumentParser()
- parser.add_argument(
- '--platform-name',
- dest='platformName',
- choices=['windows', 'android', 'mac', 'ios'],
- default=VcpkgBuilder.defaultPackagePlatformName(),
- )
- args = parser.parse_args()
- packageSystemDir = Path(__file__).resolve().parents[1]
- opensslPackageSourceDir = packageSystemDir / 'OpenSSL'
- outputDir = opensslPackageSourceDir / 'temp' / f'OpenSSL-{args.platformName}'
- opensslPatch = opensslPackageSourceDir / 'set_openssl_port_to_1_1_1_x.patch'
- enableStdioOnIOS = opensslPackageSourceDir / 'enable-stdio-on-iOS.patch'
- cmakeFindFile = opensslPackageSourceDir / 'FindOpenSSL.cmake.template'
- cmakeFindFileTemplate = cmakeFindFile.open().read()
- useStaticLibsForPlatform = {
- 'android': True,
- 'mac': True,
- 'ios': True,
- 'windows': True,
- }
- revisionForPlatform = {
- 'android': 'rev2',
- 'mac': 'rev1',
- 'ios': 'rev1',
- 'windows': 'rev1'
- }
- testScriptForPlatform = {
- 'android' : opensslPackageSourceDir / 'test_OpenSSL_android.cmd',
- 'mac' : opensslPackageSourceDir / 'test_OpenSSL_mac.sh',
- 'ios' : opensslPackageSourceDir / 'test_OpenSSL_ios.sh',
- 'windows' : opensslPackageSourceDir / 'test_OpenSSL_windows.cmd'
- }
- with TemporaryDirectory() as tempdir:
- tempdir = Path(tempdir)
- builder = VcpkgBuilder(packageName='OpenSSL', portName='openssl', vcpkgDir=tempdir, targetPlatform=args.platformName, static=useStaticLibsForPlatform[args.platformName])
- builder.deleteFolder(outputDir)
- builder.cloneVcpkg('b86c0c35b88e2bf3557ff49dc831689c2f085090')
- builder.bootstrap()
- builder.patch(opensslPatch)
- builder.patch(enableStdioOnIOS)
- builder.build()
- builder.copyBuildOutputTo(
- outputDir,
- extraFiles={
- next(builder.vcpkgDir.glob(f'buildtrees/openssl/{builder.triplet}-rel/**/LICENSE')): outputDir / builder.packageName / 'LICENSE',
- })
- revisionName = revisionForPlatform[args.platformName]
- builder.writePackageInfoFile(
- outputDir,
- settings={
- 'PackageName': f'OpenSSL-1.1.1o-{revisionName}-{args.platformName}',
- 'URL': 'https://github.com/openssl/openssl',
- 'License': 'OpenSSL',
- 'LicenseFile': 'OpenSSL/LICENSE'
- },
- )
- crypto_library_dependencies = ''
- if args.platformName == 'windows':
- crypto_library_dependencies = 'crypt32.lib ws2_32.lib'
- builder.writeCMakeFindFile(
- outputDir,
- template=cmakeFindFileTemplate,
- templateEnv={
- 'CRYPTO_LIBRARY_DEPENDENCIES':crypto_library_dependencies
- },
- )
- # now test the package, it will be in outputDir
- customEnviron = os.environ.copy()
- customEnviron["PACKAGE_ROOT"] = str(outputDir.resolve())
- scriptpath = testScriptForPlatform[args.platformName].resolve()
- cwdpath = opensslPackageSourceDir.resolve()
- print(f'Running test script "{scriptpath}" with package "{outputDir}" with cwd "{cwdpath}"')
- subprocess.check_call(
- [ str(scriptpath) ],
- cwd=str(cwdpath),
- env=customEnviron
- )
-
- if __name__ == '__main__':
- main()
|