meta-oic: Hotfix to use tools from sysroot before system PATH
[AGL/meta-agl.git] / meta-agl-bsp / meta-oic / recipes-core / iotivity / files / 0364-yocto-Use-tools-from-sysroot-before-system-PATH-agai.patch
1 From b0f0c742ec1e1fc223871f6d98b21de09cf024b7 Mon Sep 17 00:00:00 2001
2 From: Philippe Coval <philippe.coval@osg.samsung.com>
3 Date: Fri, 16 Sep 2016 20:22:03 +0200
4 Subject: [PATCH 364/364] yocto: Use tools from sysroot before system PATH
5  (again)
6
7 Reintroduce existing change that was (wrongly?) removed in:
8
9 https://gerrit.iotivity.org/gerrit/#/c/12029/64/build_common/SConscript
10
11 Original review at:
12
13 https://gerrit.iotivity.org/gerrit/11935
14
15 To ensure reproductibily Scons avoids to rely on environment
16  but some systems like Yocto are defining their own cross compiling env.
17
18 To deal with those orthogonal paradigms,
19  a new CONFIG_ENVIRONMENT_IMPORT variable has been introduced,
20  It enables import of needed variables (PATH and pkg-config's ones).
21
22 Without this change, system tools might be used by scons
23  instead of looking into yocto's sysroot.
24  This is not not wanted and may be less reproductible.
25
26 This problem was noticed when building Ostro OS
27  (on a system without all Yocto dependencies)
28  reported error messages were:
29
30   | sh: gdbus-codegen: command not found
31   | /bin/sh: 1: pkg-config: not found
32
33 More information about using SCONS along Yocto, check some notes at:
34
35 https://bitbucket.org/scons/scons/wiki/Notes
36
37 Bug: https://jira.iotivity.org/browse/IOT-1219
38 Change-Id: I6af59a590f8be489398623d29cf85c2f00000002
39 Origin: https://github.com/TizenTeam/iotivity/tree/sandbox/pcoval/on/master/mine
40 Thanks-to: Mikko Ylinen <mikko.ylinen@intel.com>
41 Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
42 Reviewed-on: https://gerrit.iotivity.org/gerrit/16225
43 Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
44 Reviewed-by: Kishen Maloor <kishen.maloor@intel.com>
45 (cherry picked from commit 1085512bc103e987d95a43063e6552f39acd40f2)
46 Reviewed-on: https://gerrit.iotivity.org/gerrit/16223
47 ---
48  build_common/SConscript | 22 +++++++++++++---------
49  1 file changed, 13 insertions(+), 9 deletions(-)
50
51 diff --git a/build_common/SConscript b/build_common/SConscript
52 index a9ff494..fff1752 100644
53 --- a/build_common/SConscript
54 +++ b/build_common/SConscript
55 @@ -194,13 +194,19 @@ if target_os in targets_support_cc:
56         if prefix or tc_path:
57                 print tc_set_msg
58  
59 -# If cross-compiling, honor environment settings for toolchain to avoid picking up native tools
60 -if os.environ.get('PKG_CONFIG') != None:
61 -       env["ENV"]["PKG_CONFIG"] = os.environ.get("PKG_CONFIG")
62 -if os.environ.get('PKG_CONFIG_PATH') != None:
63 -       env["ENV"]["PKG_CONFIG_PATH"] = os.environ.get("PKG_CONFIG_PATH")
64 -if os.environ.get('PKG_CONFIG_SYSROOT_DIR') != None:
65 -       env["ENV"]["PKG_CONFIG_SYSROOT_DIR"] = os.environ.get("PKG_CONFIG_SYSROOT_DIR")
66 +# Import env variables only if reproductibility is ensured
67 +if target_os in ['yocto']:
68 +    env['CONFIG_ENVIRONMENT_IMPORT'] = True
69 +else:
70 +    env['CONFIG_ENVIRONMENT_IMPORT'] = False
71 +
72 +if env['CONFIG_ENVIRONMENT_IMPORT'] == True:
73 +    print "warning: importing some environment variables for OS: %s" % target_os
74 +    for ev in ['PATH', 'PKG_CONFIG', 'PKG_CONFIG_PATH', 'PKG_CONFIG_SYSROOT_DIR']:
75 +        if os.environ.get(ev) != None:
76 +            env['ENV'][ev] = os.environ.get(ev)
77 +    if os.environ['LDFLAGS'] != None:
78 +        env.AppendUnique(LINKFLAGS = Split(os.environ['LDFLAGS']))
79  
80  # Ensure scons be able to change its working directory
81  env.SConscriptChdir(1)
82 @@ -394,8 +400,6 @@ if target_os == "yocto":
83                          env[tool] = os.path.join(path, os.environ[tool])
84                          break
85          env['CROSS_COMPILE'] = target_prefix[:len(target_prefix) - 1]
86 -        if os.environ['LDFLAGS'] != None:
87 -            env.AppendUnique(LINKFLAGS = Split(os.environ['LDFLAGS']))
88      except:
89          print "ERROR in Yocto cross-toolchain environment"
90          Exit(1)
91 -- 
92 1.9.1
93