From 071362db1f6774f1270dd31e8845cb9458d83351 Mon Sep 17 00:00:00 2001 From: Kishen Maloor Date: Wed, 6 May 2015 15:26:38 -0700 Subject: [PATCH] IoTivity scons build update for Yocto * 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/919 Tested-by: jenkins-iotivity Reviewed-by: Caiwen Zhang Reviewed-by: Erich Keane --- build_common/SConscript | 16 ++++++++++++++-- extlibs/gtest/SConscript | 5 ++++- resource/csdk/connectivity/build/SConscript | 16 ++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/build_common/SConscript b/build_common/SConscript index 1a65752..abe8f50 100644 --- a/build_common/SConscript +++ b/build_common/SConscript @@ -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: ''' diff --git a/extlibs/gtest/SConscript b/extlibs/gtest/SConscript index 522b3e1..396e4f3 100644 --- a/extlibs/gtest/SConscript +++ b/extlibs/gtest/SConscript @@ -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' diff --git a/resource/csdk/connectivity/build/SConscript b/resource/csdk/connectivity/build/SConscript index 93a102a..b29c55a 100644 --- a/resource/csdk/connectivity/build/SConscript +++ b/resource/csdk/connectivity/build/SConscript @@ -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: ''' -- 2.7.4