1 #This script builds edisonclient for Ubuntu and edisonserver for Yocto.
3 #Client build for Ubuntu
4 #Set IOTIVITY_ROOT to the root of oic-resource on Ubuntu.
6 #Set IOTIVITY_LIBS_PATH to path on Ubuntu that contains liboc.so, liboctbstack.so, liboc_logger.so and libcoap.so.
7 IOTIVITY_LIBS_PATH = ''
9 env = DefaultEnvironment()
10 env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
11 env.AppendUnique(LINKFLAGS = ['-pthread'])
12 env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'coap'])
14 envClient = env.Clone()
15 envClient.AppendUnique(CPPPATH = [
16 IOTIVITY_ROOT + '/resource/include',
17 IOTIVITY_ROOT + '/resource/csdk/stack/include',
18 IOTIVITY_ROOT + '/resource/csdk/ocsocket/include',
19 IOTIVITY_ROOT + '/resource/oc_logger/include',
21 envClient.AppendUnique(LIBPATH = [IOTIVITY_LIBS_PATH])
22 envClient.Program('edisonclient', 'client.cpp')
25 envServer = env.Clone()
27 This code injects Yocto cross-compilation flags into scons' default environment
28 in order to invoke the relevant tools while performing a build.
34 sdk_root = re.search(r'--sysroot=\S+', CC).group().split('=')[1]
35 target_prefix = CC.split()[0]
36 target_prefix = target_prefix[:len(target_prefix)-3]
37 tools = {"CC" : target_prefix+"gcc",
38 "CXX" : target_prefix+"g++",
39 "AS" : target_prefix+"as",
40 "LD" : target_prefix+"ld",
41 "GDB" : target_prefix+"gdb",
42 "STRIP" : target_prefix+"strip",
43 "RANLIB" : target_prefix+"ranlib",
44 "OBJCOPY" : target_prefix+"objcopy",
45 "OBJDUMP" : target_prefix+"objdump",
46 "AR" : target_prefix+"ar",
47 "NM" : target_prefix+"nm",
49 "STRINGS": target_prefix+"strings"}
50 PATH = os.environ['PATH'].split(os.pathsep)
52 if tool in os.environ:
54 if os.path.isfile(os.path.join(path, tools[tool])):
55 envServer[tool] = os.path.join(path, os.environ[tool])
56 envServer.Program('edisonserver', ['server.cpp', 'observer.cpp'])
57 envServer.AppendUnique(LIBS = ['mraa'])
58 envServer.AppendUnique(CPPPATH = [
59 sdk_root + '/usr/include/iotivity/',
60 sdk_root + '/usr/include/iotivity/stack/',
61 sdk_root + '/usr/include/iotivity/ocsocket/',
62 sdk_root + '/usr/include/iotivity/oc_logger/',
65 print "ERROR configuring Yocto cross-toolchain environment. This is required for building the server"