IoTivity scons build update for Yocto
authorKishen Maloor <kishen.maloor@intel.com>
Wed, 6 May 2015 22:26:38 +0000 (15:26 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 7 May 2015 16:21:27 +0000 (16:21 +0000)
* Added meta data for other architectures supported
by the Yocto toolchain. (For eg. we can now
build IoTivity for ARM/RaspberryPi)
* Added additional required compiler flags to be
used while building IoTivity for Yocto.
* Added new CROSS_COMPILE key to the construction
environment which can be used to build IoTivity's
external dependencies for Yocto. (For eg. gtest
uses autoconf, so CROSS_COMPILE gets passed in with
the --host switch)

Change-Id: Iad52c4fbc597abde32baf53205ddbd46e22f122b
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/919
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Caiwen Zhang <caiwen.zhang@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
build_common/SConscript
extlibs/gtest/SConscript
resource/csdk/connectivity/build/SConscript

index 1a65752..abe8f50 100644 (file)
@@ -22,7 +22,7 @@ os_arch_map = {
                'darwin': ['i386', 'x86_64'],
                'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
                'arduino': ['avr', 'arm'],
-               'yocto': ['x86', 'x86_64'],
+               'yocto': ['i586', 'x86_64', 'arm', 'powerpc', 'powerpc64', 'mips', 'mipsel'],
                }
 
 host = platform.system().lower()
@@ -234,6 +234,7 @@ if target_os == "yocto":
                     if os.path.isfile(os.path.join(path, tools[tool])):
                         env[tool] = os.path.join(path, os.environ[tool])
                         break
+        env['CROSS_COMPILE'] = target_prefix[:len(target_prefix) - 1]
     except:
         print "ERROR in Yocto cross-toolchain environment"
         Exit(1)
@@ -246,7 +247,18 @@ if target_os == "yocto":
     We want to preserve debug symbols to allow BitBake to generate both DEBUG and
     RELEASE packages for OIC.
     '''
-    env['CCFLAGS'].append('-g')
+    env.AppendUnique(CCFLAGS = ['-g'])
+    '''
+    Additional flags to pass to the Yocto toolchain.
+    '''
+    if env.get('RELEASE'):
+        env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+    if env.get('LOGGING'):
+        env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__linux__', '_GNU_SOURCE'])
+    env.AppendUnique(CFLAGS = ['-std=gnu99'])
+    env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
+    env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
     Export('env')
 else:
     '''
index 522b3e1..396e4f3 100644 (file)
@@ -68,7 +68,10 @@ elif target_os == 'linux':
                if not os.path.exists(gtest_dir + "/lib"):
                        # Run configure on gtest
                        print 'Configuring google unit test'
-                       env.Configure(gtest_dir, './configure')
+                       if env.get('CROSS_COMPILE'): 
+                               env.Configure(gtest_dir, './configure --host=' + env['CROSS_COMPILE'])
+                       else:
+                               env.Configure(gtest_dir, './configure')
 
                        # Run make on gtest
                        print 'Making google unit test'
index 93a102a..b29c55a 100644 (file)
@@ -22,7 +22,7 @@ os_arch_map = {
                'darwin': ['i386', 'x86_64'],
                'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
                'arduino': ['avr', 'arm'],
-               'yocto': ['x86', 'x86_64'],
+                'yocto': ['i586', 'x86_64', 'arm', 'powerpc', 'powerpc64', 'mips', 'mipsel'],
                }
 
 host = platform.system().lower()
@@ -221,6 +221,7 @@ if target_os == "yocto":
                     if os.path.isfile(os.path.join(path, tools[tool])):
                         env[tool] = os.path.join(path, os.environ[tool])
                         break
+        env['CROSS_COMPILE'] = target_prefix[:len(target_prefix) - 1]
     except:
         print "ERROR in Yocto cross-toolchain environment"
         Exit(1)
@@ -233,7 +234,18 @@ if target_os == "yocto":
     We want to preserve debug symbols to allow BitBake to generate both DEBUG and
     RELEASE packages for OIC.
     '''
-    env['CCFLAGS'].append('-g')
+    env.AppendUnique(CCFLAGS = ['-g'])
+    '''
+    Additional flags to pass to the Yocto toolchain.
+    '''
+    if env.get('RELEASE'):
+        env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+    if env.get('LOGGING'):
+        env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__linux__', '_GNU_SOURCE'])
+    env.AppendUnique(CFLAGS = ['-std=gnu99'])
+    env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
+    env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
     Export('env')
 else:
     '''