1 #******************************************************************
3 # Copyright 2016 Samsung Electronics All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
27 """Run a command and decipher the return code. Exit by default."""
29 # Assumes that if a process doesn't call exit, it was successful
30 if (os.WIFEXITED(res)):
31 code = os.WEXITSTATUS(res)
33 print "Error: return code: " + str(code)
34 if SCons.Script.keep_going_on_error == 0:
37 root_dir = env.get('SRC_DIR')
39 tls_dir = os.path.join(root_dir, 'extlibs','mbedtls','mbedtls')
41 if not os.path.exists(tls_dir):
43 *********************************** Error: ****************************************
44 * Please download mbedtls using the following command: *
45 * $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls *
46 ***********************************************************************************
50 start_dir = os.getcwd()
53 #Apply patch to enable TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256 ciphersuite and server identity hint
54 cmd = 'git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd && git apply ../ocf.patch'
57 build_dir = env.get('BUILD_DIR')
58 libs_list = ['libmbedcrypto.so', 'libmbedtls.so', 'libmbedx509.so']
60 if env.GetOption('clean'):
61 print 'Clean-up mbedtls...'
64 #Delete copied libs from out folder
65 for file_name in libs_list:
66 run("rm -f " + build_dir + file_name + "*")
68 #Pass to make proper debug option
69 if env.get('RELEASE'): debug = ''
70 else: debug = 'DEBUG=1 '
72 cmd = 'export SHARED=1 ' + debug + '&& make no_test'
74 print 'Making mbedtls libraries...'
78 #Copy libs to out folder
79 if not os.path.exists(build_dir): os.makedirs(build_dir)
80 for file_name in libs_list:
81 run("cp -d " + tls_dir + '/library/' + file_name + " " + build_dir)
82 run("cp " + tls_dir + '/library/' + file_name + ".* " + build_dir)