From: saurabh.s9 Date: Sat, 27 Aug 2016 08:25:35 +0000 (+0530) Subject: [IOT-1230] Resolving tizen platform build issue with mbedtls library included X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e34616c7d1ac5b70dcc84fa77c80408034f2571;p=contrib%2Fiotivity.git [IOT-1230] Resolving tizen platform build issue with mbedtls library included Change-Id: Ie48369da681590464421231763159ded5d484def Signed-off-by: saurabh.s9 Reviewed-on: https://gerrit.iotivity.org/gerrit/10995 Tested-by: jenkins-iotivity Reviewed-by: dongik Lee Reviewed-by: Dmitriy Zhuravlev --- diff --git a/extlibs/mbedtls/SConscript b/extlibs/mbedtls/SConscript index 0e5cd89..1b662b7 100644 --- a/extlibs/mbedtls/SConscript +++ b/extlibs/mbedtls/SConscript @@ -26,19 +26,6 @@ import sys target_os = env.get('TARGET_OS') root_dir = env.get('SRC_DIR') mbedtls_dir = os.path.join(root_dir, 'extlibs','mbedtls','mbedtls/') -libs_list = ['libmbedcrypto','libmbedtls','libmbedx509'] - -def run(cmd): - """Run a command and decipher the return code. Exit by default.""" - res = os.system(cmd) - # Assumes that if a process doesn't call exit, it was successful - if (os.WIFEXITED(res)): - code = os.WEXITSTATUS(res) - if code != 0: - print "Error: return code: " + str(code) - if SCons.Script.keep_going_on_error == 0: - sys.exit(code) - if not os.path.exists(mbedtls_dir): print ''' @@ -49,11 +36,13 @@ if not os.path.exists(mbedtls_dir): ''' Exit(1) #Apply patch to enable TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256 ciphersuite and server identity hint -start_dir = os.getcwd() -os.chdir(mbedtls_dir) -cmd = 'git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd && git apply ../ocf.patch' -run(cmd) -os.chdir(start_dir) +#For tizen platform patch is applied by gbsbuild script +if target_os != 'tizen': + start_dir = os.getcwd() + os.chdir(mbedtls_dir) + cmd = 'git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd && git apply ../ocf.patch' + os.system(cmd) + os.chdir(start_dir) mbedtls_env = env.Clone() @@ -157,4 +146,3 @@ mbex509_env.InstallTarget(static_libmbedx509, 'mbedx509') mbedtls_env.AppendUnique(LIBS = ['mbedx509', 'mbedcrypto']) static_libmbedtls = mbedtls_env.StaticLibrary('mbedtls', mbedtls_src) mbedtls_env.InstallTarget(static_libmbedtls, 'mbedtls') - diff --git a/gbsbuild.sh b/gbsbuild.sh index f2d61c7..633a286 100755 --- a/gbsbuild.sh +++ b/gbsbuild.sh @@ -30,6 +30,7 @@ cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git cp -R ./extlibs/cjson $sourcedir/tmp/extlibs +cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs cp -R ./extlibs/gtest $sourcedir/tmp/extlibs cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs @@ -54,8 +55,24 @@ cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp cd $sourcedir/tmp echo `pwd` +if [ -d ./extlibs/mbedtls/mbedtls ];then + cd ./extlibs/mbedtls/mbedtls + git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply ../ocf.patch + cd - + rm -rf ./extlibs/mbedtls/mbedtls/.git* + +else + echo "" + echo "*********************************** Error: ****************************************" + echo "* Please download mbedtls using the following command: *" + echo "* $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls *" + echo "***********************************************************************************" + echo "" + exit +fi rm -rf ./extlibs/tinycbor/tinycbor/.git* + # Initialize Git repository if [ ! -d .git ]; then git init ./ @@ -65,8 +82,17 @@ if [ ! -d .git ]; then git commit -m "Initial commit" fi +withtcp=0 +withcloud=0 +if [ "WITH_TCP" = "$1" ] || [ "WITH_TCP" = "$2" ];then + withtcp=1 +fi +if [ "WITH_CLOUD" = "$1" ] || [ "WITH_CLOUD" = "$2" ];then + withcloud=1 +fi + echo "Calling core gbs build command" -gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all --repository ./" +gbscommand="gbs build -A armv7l --define 'WITH_TCP $withtcp' --define 'WITH_CLOUD $withcloud' -B ~/GBS-ROOT-OIC --include-all --repository ./" echo $gbscommand if eval $gbscommand; then echo "Build is successful" @@ -75,6 +101,7 @@ else exit 1 fi + rm -rf tmp cd $sourcedir rm -rf $sourcedir/tmp diff --git a/resource/csdk/connectivity/src/SConscript b/resource/csdk/connectivity/src/SConscript index cffb3e1..e2ce9d9 100644 --- a/resource/csdk/connectivity/src/SConscript +++ b/resource/csdk/connectivity/src/SConscript @@ -173,6 +173,7 @@ if env.get('LOGGING'): if ca_os == 'android': lib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libconnectivity_abstraction.so']) + if ca_os in ['android', 'tizen']: lib_env.AppendUnique(LIBS = ['coap']) if lib_env.get('SECURED') == '1': @@ -180,6 +181,8 @@ if ca_os in ['android', 'tizen']: lib_env.AppendUnique(LIBS = ['timer']) if ca_os != 'android': lib_env.AppendUnique(LIBS = ['rt']) + if ((lib_env.get('SECURED') == '1') and ((lib_env.get('WITH_TCP')) or (lib_env.get('WITH_CLOUD')))): + lib_env.AppendUnique(LIBS = ['mbedtls','mbedx509','mbedcrypto']) calib = lib_env.SharedLibrary('connectivity_abstraction', env.get('CA_SRC')) elif ca_os in ['msys_nt', 'windows']: lib_env.AppendUnique(LIBS = ['coap', 'mswsock', 'ws2_32', 'iphlpapi', 'logger']) diff --git a/tools/tizen/iotivity.spec b/tools/tizen/iotivity.spec index 714569d..1c042c3 100644 --- a/tools/tizen/iotivity.spec +++ b/tools/tizen/iotivity.spec @@ -108,7 +108,7 @@ cp %{SOURCE1001} ./%{name}-test.manifest scons -j2 --prefix=%{_prefix} \ VERBOSE=%{VERBOSE} \ TARGET_OS=tizen TARGET_ARCH=%{RPM_ARCH} TARGET_TRANSPORT=%{TARGET_TRANSPORT} \ - RELEASE=%{RELEASE} SECURED=%{SECURED} LOGGING=%{LOGGING} ROUTING=%{ROUTING} \ + RELEASE=%{RELEASE} SECURED=%{SECURED} WITH_TCP=%{WITH_TCP} WITH_CLOUD=%{WITH_CLOUD} LOGGING=%{LOGGING} ROUTING=%{ROUTING} \ ES_TARGET_ENROLLEE=%{ES_TARGET_ENROLLEE} LIB_INSTALL_DIR=%{_libdir} @@ -117,7 +117,7 @@ rm -rf %{buildroot} CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; scons install --install-sandbox=%{buildroot} --prefix=%{_prefix} \ TARGET_OS=tizen TARGET_ARCH=%{RPM_ARCH} TARGET_TRANSPORT=%{TARGET_TRANSPORT} \ - RELEASE=%{RELEASE} SECURED=%{SECURED} LOGGING=%{LOGGING} ROUTING=%{ROUTING} \ + RELEASE=%{RELEASE} SECURED=%{SECURED} WITH_TCP=%{WITH_TCP} WITH_CLOUD=%{WITH_CLOUD} LOGGING=%{LOGGING} ROUTING=%{ROUTING} \ ES_TARGET_ENROLLEE=%{ES_TARGET_ENROLLEE} LIB_INSTALL_DIR=%{_libdir}