Enable building C Samples using scons
authorCaiwen Zhang <caiwen.zhang@intel.com>
Fri, 16 Jan 2015 07:12:52 +0000 (15:12 +0800)
committerCaiwen Zhang <caiwen.zhang@intel.com>
Fri, 16 Jan 2015 07:16:49 +0000 (15:16 +0800)
Change-Id: I9de4f80a0abe0cd1da14b2abb063e3deda928cba
Signed-off-by: Sashi Penta <sashi.kumar.penta@intel.com>
Signed-off-by: Caiwen Zhang <caiwen.zhang@intel.com>
resource/SConscript
resource/csdk/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript [new file with mode: 0644]

index e1ad14e21e687978e1fd0b22222dc086649aba5f..ead728ec4fa4fc220c13c0cf44a5f6e69265f506 100644 (file)
@@ -25,5 +25,9 @@ if target_os != 'arduino':
 
        # Build examples
        SConscript('examples/SConscript')
-else:
-       SConscript('csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript')
\ No newline at end of file
+
+if target_os == 'linux':
+       # Build c samples
+       SConscript('csdk/stack/samples/linux/SimpleClientServer/SConscript')
+elif target_os == 'arduino':
+       SConscript('csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript')
index 65d02a192edb8e767d000f6120ad354654f115c3..e1b0f1a2ce99db335a114f91fb97c923f317ae83 100644 (file)
@@ -39,9 +39,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'])
@@ -50,8 +49,6 @@ else:
 
 if target_os in ['darwin', 'ios']:
        liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-       liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-       liboctbstack_env.AppendUnique(LIBS = ['coap'])
 
 if not env.get('RELEASE'):
        liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/SConscript b/resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
new file mode 100644 (file)
index 0000000..e22d396
--- /dev/null
@@ -0,0 +1,45 @@
+
+Import('env')
+
+samples_env = env.Clone()
+######################################################################
+# Build flags
+######################################################################
+samples_env.PrependUnique(CPPPATH = [
+               '../../../../ocsocket/include',
+               '../../../../logger/include',
+               '../../../../stack/include',
+               '../../../../ocmalloc/include',
+               '../../../../../../extlibs/cjson',
+               '../../../../../oc_logger/include'
+               ])
+
+samples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+
+samples_env.AppendUnique(LIBS = ['-lpthread'])
+
+samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+samples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'oc_logger', 'm'])
+
+samples_env.AppendUnique(CPPDEFINES = ['CA_INT', 'TB_LOG'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+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', '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
+                ])
+
+env.AppendTarget('samples')
+