Updates for the Yocto build
authorKishen Maloor <kishen.maloor@intel.com>
Mon, 25 May 2015 10:37:39 +0000 (03:37 -0700)
committerErich Keane <erich.keane@intel.com>
Tue, 26 May 2015 20:04:33 +0000 (20:04 +0000)
* Added libuuid to LIBS in the Yocto build configuration.
* Updated OICSensorBoard client for API change.
* Replaced scons script with Makefile for OICSensorBoard.
* Updated OICSensorBoardREADME to reflect the above change.

Change-Id: I8764616476b7d62d06510999535cef10c132e23d
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1106
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Bernie Keany <bernie.keany@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
build_common/SConscript
examples/OICSensorBoard/Makefile [new file with mode: 0644]
examples/OICSensorBoard/OICSensorBoardREADME.pdf
examples/OICSensorBoard/SConstruct [deleted file]
examples/OICSensorBoard/client.cpp

index 16a81f9..3c50141 100644 (file)
@@ -261,6 +261,7 @@ if target_os == "yocto":
     env.AppendUnique(CFLAGS = ['-std=gnu99'])
     env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
     env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
+    env.AppendUnique(LIBS = ['uuid'])
     Export('env')
 else:
     '''
diff --git a/examples/OICSensorBoard/Makefile b/examples/OICSensorBoard/Makefile
new file mode 100644 (file)
index 0000000..ce6b173
--- /dev/null
@@ -0,0 +1,34 @@
+#Set the two variables below for the client build. 
+CLIENTARCH=x86
+BUILDTYPE=release
+##
+
+YOCTOCXXFLAGS=-I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/stack -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ocrandom -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/logger -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/oc_logger
+
+YOCTOLDFLAGS=-loc -loctbstack -loc_logger -lmraa
+
+CXXFLAGS=-I../../resource/include -I../../resource/csdk/stack/include -I../../resource/csdk/ocrandom/include -I../../resource/csdk/logger/include -I../../resource/oc_logger/include
+
+LDFLAGS=-L../../out/linux/$(CLIENTARCH)/$(BUILDTYPE) -loc -loctbstack -loc_logger
+
+client: client.o
+       g++ -o client client.o $(LDFLAGS)
+
+client.o: client.cpp
+       g++ -std=c++0x -c -o $@ $< $(CXXFLAGS)
+
+observer.o: observer.cpp
+       $(CXX) -std=c++0x -c -o $@ $< $(YOCTOCXXFLAGS)
+
+server.o: server.cpp
+ifeq ($(SDKTARGETSYSROOT),)
+       echo "Error: Yocto cross-toolchain environment not initialized"
+       exit 1 
+endif
+       $(CXX) -std=c++0x -c -o $@ $< $(YOCTOCXXFLAGS)
+
+server: server.o observer.o
+       $(CXX) -o server server.o observer.o $(YOCTOLDFLAGS)
+
+clean:
+       rm -rf server client *.o
index d5f9f2d..e98506b 100644 (file)
Binary files a/examples/OICSensorBoard/OICSensorBoardREADME.pdf and b/examples/OICSensorBoard/OICSensorBoardREADME.pdf differ
diff --git a/examples/OICSensorBoard/SConstruct b/examples/OICSensorBoard/SConstruct
deleted file mode 100644 (file)
index 2a468aa..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#******************************************************************
-#
-# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#This script builds edisonclient for Ubuntu and edisonserver for Yocto.
-
-#Client build for Ubuntu
-#Set IOTIVITY_ROOT to the root of oic-resource on Ubuntu.
-IOTIVITY_ROOT = ''
-#Set IOTIVITY_LIBS_PATH to path on Ubuntu that contains liboc.so, liboctbstack.so, liboc_logger.so and libcoap.so.
-IOTIVITY_LIBS_PATH = ''
-
-env = DefaultEnvironment()
-env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
-env.AppendUnique(LINKFLAGS = ['-pthread'])
-env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'coap'])
-
-envClient = env.Clone()
-envClient.AppendUnique(CPPPATH = [
-                IOTIVITY_ROOT + '/resource/include',
-                IOTIVITY_ROOT + '/resource/csdk/stack/include',
-                IOTIVITY_ROOT + '/resource/oc_logger/include',
-                ])
-envClient.AppendUnique(LIBPATH = [IOTIVITY_LIBS_PATH])
-envClient.Program('edisonclient', 'client.cpp')
-
-#Server build
-envServer = env.Clone()
-'''
-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])):
-                       envServer[tool] = os.path.join(path, os.environ[tool])
-    envServer.Program('edisonserver', ['server.cpp', 'observer.cpp'])
-    envServer.AppendUnique(LIBS = ['mraa'])
-    envServer.AppendUnique(CPPPATH = [
-                sdk_root + '/usr/include/iotivity/',
-                sdk_root + '/usr/include/iotivity/stack/',
-                sdk_root + '/usr/include/iotivity/oc_logger/',
-                ])
-except:
-    print "ERROR configuring Yocto cross-toolchain environment. This is required for building the server"
-
index 4b7fe85..096fa85 100644 (file)
@@ -43,7 +43,7 @@ void IoTClient::initializePlatform()
 void IoTClient::findResource()
 {
     string coap_multicast_discovery = string(OC_WELL_KNOWN_QUERY "?if=" EDISON_RESOURCE_INTERFACE);
-    OCPlatform::findResource("", coap_multicast_discovery.c_str(), m_resourceDiscoveryCallback,
+    OCPlatform::findResource("", coap_multicast_discovery.c_str(),  OC_ALL, m_resourceDiscoveryCallback,
                              OC::QualityOfService::LowQos);
 }