extlibs: Use patch as fallback and trap errors
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Wed, 22 Mar 2017 08:27:25 +0000 (09:27 +0100)
committerZiran Sun <ziran.sun@samsung.com>
Tue, 18 Apr 2017 10:20:33 +0000 (10:20 +0000)
This will be helpful for Tizen and others OS.

If lib is bundled as "imported git patch"
then application of "duplicated ocf.patch as git patch",
is not needed anymore, and relies on scons.

To Tizen maintainers:
From now on let's maintain only one version in tree,
ealier versions of git patches can be reverted,
For reference check:
https://wiki.iotivity.org/tizen#maintenance_tips

Bug: https://jira.iotivity.org/browse/IOT-1745
Change-Id: I0598ddd5c846a2286218879d57381ec2f20c17a4
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18661
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
extlibs/mbedtls/SConscript

index 1cd4cef..ed90ffb 100644 (file)
@@ -19,7 +19,7 @@
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 Import('env')
-
+import SCons.Errors
 import os
 import sys
 import subprocess
@@ -79,10 +79,13 @@ 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)
+        res = os.system(cmd)
     else:
-        print "mbedtls: error: missing %s" % pattern
-        Exit(1)
+        # Fallback to regular patch command
+        cmd = 'patch -p1 -l -f < ../ocf.patch'
+        res = os.system(cmd)
+    if 0 != res:
+        raise SCons.Errors.StopError('mbedtls: issue on applying patch: %d' % res)
 
 os.chdir(start_dir)