Enable building C Samples using scons
authorSashi Penta <sashi.kumar.penta@intel.com>
Fri, 16 Jan 2015 07:45:07 +0000 (23:45 -0800)
committerSashi Penta <sashi.kumar.penta@intel.com>
Fri, 16 Jan 2015 07:45:07 +0000 (23:45 -0800)
Enable building C Samples using scons on CA Branch.
Added third party conditional check for glib-2.0.

Change-Id: Iecaf20645c9d7881021bacc54c756c9d5559f3b6
Signed-off-by: Sashi Penta <sashi.kumar.penta@intel.com>
Signed-off-by: Yamin Al-Mousa <yamin.s.al-mousa@intel.com>
resource/SConscript
resource/csdk/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/third_party_libs.scons

index bc498c0..bff257e 100644 (file)
@@ -27,9 +27,12 @@ if target_os != 'arduino':
        # Build examples
        SConscript('examples/SConscript')
 
+if target_os == 'linux':
+       # Build C Samples
        SConscript('csdk/stack/samples/linux/SimpleClientServer/SConscript')
 
        # Build secure samples
        SConscript('csdk/stack/samples/linux/secure/SConscript')
-else:
+
+elif target_os == 'arduino':
        SConscript('csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript')
index f393088..86e2af6 100644 (file)
@@ -41,9 +41,8 @@ if target_os not in ['arduino', 'windows', 'winrt']:
 if target_os not in ['windows', 'winrt']:
        liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
 
-if target_os == 'android':
-       liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-       liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
+liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
 
 if target_os == 'arduino':
        liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
index e023c22..61c4bac 100644 (file)
@@ -9,35 +9,17 @@ samples_env.PrependUnique(CPPPATH = [
                '../../../../ocsocket/include',
                '../../../../logger/include',
                '../../../../stack/include',
+               '../../../../ocmalloc/include',
                '../../../../../../extlibs/cjson',
                '../../../../../oc_logger/include'
                ])
 
-target_os = env.get('TARGET_OS')
-if target_os not in ['windows', 'winrt']:
-       samples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
-
-       # Note: 'pthread' is in libc for android. On other platform, if use
-       # new gcc(>4.9?) it isn't required, otherwise, it's required
-       if target_os != 'android':
-               samples_env.AppendUnique(LIBS = ['-lpthread'])
-
+samples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
 samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
 samples_env.PrependUnique(LIBS = ['oc', 'm', 'octbstack', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction'])
 
 samples_env.ParseConfig('pkg-config --libs glib-2.0');
 
-if target_os == 'android':
-       samples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       samples_env.AppendUnique(LIBS = ['gnustl_static'])
-       samples_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
-
-       if not env.get('RELEASE'):
-               samples_env.AppendUnique(LIBS = ['log'])
-
-if target_os in ['darwin', 'ios']:
-       samples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-
 samples_env.AppendUnique(CPPDEFINES = ['CA_INT', 'TB_LOG'])
 
 ######################################################################
@@ -45,21 +27,18 @@ samples_env.AppendUnique(CPPDEFINES = ['CA_INT', 'TB_LOG'])
 ######################################################################
 ocserver         = samples_env.Program('ocserver', ['ocserver.cpp', 'common.cpp'])
 occlient         = samples_env.Program('occlient', ['occlient.cpp', 'common.cpp'])
-#ocserverslow     = samples_env.Program('ocserverslow', 'ocserverslow.cpp')
-#occlientslow     = samples_env.Program('occlientslow', 'occlientslow.cpp')
-#ocservercoll     = samples_env.Program('ocservercoll', 'ocservercoll.cpp')
-#occlientcoll     = samples_env.Program('occlientcoll', 'occlientcoll.cpp')
-#ocserverbasicops = samples_env.Program('ocserverbasicops', 'ocserverbasicops.cpp')
-#occlientbasicops = samples_env.Program('occlientbasicops', 'occlientbasicops.cpp')
+ocserverslow     = samples_env.Program('ocserverslow', ['ocserverslow.cpp', 'common.cpp'])
+occlientslow     = samples_env.Program('occlientslow', ['occlientslow.cpp', 'common.cpp'])
+ocservercoll     = samples_env.Program('ocservercoll', ['ocservercoll.cpp', 'common.cpp'])
+occlientcoll     = samples_env.Program('occlientcoll', ['occlientcoll.cpp', 'common.cpp'])
+ocserverbasicops = samples_env.Program('ocserverbasicops', ['ocserverbasicops.cpp', 'common.cpp'])
+occlientbasicops = samples_env.Program('occlientbasicops', ['occlientbasicops.cpp', 'common.cpp'])
 
 Alias("samples", [ocserver, occlient,
-                               #ocservercoll, occlientcoll,
-                               #ocserverbasicops, occlientbasicops,
-                               #ocserverslow, occlientslow
+                               ocservercoll, occlientcoll,
+                               ocserverbasicops, occlientbasicops,
+                               ocserverslow, occlientslow
                 ])
 
 env.AppendTarget('samples')
 
-#ios doesn't allow run application from terminal, so won't build these samples
-#if target_os != 'ios':
-#      SConscript('ocicuc/SConscript')
index 4b1c902..28fa4f1 100644 (file)
@@ -32,6 +32,11 @@ if target_os in ['linux', 'tizen']:
                        print 'Did not find boost_program_options, exiting!'
                        Exit(1)
 
+               if not conf.CheckLib('glib-2.0'):
+                       print 'Install glib-2 on ubuntu with the following command'
+                       print 'sudo apt-get install libglib2.0-dev'
+                       Exit(1)
+
                conf.Finish()