summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSashi Penta <sashi.kumar.penta@intel.com>2015-01-29 14:56:08 -0800
committerSudarshan Prasad <sudarshan.prasad@intel.com>2015-01-31 20:49:25 +0000
commit61d1cb4bad20c304abe225ad91aaf16175ada8e9 (patch)
treea628dbbdc6f97e152d4c22c9dbe07f43adde5d79 /examples
parent90f3cc6e9b96f7790502158faca65b3a37acb838 (diff)
downloadiotivity-61d1cb4bad20c304abe225ad91aaf16175ada8e9.tar.gz
iotivity-61d1cb4bad20c304abe225ad91aaf16175ada8e9.tar.bz2
iotivity-61d1cb4bad20c304abe225ad91aaf16175ada8e9.zip
Build OICMiddle using Scons on CA branch
Change-Id: I63ad62700ee87b13c316fcf04d8e2c1fa42f4cc0 Signed-off-by: Sashi Penta <sashi.kumar.penta@intel.com> Reviewed-on: https://gerrit.iotivity.org/gerrit/274 Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> Reviewed-by: John Light <john.j.light@intel.com> Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/OICMiddle/Client.cpp2
-rw-r--r--examples/OICMiddle/SConscript60
-rw-r--r--examples/OICMiddle/SConstruct81
3 files changed, 61 insertions, 82 deletions
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<OCResource> 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)