build: Apply OCF patch if needed
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Wed, 1 Feb 2017 12:53:41 +0000 (13:53 +0100)
committerKevin Kane <kkane@microsoft.com>
Fri, 3 Mar 2017 22:31:48 +0000 (22:31 +0000)
Bug: https://jira.iotivity.org/browse/IOT-1745
Change-Id: I2928fed0a97b51f358a0f87f35b164317b4d7b9d
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Origin: https://gerrit.iotivity.org/gerrit/#/c/16967/
Reviewed-on: https://gerrit.iotivity.org/gerrit/16967
Reviewed-by: Mats Wichmann <mats@linux.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: George Nash <george.nash@intel.com>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
extlibs/mbedtls/SConscript

index 9400c95..cc58b24 100644 (file)
@@ -64,12 +64,25 @@ if target_os != 'tizen':
         Exit(1)
 
 
-# Apply ocf patch on git revision
-if os.path.exists('.git/HEAD'):
-    cmd = 'git checkout development && git reset --hard ' + mbedtls_revision + ' && git clean -f && git apply --whitespace=fix ../ocf.patch'
-    os.system(cmd)
-else:
-    print 'mbedtls: Assume ocf.patch (TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256) was applied in %s' % mbedtls_dir
+pattern = 'TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256'
+found = False
+import re
+import sys
+mbedtls_header = os.path.join('include', 'mbedtls', 'compat-1.3.h')
+with open(mbedtls_header, 'r') as stream:
+    for line in stream:
+        if pattern in line:
+            found = True
+            break
+if not found:
+    if os.path.exists('.git/HEAD'):
+        # Apply ocf patch on git revision
+        cmd = 'git checkout development && git reset --hard ' + mbedtls_revision + ' && git clean -f && git apply --whitespace=fix ../ocf.patch'
+        os.system(cmd)
+    else:
+        print "mbedtls: error: missing %s" % pattern
+        Exit(1)
+
 os.chdir(start_dir)
 
 # Copy IoTivity's version of the mbedtls build configuration file