From 61d1cb4bad20c304abe225ad91aaf16175ada8e9 Mon Sep 17 00:00:00 2001 From: Sashi Penta Date: Thu, 29 Jan 2015 14:56:08 -0800 Subject: Build OICMiddle using Scons on CA branch Change-Id: I63ad62700ee87b13c316fcf04d8e2c1fa42f4cc0 Signed-off-by: Sashi Penta Reviewed-on: https://gerrit.iotivity.org/gerrit/274 Tested-by: jenkins-iotivity Reviewed-by: John Light Reviewed-by: Sudarshan Prasad --- examples/OICMiddle/Client.cpp | 2 +- examples/OICMiddle/SConscript | 60 ++++++++++++++++++++++++++++++++ examples/OICMiddle/SConstruct | 81 ------------------------------------------- 3 files changed, 61 insertions(+), 82 deletions(-) create mode 100644 examples/OICMiddle/SConscript delete mode 100644 examples/OICMiddle/SConstruct (limited to 'examples') diff --git a/examples/OICMiddle/Client.cpp b/examples/OICMiddle/Client.cpp index 8d6e7d16e..1aafde946 100644 --- a/examples/OICMiddle/Client.cpp +++ b/examples/OICMiddle/Client.cpp @@ -38,7 +38,7 @@ void MiddleClient::findResources() { m_resourceMap.clear(); - OC::OCPlatform::findResource("", OC_WELL_KNOWN_QUERY, m_findCB); + OC::OCPlatform::findResource("", OC_WELL_KNOWN_QUERY, OC_WIFI, m_findCB); } void MiddleClient::foundOCResource(shared_ptr resource) diff --git a/examples/OICMiddle/SConscript b/examples/OICMiddle/SConscript new file mode 100644 index 000000000..56c42eacf --- /dev/null +++ b/examples/OICMiddle/SConscript @@ -0,0 +1,60 @@ +## +# Examples build script +## +Import('env') +# Add third party libraries +lib_env = env.Clone() +SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env') + +examples_env = lib_env.Clone() + +###################################################################### +# Build flags +###################################################################### +examples_env.AppendUnique(CPPPATH = [ + '../../resource/include/', + '../../resource/csdk/stack/include', + '../../resource/csdk/ocsocket/include', + '../../resource/csdk/ocrandom/include', + '../../resource/csdk/logger/include', + '../../resource/csdk/libcoap', + '../../resource/oc_logger/include' + ]) + +target_os = env.get('TARGET_OS') +if target_os not in ['windows', 'winrt']: + examples_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': + examples_env.AppendUnique(LIBS = ['-lpthread']) + +examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) +examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction']) +if env.get('SECURED') == '1': + examples_env.AppendUnique(LIBS = ['tinydtls']) + +examples_env.ParseConfig('pkg-config --libs glib-2.0'); + +if target_os == 'android': + examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) + examples_env.AppendUnique(LIBS = ['gnustl_static']) + + if not env.get('RELEASE'): + examples_env.AppendUnique(LIBS = ['log']) + +if target_os in ['darwin', 'ios']: + examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE']) + +examples_env.AppendUnique(CPPDEFINES = ['CA_INT']) + +###################################################################### +# Source files and Targets +###################################################################### +OICMiddle = examples_env.Program('OICMiddle', ['OICMiddle.cpp', 'Client.cpp', 'LineInput.cpp', 'RestInput.cpp', 'Server.cpp', 'WrapResource.cpp']) + +Alias("examples", [OICMiddle]) +env.AppendTarget('examples') + + diff --git a/examples/OICMiddle/SConstruct b/examples/OICMiddle/SConstruct deleted file mode 100644 index 02a2d8e9b..000000000 --- a/examples/OICMiddle/SConstruct +++ /dev/null @@ -1,81 +0,0 @@ -#For Yocto builds, set OS=yocto as a command-line argument to scons once -#the Yocto toolchain is installed and configured. - -#For Linux builds, set the following two variables: -#Set OIC_RESOURCE_PATH to the root of oic-resource on Ubuntu. - -OIC_RESOURCE_PATH = '../..' - -#Set OIC_LIBS_PATH to path on Ubuntu that contains liboc.so, liboctbstack.so, -#liboc_logger.so and libcoap.so. - -OIC_LIBS_PATH = '../../out/linux/x86_64/release' - -env = DefaultEnvironment() -target_os = ARGUMENTS.get("OS", "linux").lower() -output_dir = env.GetLaunchDir() + "/out/" + target_os -env.VariantDir(output_dir, env.GetLaunchDir(), duplicate=0) -env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall']) -env.AppendUnique(LINKFLAGS = ['-pthread']) -env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'coap']) -env.Program(output_dir + '/OICMiddle', [output_dir + '/OICMiddle.cpp', - output_dir + '/Client.cpp', - output_dir + '/Server.cpp', - output_dir + '/WrapResource.cpp', - output_dir + '/LineInput.cpp', - output_dir + '/RestInput.cpp']) - -if target_os == "yocto": - ''' - This code injects Yocto cross-compilation flags into scons' default environment - in order to invoke the relevant tools while performing a build. - ''' - import os.path, re - sdk_root = '' - try: - CC = os.environ['CC'] - sdk_root = re.search(r'--sysroot=\S+', CC).group().split('=')[1] - target_prefix = CC.split()[0] - target_prefix = target_prefix[:len(target_prefix)-3] - tools = {"CC" : target_prefix+"gcc", - "CXX" : target_prefix+"g++", - "AS" : target_prefix+"as", - "LD" : target_prefix+"ld", - "GDB" : target_prefix+"gdb", - "STRIP" : target_prefix+"strip", - "RANLIB" : target_prefix+"ranlib", - "OBJCOPY" : target_prefix+"objcopy", - "OBJDUMP" : target_prefix+"objdump", - "AR" : target_prefix+"ar", - "NM" : target_prefix+"nm", - "M4" : "m4", - "STRINGS": target_prefix+"strings"} - PATH = os.environ['PATH'].split(os.pathsep) - for tool in tools: - if tool in os.environ: - for path in PATH: - if os.path.isfile(os.path.join(path, tools[tool])): - env[tool] = os.path.join(path, os.environ[tool]) - env.AppendUnique(CPPPATH = [ - sdk_root + '/usr/include/oic/', - sdk_root + '/usr/include/oic/stack/', - sdk_root + '/usr/include/oic/ocsocket/', - sdk_root + '/usr/include/oic/oc_logger/', - ]) - except: - print "ERROR configuring Yocto cross-toolchain environment." - Exit(1) -elif target_os == "linux": - if OIC_RESOURCE_PATH == '' or OIC_LIBS_PATH == '': - print "ERROR Please set both OIC_RESOURCE_PATH and OIC_LIBS_PATH in SConstruct" - Exit(1) - env.AppendUnique(CPPPATH = [ - OIC_RESOURCE_PATH + '/resource/include', - OIC_RESOURCE_PATH + '/resource/csdk/stack/include', - OIC_RESOURCE_PATH + '/resource/csdk/ocsocket/include', - OIC_RESOURCE_PATH + '/resource/oc_logger/include', - ]) - env.AppendUnique(LIBPATH = [OIC_LIBS_PATH]) -else: - print "ERROR ", target_os, " is an unsupported target" - Exit(1) -- cgit v1.2.3