feat(hos_client_create, hos_client_destory): 多次调用destory不会导致重复释放

This commit is contained in:
彭宣正
2020-12-14 17:24:58 +08:00
parent 505d529c32
commit 10b370e486
55976 changed files with 8544395 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
# exceptions due to naming conflicts between our external projects (curl/openssl) and implementations that use those libraries
!patches/zlib
!patches/curl

View File

@@ -0,0 +1,12 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#
SET( HAVE_GLIBC_STRERROR_R 1 CACHE STRING "Result from TRY_RUN" FORCE)
SET( HAVE_GLIBC_STRERROR_R__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE)
SET( HAVE_POSIX_STRERROR_R 0 CACHE STRING "Result from TRY_RUN" FORCE)
SET( HAVE_POSIX_STRERROR_R__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE)
SET( HAVE_POLL_FINE_EXITCODE 0 CACHE STRING "Result from TRY_RUN" FORCE )
SET( HAVE_POLL_FINE_EXITCODE__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE)
SET( OPENSSL_CRYPTO_LIBRARY crypto CACHE STRING "Set crypto" FORCE )
SET( OPENSSL_SSL_LIBRARY ssl CACHE STRING "Set ssl" FORCE )

View File

@@ -0,0 +1,446 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#
import re
import os
import argparse
import subprocess
import shutil
import time
import datetime
import sys
TestName = "AndroidSDKTesting"
TestLowerName = TestName.lower()
def ArgumentException( Exception ):
def __init__( self, argumentName, argumentValue ):
self.m_argumentName = argumentName
self.m_argumentValue = argumentValue
def ParseArguments():
parser = argparse.ArgumentParser(description="AWSNativeSDK Android Test Script")
parser.add_argument("--clean", action="store_true")
parser.add_argument("--emu", action="store_true")
parser.add_argument("--abi", action="store")
parser.add_argument("--avd", action="store")
parser.add_argument("--nobuild", action="store_true")
parser.add_argument("--noinstall", action="store_true")
parser.add_argument("--runtest", action="store")
parser.add_argument("--credentials", action="store")
parser.add_argument("--build", action="store")
parser.add_argument("--so", action="store_true")
parser.add_argument("--stl", action="store")
args = vars( parser.parse_args() )
argMap = {}
argMap[ "clean" ] = args[ "clean" ]
argMap[ "abi" ] = args[ "abi" ] or "armeabi-v7a"
argMap[ "avd" ] = args[ "avd" ]
argMap[ "useExistingEmulator" ] = args[ "emu" ]
argMap[ "noBuild" ] = args[ "nobuild" ]
argMap[ "noInstall" ] = args[ "noinstall" ]
argMap[ "credentialsFile" ] = args[ "credentials" ] or "~/.aws/credentials"
argMap[ "buildType" ] = args[ "build" ] or "Release"
argMap[ "runTest" ] = args[ "runtest" ]
argMap[ "so" ] = args[ "so" ]
argMap[ "stl" ] = args[ "stl" ] or "libc++_shared"
return argMap
def IsValidABI(abi):
return abi == "armeabi-v7a"
def ShouldBuildClean(abi, buildDir):
if not os.path.exists( buildDir ):
return True
abiPattern = re.compile("ANDROID_ABI:STRING=\s*(?P<abi>\S+)")
for _, line in enumerate(open(buildDir + "/CMakeCache.txt")):
result = abiPattern.search(line)
if result != None:
return result.group("abi") != abi
return False
def BuildAvdAbiSet():
namePattern = re.compile("Name:\s*(?P<name>\S+)")
abiPattern = re.compile("ABI: default/(?P<abi>\S+)")
avdList = subprocess.check_output(["android", "list", "avds"])
avdABIs = {}
currentName = None
for _, line in enumerate(avdList.splitlines()):
if not currentName:
nameResult = namePattern.search(line)
if nameResult != None:
currentName = nameResult.group("name")
else:
abiResult = abiPattern.search(line)
if abiResult != None:
avdABIs[currentName] = abiResult.group("abi")
currentName = None
return avdABIs
def DoesAVDSupportABI(avdAbi, abi):
if avdAbi == "armeabi-v7a":
return abi == "armeabi-v7a" or abi == "armeabi"
else:
return abi == avdAbi
def FindAVDForABI(abi, avdABIs):
for avdName in avdABIs:
if DoesAVDSupportABI(avdABIs[avdName], abi):
return avdName
return None
def IsValidAVD(avd, abi, avdABIs):
return DoesAVDSupportABI(avdABIs[avd], abi)
def GetTestList(buildSharedObjects):
if buildSharedObjects:
return [ 'core', 's3', 'dynamodb', 'cloudfront', 'cognitoidentity', 'identity', 'lambda', 'logging', 'redshift', 'sqs', 'transfer' ]
else:
return [ 'unified' ]
def ValidateArguments(buildDir, avd, abi, clean, runTest, buildSharedObjects):
validTests = GetTestList( buildSharedObjects )
if runTest not in validTests:
print( 'Invalid value for runtest option: ' + runTest )
print( 'Valid values are: ' )
print( ' ' + ", ".join( validTests ) )
raise ArgumentException('runtest', runTest)
if not IsValidABI(abi):
print('Invalid argument value for abi: ', abi)
print(' Valid values are "armeabi-v7a"')
raise ArgumentException('abi', abi)
if not clean and ShouldBuildClean(abi, buildDir):
clean = True
avdABIs = BuildAvdAbiSet()
if not avd:
print('No virtual device specified (--avd), trying to find one in the existing avd set...')
avd = FindAVDForABI(abi, avdABIs)
if not IsValidAVD(avd, abi, avdABIs):
print('Invalid virtual device: ', avd)
print(' Use --avd to set the virtual device')
print(' Use "android lists avds" to see all usable virtual devices')
raise ArgumentException('avd', avd)
return (avd, abi, clean)
def SetupJniDirectory(abi, clean):
path = os.path.join( TestName, "app", "src", "main", "jniLibs", abi )
if clean and os.path.exists(path):
shutil.rmtree(path)
if os.path.exists( path ) == False:
os.makedirs( path )
return path
def CopyNativeLibraries(buildSharedObjects, jniDir, buildDir, abi, stl):
baseToolchainDir = os.path.join(buildDir, 'toolchains', 'android')
toolchainDirList = os.listdir(baseToolchainDir) # should only be one entry
toolchainDir = os.path.join(baseToolchainDir, toolchainDirList[0])
platformLibDir = os.path.join(toolchainDir, "sysroot", "usr", "lib")
shutil.copy(os.path.join(platformLibDir, "liblog.so"), jniDir)
stdLibDir = os.path.join(toolchainDir, 'arm-linux-androideabi', 'lib')
if stl == 'libc++_shared':
shutil.copy(os.path.join(stdLibDir, "libc++_shared.so"), jniDir)
elif stl == 'gnustl_shared':
shutil.copy(os.path.join(stdLibDir, "armv7-a", "libgnustl_shared.so"), jniDir) # TODO: remove armv7-a hardcoded path
if buildSharedObjects:
soPattern = re.compile(".*\.so$")
for rootDir, dirNames, fileNames in os.walk( buildDir ):
for fileName in fileNames:
if soPattern.search(fileName):
libFileName = os.path.join(rootDir, fileName)
shutil.copy(libFileName, jniDir)
else:
unifiedTestsLibrary = os.path.join(buildDir, "android-unified-tests", "libandroid-unified-tests.so")
shutil.copy(unifiedTestsLibrary, jniDir)
def RemoveTree(dir):
if os.path.exists( dir ):
shutil.rmtree( dir )
def BuildNative(abi, clean, buildDir, jniDir, installDir, buildType, buildSharedObjects, stl):
if clean:
RemoveTree(installDir)
RemoveTree(buildDir)
RemoveTree(jniDir)
for externalProjectDir in [ "openssl", "zlib", "curl" ]:
RemoveTree(externalProjectDir)
os.makedirs( jniDir )
os.makedirs( buildDir )
os.chdir( buildDir )
if not buildSharedObjects:
link_type_line = "-DBUILD_SHARED_LIBS=OFF"
else:
link_type_line = "-DBUILD_SHARED_LIBS=ON"
subprocess.check_call( [ "cmake",
link_type_line,
"-DCUSTOM_MEMORY_MANAGEMENT=ON",
"-DTARGET_ARCH=ANDROID",
"-DANDROID_ABI=" + abi,
"-DANDROID_STL=" + stl,
"-DCMAKE_BUILD_TYPE=" + buildType,
"-DENABLE_UNITY_BUILD=ON",
'-DTEST_CERT_PATH="/data/data/aws.' + TestLowerName + '/certs"',
'-DBUILD_ONLY=dynamodb;sqs;s3;lambda;kinesis;cognito-identity;transfer;iam;identity-management;access-management;s3-encryption',
".."] )
else:
os.chdir( buildDir )
if buildSharedObjects:
subprocess.check_call( [ "make", "-j12" ] )
else:
subprocess.check_call( [ "make", "-j12", "android-unified-tests" ] )
os.chdir( ".." )
CopyNativeLibraries(buildSharedObjects, jniDir, buildDir, abi, stl)
def BuildJava(clean):
os.chdir( TestName )
if clean:
subprocess.check_call( [ "./gradlew", "clean" ] )
subprocess.check_call( [ "./gradlew", "--refresh-dependencies" ] )
subprocess.check_call( [ "./gradlew", "assembleDebug" ] )
os.chdir( ".." )
def IsAnEmulatorRunning():
emulatorPattern = re.compile("(?P<emu>emulator-\d+)")
emulatorList = subprocess.check_output(["adb", "devices"])
for _, line in enumerate(emulatorList.splitlines()):
result = emulatorPattern.search(line)
if result:
return True
return False
def KillRunningEmulators():
emulatorPattern = re.compile("(?P<emu>emulator-\d+)")
emulatorList = subprocess.check_output(["adb", "devices"])
for _, line in enumerate(emulatorList.splitlines()):
result = emulatorPattern.search(line)
if result:
emulatorName = result.group( "emu" )
subprocess.check_call( [ "adb", "-s", emulatorName, "emu", "kill" ] )
def WaitForEmulatorToBoot():
time.sleep(5)
subprocess.check_call( [ "adb", "-e", "wait-for-device" ] )
print( "Device online; booting..." )
bootCompleted = False
bootAnimPlaying = True
while not bootCompleted or bootAnimPlaying:
time.sleep(1)
bootCompleted = subprocess.check_output( [ "adb", "-e", "shell", "getprop sys.boot_completed" ] ).strip() == "1"
bootAnimPlaying = subprocess.check_output( [ "adb", "-e", "shell", "getprop init.svc.bootanim" ] ).strip() != "stopped"
print( "Device booted" )
def InitializeEmulator(avd, useExistingEmu):
if not useExistingEmu:
KillRunningEmulators()
if not IsAnEmulatorRunning():
# this may not work on windows due to the shell and &
subprocess.Popen( "emulator -avd " + avd + " -gpu off &", shell=True ).communicate()
WaitForEmulatorToBoot()
#TEMPORARY: once we have android CI, we will adjust the emulator's CA set as a one-time step and then remove this step
def BuildAndInstallCertSet(pemSourceDir, buildDir):
# android's default cert set does not allow verification of Amazon's cert chain, so we build, install, and use our own set that works
certDir = os.path.join( buildDir, "certs" )
pemSourceFile = os.path.join( pemSourceDir, "cacert.pem" )
# assume that if the directory exists, then the cert set is valid and we just need to upload
if not os.path.exists( certDir ):
os.makedirs( certDir )
# extract all the certs in curl's master cacert.pem file out into individual .pem files
subprocess.check_call( "cat " + pemSourceFile + " | awk '{print > \"" + certDir + "/cert\" (1+n) \".pem\"} /-----END CERTIFICATE-----/ {n++}'", shell = True )
# use openssl to transform the certs into the hashname form that curl/openssl expects
subprocess.check_call( "c_rehash certs", shell = True, cwd = buildDir )
# The root (VeriSign 3) cert in Amazon's chain is missing from curl's master cacert.pem file and needs to be copied manually
shutil.copy(os.path.join( pemSourceDir, "certs", "415660c1.0" ), certDir)
shutil.copy(os.path.join( pemSourceDir, "certs", "7651b327.0" ), certDir)
subprocess.check_call( [ "adb", "shell", "rm -rf /data/data/aws." + TestLowerName + "/certs" ] )
subprocess.check_call( [ "adb", "shell", "mkdir /data/data/aws." + TestLowerName + "/certs" ] )
# upload all the hashed certs to the emulator
certPattern = re.compile(".*\.0$")
for rootDir, dirNames, fileNames in os.walk( certDir ):
for fileName in fileNames:
if certPattern.search(fileName):
certFileName = os.path.join(rootDir, fileName)
subprocess.check_call( [ "adb", "push", certFileName, "/data/data/aws." + TestLowerName + "/certs" ] )
def UploadTestResources(resourcesDir):
for rootDir, dirNames, fileNames in os.walk( resourcesDir ):
for fileName in fileNames:
resourceFileName = os.path.join( rootDir, fileName )
subprocess.check_call( [ "adb", "push", resourceFileName, os.path.join( "/data/data/aws." + TestLowerName + "/resources", fileName ) ] )
def UploadAwsSigV4TestSuite(resourceDir):
for rootDir, dirNames, fileNames in os.walk( resourceDir ):
for fileName in fileNames:
resourceFileName = os.path.join( rootDir, fileName )
subDir = os.path.basename( rootDir )
subprocess.check_call( [ "adb", "push", resourceFileName, os.path.join( "/data/data/aws." + TestLowerName + "/resources", subDir, fileName ) ] )
def InstallTests(credentialsFile):
subprocess.check_call( [ "adb", "install", "-r", TestName + "/app/build/outputs/apk/app-debug.apk" ] )
subprocess.check_call( [ "adb", "logcat", "-c" ] ) # this doesn't seem to work
if credentialsFile and credentialsFile != "":
print( "uploading credentials" )
subprocess.check_call( [ "adb", "push", credentialsFile, "/data/data/aws." + TestLowerName + "/.aws/credentials" ] )
def TestsAreRunning(timeStart):
shutdownCalledOutput = subprocess.check_output( "adb logcat -t " + timeStart + " *:V | grep \"Shutting down TestActivity\"; exit 0 ", shell = True )
return not shutdownCalledOutput
def RunTest(testName):
time.sleep(5)
print( "Attempting to unlock..." )
subprocess.check_call( [ "adb", "-e", "shell", "input keyevent 82" ] )
logTime = datetime.datetime.now() + datetime.timedelta(minutes=-1) # the emulator and the computer do not appear to be in perfect sync
logTimeString = logTime.strftime("\"%m-%d %H:%M:%S.000\"")
time.sleep(5)
print( "Attempting to run tests..." )
subprocess.check_call( [ "adb", "shell", "am start -e test " + testName + " -n aws." + TestLowerName + "/aws." + TestLowerName + ".RunSDKTests" ] )
time.sleep(10)
while TestsAreRunning(logTimeString):
print( "Tests still running..." )
time.sleep(5)
print( "Saving logs..." )
subprocess.Popen( "adb logcat -t " + logTimeString + " *:V | grep -a NativeSDK > AndroidTestOutput.txt", shell=True )
print( "Cleaning up..." )
subprocess.check_call( [ "adb", "shell", "pm clear aws." + TestLowerName ] )
def DidAllTestsSucceed():
failures = subprocess.check_output( "grep \"FAILED\" AndroidTestOutput.txt ; exit 0", shell = True )
return failures == ""
def Main():
args = ParseArguments()
avd = args[ "avd" ]
abi = args[ "abi" ]
clean = args[ "clean" ]
useExistingEmu = args[ "useExistingEmulator" ]
skipBuild = args[ "noBuild" ]
credentialsFile = args[ "credentialsFile" ]
buildType = args[ "buildType" ]
noInstall = args[ "noInstall" ]
buildSharedObjects = args[ "so" ]
runTest = args[ "runTest" ]
stl = args[ "stl" ]
buildDir = "_build" + buildType
installDir = os.path.join( "external", abi );
if runTest:
avd, abi, clean = ValidateArguments(buildDir, avd, abi, clean, runTest, buildSharedObjects)
jniDir = SetupJniDirectory(abi, clean)
if not skipBuild:
BuildNative(abi, clean, buildDir, jniDir, installDir, buildType, buildSharedObjects, stl)
BuildJava(clean)
if not runTest:
return 0
print("Starting emulator...")
InitializeEmulator(avd, useExistingEmu)
if not noInstall:
print("Installing tests...")
InstallTests(credentialsFile)
print("Installing certs...")
BuildAndInstallCertSet("android-build", buildDir)
print("Uploading test resources")
UploadTestResources("aws-cpp-sdk-lambda-integration-tests/resources")
print("Uploading SigV4 test files")
UploadAwsSigV4TestSuite(os.path.join("aws-cpp-sdk-core-tests", "resources", "aws4_testsuite", "aws4_testsuite"))
print("Running tests...")
RunTest( runTest )
if not useExistingEmu:
KillRunningEmulators()
if DidAllTestsSucceed():
print( "All tests passed!" )
return 0
else:
print( "Some tests failed. See AndroidTestOutput.txt" )
return 1
Main()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
-----END CERTIFICATE-----

View File

@@ -0,0 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
-----END CERTIFICATE-----

View File

@@ -0,0 +1,65 @@
# Based on original work by David Manura
# Copyright (C) 2007-2012 LuaDist.
# Copyright (C) 2013 Brian Sidebotham
# Redistribution and use of this file is allowed according to the terms of the
# MIT license.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#bambrose 2015-06-01 commented out unneeded features that were breaking android build. Since this is only for android, we removed ocsp and wincrypt since they were not needed anyways.
project( openssl )
cmake_minimum_required( VERSION 2.8.3 )
add_definitions( -DZLIB )
if(BUILD_SHARED_LIBS)
add_definitions( -DZLIB_SHARED )
endif()
if( WIN32 AND NOT CYGWIN )
add_definitions( -DOPENSSL_SYSNAME_WIN32 )
add_definitions( -DWIN32_LEAN_AND_MEAN )
# avoid conflict: ocsp.h and wincrypt.h
add_definitions( -D_WINDLL )
endif ( )
if( MINGW )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all" )
endif()
add_subdirectory( crypto )
add_subdirectory( ssl )
if( NOT BUILD_SHARED_LIBS )
add_subdirectory( apps )
endif()
install( FILES e_os2.h DESTINATION include/openssl )
# Generate the package target
set( CPACK_GENERATOR ZIP TGZ )
set( CPACK_PACKAGE_NAME "openssl-cmake" )
set( CPACK_PACKAGE_VERSION_MAJOR 1 )
set( CPACK_PACKAGE_VERSION_MINOR 0 )
set( CPACK_PACKAGE_VERSION_PATCH 2g )
include( CPack )

View File

@@ -0,0 +1,43 @@
# Based on original work by David Manura
# Copyright (C) 2007-2012 LuaDist.
# Copyright (C) 2013 Brian Sidebotham
# Redistribution and use of this file is allowed according to the terms of the
# MIT license.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#bambrose 2015-06-01 commented out unneeded compile deps.
include_directories ( .. ../include )
add_definitions ( -DMONOLITH )
set ( E_SRC openssl.c #
verify.c asn1pars.c req.c dgst.c dh.c dhparam.c enc.c passwd.c gendh.c errstr.c
ca.c pkcs7.c crl2p7.c crl.c rsa.c rsautl.c dsa.c dsaparam.c ec.c ecparam.c x509.c
genrsa.c gendsa.c genpkey.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c
s_socket.c app_rand.c version.c sess_id.c ciphers.c nseq.c pkcs12.c pkcs8.c pkey.c
pkeyparam.c pkeyutl.c spkac.c smime.c cms.c rand.c engine.c ocsp.c prime.c ts.c
srp.c )
add_executable ( openssl ${E_SRC} )
target_link_libraries ( openssl z crypto ssl )
install( TARGETS openssl RUNTIME DESTINATION bin )

View File

@@ -0,0 +1,223 @@
# Based on original work by David Manura
# Copyright (C) 2007-2012 LuaDist.
# Copyright (C) 2013 Brian Sidebotham
# Redistribution and use of this file is allowed according to the terms of the
# MIT license.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#bambrose 2015-06-01 commented out unneeded features.
include( CMakeParseArguments )
file( READ opensslconf.h.in CONF )
string( REPLACE "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION" "#cmakedefine OPENSSL_EXPORT_VAR_AS_FUNCTION"
CONF "${CONF}" )
set( CONF "
#define OPENSSL_NO_GMP
#define OPENSSL_NO_JPAKE
#define OPENSSL_NO_KRB5
#define OPENSSL_NO_MD2
#define OPENSSL_NO_RC5
#define OPENSSL_NO_RFC3779
#define OPENSSL_NO_STORE
#define OPENSSL_NO_DYNAMIC_ENGINE
#define OPENSSL_NO_SCTP
#define OPENSSL_NO_EC_NISTP_64_GCC_128
#define OPENSSL_NO_GOST
#define OPENSSL_NO_EC
#define OPENSSL_NO_ECDH
#define OPENSSL_NO_ECDSA
#define OPENSSL_NO_SSL_TRACE
#define OPENSSL_NO_UNIT_TEST
#define OPENSSL_THREADS
${CONF}" )
file( WRITE ${CMAKE_SOURCE_DIR}/tmp/opensslconf.h.cmake "${CONF}" )
#~2DO: set BUILDINF_DATE to `date LC_ALL=C LC_TIME=C`
configure_file ( buildinf.h.cmake buildinf.h )
if( WIN32 AND MINGW AND NOT CYGWIN )
set( OPENSSL_EXPORT_VAR_AS_FUNCTION true )
endif()
configure_file( ${CMAKE_SOURCE_DIR}/tmp/opensslconf.h.cmake ${CMAKE_SOURCE_DIR}/include/openssl/opensslconf.h )
configure_file( ${CMAKE_SOURCE_DIR}/tmp/opensslconf.h.cmake ${CMAKE_SOURCE_DIR}/crypto/opensslconf.h )
set( LIBSRC cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c ex_data.c cpt_err.c
ebcdic.c uid.c o_time.c o_str.c o_dir.c o_init.c)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} .. ../include . asn1 evp modes )
if( BUILD_SHARED_LIBS )
add_definitions( -DOPENSSL_BUILD_SHLIBCRYPTO )
endif()
macro( add_submodule dir )
set( options )
set( oneValueArgs )
set( multiValueArgs EXHEADERS )
cmake_parse_arguments( add_submodule "" "" "${multiValueArgs}" ${ARGN} )
#message( STATUS "{dir} ${dir}" )
#message( STATUS "{add_submodule_UNPARSED_ARGUMENTS} ${add_submodule_UNPARSED_ARGUMENTS}" )
foreach( name ${add_submodule_UNPARSED_ARGUMENTS} )
set( LIBSRC ${LIBSRC} ${dir}/${name} )
endforeach( name )
#message( STATUS "{add_submodule_EXHEADERS} ${add_submodule_EXHEADERS}" )
foreach( name ${add_submodule_EXHEADERS} )
set( EXHEADERS ${EXHEADERS} ${dir}/${name} )
endforeach( name )
endmacro( add_submodule )
add_submodule ( ../engines e_4758cca.c e_aep.c e_atalla.c e_cswift.c e_gmp.c e_chil.c
e_nuron.c e_sureware.c e_ubsec.c e_padlock.c e_capi.c )
# avoid conflict: ocsp.h and wincrypt.h
if( WIN32 AND NOT CYGWIN )
set_property( SOURCE ../engines/e_capi.c APPEND PROPERTY COMPILE_DEFINITIONS HEADER_OCSP_H )
#set_property( SOURCE ../engines/ccgost/gost_asn1.c APPEND PROPERTY COMPILE_DEFINITIONS
# WIN32_LEAN_AND_MEAN )
endif( WIN32 AND NOT CYGWIN )
add_submodule ( aes aes_core.c aes_misc.c aes_ecb.c aes_cbc.c aes_cfb.c aes_ofb.c
aes_ctr.c aes_ige.c aes_wrap.c EXHEADERS aes.h )
add_submodule ( asn1 a_object.c a_bitstr.c a_utctm.c a_gentm.c a_time.c a_int.c a_octet.c
a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_enum.c a_utf8.c a_sign.c
a_digest.c a_verify.c a_mbstr.c a_strex.c x_algor.c x_val.c x_pubkey.c x_sig.c
x_req.c x_attrib.c x_bignum.c x_long.c x_name.c x_x509.c x_x509a.c x_crl.c x_info.c
x_spki.c nsseq.c x_nx509.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c
t_x509a.c t_crl.c t_pkey.c t_spki.c t_bitst.c tasn_new.c tasn_fre.c tasn_enc.c
tasn_dec.c tasn_utl.c tasn_typ.c tasn_prn.c ameth_lib.c f_int.c f_string.c n_pkey.c
f_enum.c x_pkey.c a_bool.c x_exten.c bio_asn1.c bio_ndef.c asn_mime.c asn1_gen.c
asn1_par.c asn1_lib.c asn1_err.c a_bytes.c a_strnid.c evp_asn1.c asn_pack.c p5_pbe.c
p5_pbev2.c p8_pkey.c asn_moid.c EXHEADERS asn1.h asn1_mac.h asn1t.h )
add_submodule ( bf bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c EXHEADERS blowfish.h )
add_submodule ( bio bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c
bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c
bf_nbio.c bss_log.c bss_bio.c bss_dgram.c # bf_lbuf.c
EXHEADERS bio.h )
add_submodule ( bn bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c
bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c bn_kron.c bn_sqrt.c bn_gcd.c
bn_prime.c bn_err.c bn_sqr.c bn_asm.c bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c
bn_nist.c bn_depr.c bn_const.c rsaz_exp.c EXHEADERS bn.h )
add_submodule ( buffer buffer.c buf_err.c buf_str.c EXHEADERS buffer.h )
add_submodule ( camellia camellia.c cmll_misc.c cmll_ecb.c cmll_cbc.c cmll_ofb.c
cmll_cfb.c cmll_ctr.c cmll_utl.c EXHEADERS camellia.h )
add_submodule ( cast c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c EXHEADERS cast.h )
add_submodule ( cmac cm_ameth.c cm_pmeth.c cmac.c EXHEADERS cmac.h )
add_submodule ( cms cms_lib.c cms_asn1.c cms_att.c cms_io.c cms_smime.c cms_err.c
cms_sd.c cms_dd.c cms_cd.c cms_env.c cms_enc.c cms_ess.c cms_pwri.c cms_kari.c EXHEADERS cms.h )
add_submodule ( comp comp_lib.c comp_err.c c_rle.c c_zlib.c EXHEADERS comp.h )
add_submodule ( conf conf_err.c conf_lib.c conf_api.c conf_def.c conf_mod.c conf_mall.c
conf_sap.c EXHEADERS conf.h conf_api.h )
add_submodule ( des cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c
enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c
rpc_enc.c set_key.c des_enc.c fcrypt_b.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c
ede_cbcm_enc.c des_old.c des_old2.c read2pwd.c EXHEADERS des.h des_old.h )
add_submodule ( dh dh_asn1.c dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh_depr.c
dh_ameth.c dh_pmeth.c dh_prn.c dh_kdf.c dh_rfc5114.c EXHEADERS dh.h )
add_submodule ( dsa dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c
dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c EXHEADERS dsa.h )
add_submodule ( dso dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c dso_openssl.c
dso_win32.c dso_vms.c dso_beos.c EXHEADERS dso.h )
add_submodule ( engine eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c eng_table.c
eng_pkey.c eng_fat.c eng_all.c tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c
tb_store.c tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c eng_openssl.c eng_cnf.c
eng_dyn.c eng_cryptodev.c eng_rdrand.c EXHEADERS engine.h )
add_submodule ( err err.c err_all.c err_prn.c EXHEADERS err.h )
add_submodule ( evp encode.c digest.c evp_enc.c evp_key.c evp_acnf.c e_des.c e_bf.c
e_idea.c e_des3.c e_camellia.c e_rc4.c e_aes.c names.c e_seed.c e_xcbc_d.c e_rc2.c
e_cast.c e_rc5.c m_null.c m_md2.c m_md4.c m_md5.c m_sha.c m_sha1.c m_wp.c m_dss.c
m_dss1.c m_mdc2.c m_ripemd.c m_ecdsa.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c
p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c c_allc.c
c_alld.c evp_lib.c bio_ok.c evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c e_old.c pmeth_lib.c
pmeth_fn.c pmeth_gn.c m_sigver.c evp_cnf.c e_rc4_hmac_md5.c e_aes_cbc_hmac_sha1.c
e_aes_cbc_hmac_sha256.c EXHEADERS evp.h )
add_submodule ( hmac hmac.c hm_ameth.c hm_pmeth.c EXHEADERS hmac.h )
add_submodule ( idea i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c EXHEADERS idea.h )
add_submodule ( krb5 krb5_asn.c EXHEADERS krb5_asn.h )
add_submodule ( lhash lhash.c lh_stats.c EXHEADERS lhash.h )
add_submodule ( md4 md4_dgst.c md4_one.c EXHEADERS md4.h )
add_submodule ( md5 md5_dgst.c md5_one.c EXHEADERS md5.h )
add_submodule ( mdc2 mdc2dgst.c mdc2_one.c EXHEADERS mdc2.h )
add_submodule ( modes cbc128.c ccm128.c ctr128.c cts128.c cfb128.c gcm128.c ofb128.c
xts128.c wrap128.c EXHEADERS modes.h )
add_submodule ( objects o_names.c obj_dat.c obj_lib.c obj_err.c obj_xref.c EXHEADERS
objects.h obj_mac.h )
add_submodule ( ocsp ocsp_asn.c ocsp_ext.c ocsp_ht.c ocsp_lib.c ocsp_cl.c ocsp_srv.c
ocsp_prn.c ocsp_vfy.c ocsp_err.c EXHEADERS ocsp.h )
add_submodule ( pem pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c
pem_x509.c pem_xaux.c pem_oth.c pem_pk8.c pem_pkey.c pvkfmt.c EXHEADERS pem.h pem2.h )
add_submodule ( pkcs12 p12_add.c p12_asn.c p12_attr.c p12_crpt.c p12_crt.c p12_decr.c
p12_init.c p12_key.c p12_kiss.c p12_mutl.c p12_utl.c p12_npas.c pk12err.c p12_p8d.c
p12_p8e.c EXHEADERS pkcs12.h )
add_submodule ( pkcs7 pk7_asn1.c pk7_lib.c pkcs7err.c pk7_doit.c pk7_smime.c pk7_attr.c
pk7_mime.c bio_pk7.c EXHEADERS pkcs7.h )
add_submodule ( pqueue pqueue.c EXHEADERS pqueue.h )
add_submodule ( rand md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c rand_win.c
rand_unix.c rand_os2.c rand_nw.c EXHEADERS rand.h )
add_submodule ( rc2 rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c EXHEADERS
rc2.h )
add_submodule ( rc4 rc4_skey.c rc4_enc.c rc4_utl.c EXHEADERS rc4.h )
add_submodule ( ripemd rmd_dgst.c rmd_one.c EXHEADERS ripemd.h )
add_submodule ( rsa rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c
rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c rsa_null.c rsa_pss.c rsa_x931.c
rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c rsa_pmeth.c rsa_crpt.c EXHEADERS rsa.h )
add_submodule ( seed seed.c seed_ecb.c seed_cbc.c seed_cfb.c seed_ofb.c EXHEADERS
seed.h )
add_submodule ( sha sha_dgst.c sha1dgst.c sha_one.c sha1_one.c sha256.c sha512.c
EXHEADERS sha.h )
add_submodule ( srp srp_lib.c srp_vfy.c EXHEADERS srp.h srp_grps.h srp_lcl.h )
add_submodule ( stack stack.c EXHEADERS stack.h safestack.h )
add_submodule ( ts ts_err.c ts_req_utils.c ts_req_print.c ts_rsp_utils.c ts_rsp_print.c
ts_rsp_sign.c ts_rsp_verify.c ts_verify_ctx.c ts_lib.c ts_conf.c ts_asn1.c EXHEADERS
ts.h )
add_submodule ( txt_db txt_db.c EXHEADERS txt_db.h )
add_submodule ( ui ui_err.c ui_lib.c ui_openssl.c ui_util.c ui_compat.c EXHEADERS
ui.h ui_compat.h )
add_submodule ( whrlpool wp_dgst.c wp_block.c EXHEADERS whrlpool.h )
add_submodule ( x509 x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c
x509spki.c x509_vfy.c x509_set.c x509cset.c x509rset.c x509_err.c x509name.c x509_v3.c
x509_ext.c x509_att.c x509type.c x509_lu.c x_all.c x509_txt.c x509_trs.c by_file.c
by_dir.c x509_vpm.c EXHEADERS x509.h x509_vfy.h )
add_submodule ( x509v3 v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c
v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c v3_int.c
v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c v3_ocsp.c v3_akeya.c
v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c pcy_cache.c pcy_node.c pcy_data.c
pcy_map.c pcy_tree.c pcy_lib.c v3_asid.c v3_addr.c v3_scts.c EXHEADERS x509v3.h )
# dirs not included: threads
add_submodule ( . EXHEADERS crypto.h opensslv.h opensslconf.h ebcdic.h symhacks.h
ossl_typ.h )
add_library( crypto ${LIBSRC} ${OBJECTS_SRC} )
if( WIN32 AND NOT CYGWIN )
target_link_libraries( crypto ws2_32 crypt32 )
endif()
install( FILES ${EXHEADERS} DESTINATION include/openssl )
install( TARGETS crypto RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib )

View File

@@ -0,0 +1,10 @@
#ifndef MK1MF_BUILD
/* auto-generated by crypto/Makefile for crypto/cversion.c */
#define CFLAGS "@CMAKE_C_COMPILER@ @CMAKE_C_FLAGS@"
#define PLATFORM "@CMAKE_SYSTEM_NAME@"
#define DATE "@BUILDINF_DATE@"
#endif
/* ~2DO: is the above ok? */

View File

@@ -0,0 +1,47 @@
# Based on original work by David Manura
# Copyright (C) 2007-2012 LuaDist.
# Copyright (C) 2013 Brian Sidebotham
# Redistribution and use of this file is allowed according to the terms of the
# MIT license.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
include_directories ( ../crypto .. ../include )
if( BUILD_SHARED_LIBS )
add_definitions ( -DOPENSSL_BUILD_SHLIBSSL )
endif()
set ( LIBSRC s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c
s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c
s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c d1_meth.c d1_srvr.c
d1_clnt.c d1_lib.c d1_pkt.c d1_both.c ssl_lib.c ssl_err2.c ssl_cert.c
ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c
ssl_err.c kssl.c t1_reneg.c tls_srp.c s3_cbc.c d1_srtp.c ssl_conf.c ssl_utst.c t1_ext.c t1_trce.c)
add_library ( ssl ${LIBSRC} )
target_link_libraries ( ssl crypto )
install( FILES ssl.h ssl2.h ssl3.h ssl23.h tls1.h dtls1.h kssl.h srtp.h
DESTINATION include/openssl )
install( TARGETS ssl RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib )

View File

@@ -0,0 +1,149 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.
#
import argparse
import os
import shutil
import platform
# openssl doesn't have any cmake files; this script copies in cmake files to appropriate directories
# The CMakeFiles.txt files are variants of what can be found at https://launchpad.net/openssl-cmake
# but have been modified to account for changes in later OpenSSL versions (the original files are frozen at version 1.0.1e)
def CopyCMakeFiles(baseDir, destDir):
sourceDir = os.path.join(baseDir, "android-build", "cmakefiles", "openssl-cmake")
dirLength = len(sourceDir)
for rootDir, dirNames, fileNames in os.walk(sourceDir):
for fileName in fileNames:
if fileName == "CMakeLists.txt":
sourceFile = os.path.join(rootDir, fileName)
if rootDir == sourceDir:
finalDestDir = destDir
else:
finalDestDir = os.path.join(destDir, rootDir[(dirLength + 1):])
shutil.copy(sourceFile, finalDestDir)
# another random thing needed by openssl
specialHeaderSource = os.path.join(sourceDir, "crypto", "buildinf.h.cmake")
specialHeaderDest = os.path.join(destDir, "crypto")
shutil.copy(specialHeaderSource, specialHeaderDest)
return True
def BuildIncludeFileList():
includes = [
"../../crypto/aes/aes.h",
"../../crypto/asn1/asn1.h",
"../../crypto/asn1/asn1_mac.h",
"../../crypto/asn1/asn1t.h",
"../../crypto/bio/bio.h",
"../../crypto/bf/blowfish.h",
"../../crypto/bn/bn.h",
"../../crypto/buffer/buffer.h",
"../../crypto/camellia/camellia.h",
"../../crypto/cast/cast.h",
"../../crypto/cmac/cmac.h",
"../../crypto/cms/cms.h",
"../../crypto/comp/comp.h",
"../../crypto/conf/conf.h",
"../../crypto/conf/conf_api.h",
"../../crypto/crypto.h",
"../../crypto/des/des.h",
"../../crypto/des/des_old.h",
"../../crypto/dh/dh.h",
"../../crypto/dsa/dsa.h",
"../../crypto/dso/dso.h",
"../../ssl/dtls1.h",
"../../e_os2.h",
"../../crypto/ebcdic.h",
"../../crypto/ec/ec.h",
"../../crypto/ecdh/ecdh.h",
"../../crypto/ecdsa/ecdsa.h",
"../../crypto/engine/engine.h",
"../../crypto/err/err.h",
"../../crypto/evp/evp.h",
"../../crypto/hmac/hmac.h",
"../../crypto/idea/idea.h",
"../../crypto/krb5/krb5_asn.h",
"../../ssl/kssl.h",
"../../crypto/lhash/lhash.h",
"../../crypto/md4/md4.h",
"../../crypto/md5/md5.h",
"../../crypto/mdc2/mdc2.h",
"../../crypto/modes/modes.h",
"../../crypto/objects/obj_mac.h",
"../../crypto/objects/objects.h",
"../../crypto/ocsp/ocsp.h",
"../../crypto/opensslv.h",
"../../crypto/ossl_typ.h",
"../../crypto/pem/pem.h",
"../../crypto/pem/pem2.h",
"../../crypto/pkcs12/pkcs12.h",
"../../crypto/pkcs7/pkcs7.h",
"../../crypto/pqueue/pqueue.h",
"../../crypto/rand/rand.h",
"../../crypto/rc2/rc2.h",
"../../crypto/rc4/rc4.h",
"../../crypto/ripemd/ripemd.h",
"../../crypto/rsa/rsa.h",
"../../crypto/stack/safestack.h",
"../../crypto/seed/seed.h",
"../../crypto/sha/sha.h",
"../../crypto/srp/srp.h",
"../../ssl/srtp.h",
"../../ssl/ssl.h",
"../../ssl/ssl2.h",
"../../ssl/ssl23.h",
"../../ssl/ssl3.h",
"../../crypto/stack/stack.h",
"../../crypto/symhacks.h",
"../../ssl/tls1.h",
"../../crypto/ts/ts.h",
"../../crypto/txt_db/txt_db.h",
"../../crypto/ui/ui.h",
"../../crypto/ui/ui_compat.h",
"../../crypto/whrlpool/whrlpool.h",
"../../crypto/x509/x509.h",
"../../crypto/x509/x509_vfy.h",
"../../crypto/x509v3/x509v3.h"
]
return includes
def CopyIncludeDirectory(baseDir):
path = os.path.join( baseDir, "include", "openssl" )
if os.path.exists( path ) == False:
os.makedirs( path )
os.chdir( path )
for includeFile in BuildIncludeFileList():
shutil.copy( includeFile, "." )
def Main():
parser = argparse.ArgumentParser(description="AWSNativeSDK Android Openssl Update")
parser.add_argument("--source", action="store")
parser.add_argument("--dest", action="store")
args = vars( parser.parse_args() )
sourceDir = args[ "source" ]
destDir = args[ "dest" ]
print ("Copying CMakeLists.txt files")
if not CopyCMakeFiles(sourceDir, destDir):
print( "Failed to copy required CMake files" )
return 1
print("Making unified include directory")
# normally these would be symlinks created by configure, but since we're not running configure, copy them manually
CopyIncludeDirectory(destDir)
return 0
Main()