--- /dev/null
+1) Build with default option
+ To build with default option:
+ # scons
+
+ To see help information with default option(the output may be different with different options):
+ # scons -Q -h
+
+ To clean the project:
+ # scons -c
+
+2) Build with options
+ To build with options:
+ # scons OPTION1=xxx OPTION2=xxx OPTION3=....
+
+ To see help information:
+ # scons OPTION1=xxx OPTION2=xxx OPTION3=.... -Q -h
+
+ To clean the project:
+ # scons OPTION1=xxx OPTION2=xxx OPTION3=.... -c
+
+3) Examples
+ To build default
+ # scons
+ To see default help
+ # scons -Q -h
+ To clean
+ # scons -c
+
+ To build android armeabi-v7a
+ # scon BUILD_TARGET=Android CPU_ARCH=armeabi-v7a
+ To see help
+ # scon BUILD_TARGET=Android CPU_ARCH=armeabi-v7a -Q -h
+ To clean
+ # scon BUILD_TARGET=Android CPU_ARCH=armeabi-v7a -c
+
+Note:
+ 1. To build android binary, android NDK should be newer than r8e(recommend r10).
+ 2. You may be asked to set some options. Besides set it in command line, you
+can also set it by create a environment variable. Command line has higher priority.
+If both are set, the command line value will be used.
--- /dev/null
+##
+# The main build script
+#
+##
+import os
+
+SRC_TOP_DIR = os.path.abspath('.') + '/' #oic-resource project top directory
+
+# Common build options
+SConscript('build_common/SConscript')
+Import('RELEASE_BUILD', 'BUILD_TARGET', 'TARGET_CPU_ARCH')
+
+# Set build directory
+if RELEASE_BUILD:
+ BUILD_DIR = SRC_TOP_DIR + '/out/' + BUILD_TARGET + '/' + TARGET_CPU_ARCH + '/release/'
+else:
+ BUILD_DIR = SRC_TOP_DIR + '/out/' + BUILD_TARGET + '/' + TARGET_CPU_ARCH + '/debug/'
+VariantDir(BUILD_DIR, SRC_TOP_DIR, duplicate=0)
+Export('SRC_TOP_DIR', 'BUILD_DIR')
+
+if BUILD_TARGET == 'arduino':
+ SConscript('arduino.scons')
+
+# Build libcoap
+SConscript(BUILD_DIR + 'csdk/libcoap/SConscript')
+
+# Build liboctbstack
+SConscript(BUILD_DIR + 'csdk/SConscript')
+
+if BUILD_TARGET != 'arduino':
+ # Build liboc_logger
+ SConscript(BUILD_DIR + 'oc_logger/SConscript')
+
+ # Build liboc
+ SConscript(BUILD_DIR + 'src/SConscript')
+
+ # Build examples
+ SConscript(BUILD_DIR + 'examples/SConscript')
+
+# Print targets
+Import('env')
+
+Help('''
+===============================================================================
+Targets:\n ''')
+for t in env.get('TS'):
+ Help(t + ' ')
+Help('''
+\nDefault all targets will be built. You can specify the target to build:
+
+ #scons [options] [target]
+===============================================================================
+''')
\ No newline at end of file
--- /dev/null
+##
+# This script includes arduino specific config for oic-resource
+##
+Import('env', 'TARGET_CPU_ARCH', 'ARDUINO_HOME')
+
+# 'NET' build option
+if env.get('NET') is None:
+ vars = Variables()
+ vars.Add(EnumVariable('NET', 'Network connection type', 'Ethernet', ['Ethernet', 'Wifi']))
+ vars.Update(env)
+ Help(vars.GenerateHelpText(env))
+
+env.AppendUnique(CPPPATH = [
+ ARDUINO_HOME + '/libraries/Ethernet/src',
+ ARDUINO_HOME + '/libraries/Ethernet/src/utility',
+ ARDUINO_HOME + '/libraries/WiFi/src',
+ ARDUINO_HOME + '/libraries/WiFi/src/utility',
+ ARDUINO_HOME + '/libraries/Time/',
+ ])
+
+if TARGET_CPU_ARCH == 'arm':
+ # Include path
+ env.AppendUnique(CPPPATH = [
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/USB',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/avr',
+ ARDUINO_HOME + '/hardware/arduino/sam/system/libsam',
+ ARDUINO_HOME + '/hardware/arduino/sam/system/CMSIS/CMSIS/Include',
+ ARDUINO_HOME + '/hardware/arduino/sam/system/CMSIS/Device/ATMEL',
+ ARDUINO_HOME + '/hardware/arduino/sam/variants/arduino_due_x',
+ ARDUINO_HOME + '/hardware/arduino/sam/libraries/SPI',
+ ])
+
+ # Compiler/Linker flags
+ env.AppendUnique(CXXFLAGS = ['-ffunction-sections', '-fdata-sections', '-nostdlib',
+ '--param', 'max-inline-insns-single=500', '-fno-rtti', '-fno-exceptions',
+ '-mcpu=cortex-m3', '-mthumb'
+ ])
+ env.AppendUnique(CPPDEFINES = ['printf=iprintf', 'F_CPU=84000000L', 'ARDUINO=157',
+ 'ARDUINO_SAM_DUE', 'ARDUINO_ARCH_SAM', '__SAM3X8E__', 'USB_VID=0x2341',
+ 'USB_PID=0x003e', 'USBCON', 'DUSB_MANUFACTURER="Unknown"', 'WITH_ARDUINO',
+ ])
+
+ # Source
+ ARDUINO_SRC = []
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/*.c'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/*.cpp'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/avr/*.c'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/USB/*.cpp'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/variants/arduino_due_x/*.cpp'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/libraries/SPI/*.cpp'))
+else:
+ # Include path
+ env.AppendUnique(CPPPATH = [
+ ARDUINO_HOME + '/hardware/arduino/avr/cores/arduino',
+ ARDUINO_HOME + '/hardware/arduino/avr/libraries/SPI',
+ ARDUINO_HOME + '/hardware/arduino/avr/variants/mega',
+ ])
+
+ # Compiler/Linker flags
+ env.AppendUnique(CXXFLAGS = ['-mmcu=atmega2560', '-MMD', '-std=c++0x',
+ '-Wno-write-strings', '-ffunction-sections', '-fdata-sections',
+ '-fno-exceptions', '-felide-constructors'
+ ])
+ env.AppendUnique(CPPDEFINES = ['F_CPU=16000000L', 'ARDUINO=156', 'ARDUINO_AVR_MEGA2560',
+ 'ARDUINO_ARCH_AVR', 'WITH_ARDUINO', 'ATMEGA2560'
+ ])
+
+ # Source
+ ARDUINO_SRC = [
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/WInterrupts.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/wiring.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/wiring_digital.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/main.cpp',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/Stream.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/WMath.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/WString.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/HardwareSerial.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/Print.c',
+ ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/IPAddress.c',
+ ARDUINO_HOME + '/hardware/arduino/avr/libraries/SPI/SPI.cpp',
+ ]
+
+if env.get('NET') == 'Ethernet':
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/Ethernet/src/*.cpp'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/Ethernet/src/utility/*.cpp'))
+else:
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/WiFi/src/*.cpp'))
+ ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/WiFi/src/utility/*.cpp'))
+
+Export('ARDUINO_SRC')
\ No newline at end of file
--- /dev/null
+#! /bin/bash
+
+function clean()
+{
+ echo "*********** Clean build *************"
+ scons -c
+ rm out -rf
+}
+
+function build()
+{
+ echo "*********** Build for linux *************"
+ scons
+
+ # Note: for android, as oic-resource uses C++11 feature stoi and to_string,
+ # it requires gcc-4.9, currently only android-ndk-r10(for linux)
+ # and windows android-ndk-r10(64bit target version) support these features.
+
+ echo "*********** Build for android x86 *************"
+ scons BUILD_TARGET=Android CPU_ARCH=x86 ANDROID_HOME=$1 ANDROID_NDK=$2
+
+ echo "*********** Build for android armeabi *************"
+ scons BUILD_TARGET=Android CPU_ARCH=armeabi ANDROID_HOME=$1 ANDROID_NDK=$2
+
+ echo "*********** Build for android armeabi-v7a *************"
+ scons BUILD_TARGET=Android CPU_ARCH=armeabi-v7a ANDROID_HOME=$1 ANDROID_NDK=$2
+
+ echo "*********** Build for android armeabi-v7a-hard *************"
+ scons BUILD_TARGET=Android CPU_ARCH=armeabi-v7a-hard ANDROID_HOME=$1 ANDROID_NDK=$2
+
+ echo "*********** Build for arduino avr *************"
+ scons BUILD_TARGET=Arduino CPU_ARCH=avr ARDUINO_HOME=$3
+
+ echo "*********** Build for arduino arm *************"
+ scons BUILD_TARGET=Arduino CPU_ARCH=arm ARDUINO_HOME=$3
+
+ if [ $(uname -s) = "Darwin" ]
+ then
+ echo "*********** Build for OSX i386 *************"
+ scons BUILD_TARGET=Darwin CPU_ARCH=i386 SYS_VERSION=10.9
+
+ echo "*********** Build for OSX x86_64 *************"
+ scons BUILD_TARGET=Darwin CPU_ARCH=x86_64 SYS_VERSION=10.9
+
+ echo "*********** Build for IOS i386 *************"
+ scons BUILD_TARGET=IOS CPU_ARCH=i386 SYS_VERSION=7.0
+
+ echo "*********** Build for IOS x86_64 *************"
+ scons BUILD_TARGET=IOS CPU_ARCH=x86_64 SYS_VERSION=7.0
+
+ echo "*********** Build for IOS armv7 *************"
+ scons BUILD_TARGET=IOS CPU_ARCH=armv7 SYS_VERSION=7.0
+
+ echo "*********** Build for IOS armv7s *************"
+ scons BUILD_TARGET=IOS CPU_ARCH=armv7s SYS_VERSION=7.0
+
+ echo "*********** Build for IOS arm64 *************"
+ scons BUILD_TARGET=IOS CPU_ARCH=arm64 SYS_VERSION=7.0
+ fi
+}
+
+function help()
+{
+ echo "Usage:"
+ echo " build:"
+ echo " `basename $0` <path-to-android-sdk> <path-to-android-ndk> <path-to-arduino-home>"
+ echo " clean:"
+ echo " `basename $0` -c"
+}
+
+if [ $# -eq 1 ]
+then
+ if [ $1 = '-c' ]
+ then
+ clean
+ exit 0
+ else
+ help
+ exit -1
+ fi
+elif [ $# -ne 3 ]
+then
+ help
+ exit -1
+fi
+
+
+build $1 $2 $3
+echo "===================== done ====================="
--- /dev/null
+##
+# This script includes generic build options:
+# release/debug, build target, CPU ARCH, toolchain, build environment etc
+##
+import os
+import platform
+
+host = platform.system()
+default_arch = platform.machine()
+
+if host not in ['Linux', 'Windows', 'Darwin']:
+ host = 'Linux'
+
+# Map of host and allowed targets
+allow_target_map = {
+ 'Linux': ['Linux', 'Android', 'Arduino'],
+ 'Windows': ['Windows', 'WinRT', 'Android', 'Arduino'],
+ 'Darwin': ['Darwin', 'IOS', 'Android', 'Arduino'],
+ }
+
+# Map of platform(target) and allowed archs
+allow_arch_map = {
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+ 'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
+ 'windows': ['x86', 'amd64', 'arm'],
+ 'winrt': ['arm'],
+ 'darwin': ['i386', 'x86_64'],
+ 'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+ 'arduino': ['avr', 'arm'],
+ }
+
+######################################################################
+# Get build options (the optins from command line)
+######################################################################
+BUILD_TARGET = ARGUMENTS.get('BUILD_TARGET', host).lower() # target platform
+
+if not allow_arch_map.has_key(BUILD_TARGET):
+ print "\nError: Unknown target platform: %s (Allow values: %s)\n" % (BUILD_TARGET, allow_target_map[host])
+ Exit(1)
+
+if default_arch not in allow_arch_map[BUILD_TARGET]:
+ default_arch = allow_arch_map[BUILD_TARGET][0]
+ default_arch = default_arch.lower()
+
+TARGET_CPU_ARCH = ARGUMENTS.get('CPU_ARCH', default_arch) # target CPU ARCH
+ANDROID_NDK = ARGUMENTS.get('ANDROID_NDK', os.environ.get('ANDROID_NDK')) # ANDROID NDK base directory
+SYS_VERSION = ARGUMENTS.get('SYS_VERSION', os.environ.get('SYS_VERSION')) # OSX/IOS version
+ARDUINO_HOME = ARGUMENTS.get('ARDUINO_HOME', os.environ.get('ARDUINO_HOME')) # ARDUINO root directory
+
+######################################################################
+# Common build options (release, build target, CPU)
+######################################################################
+vars = Variables()
+vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
+vars.Add(EnumVariable('BUILD_TARGET', 'Target platform', host, allow_target_map[host]))
+vars.Add(EnumVariable('CPU_ARCH', 'Target CPU ARCH', default_arch, allow_arch_map[BUILD_TARGET]))
+
+######################################################################
+# Platform(build target) specific options: SDK/NDK & toolchain
+######################################################################
+targets_support_cc = ['linux', 'arduino']
+
+if BUILD_TARGET == 'android':
+ vars.Add(PathVariable('ANDROID_NDK', 'Android NDK root directory', os.environ.get('ANDROID_NDK')))
+
+elif BUILD_TARGET in ['darwin', 'ios']:
+ vars.Add('SYS_VERSION', 'MAC OS X version / IOS version', os.environ.get('SYS_VERSION'))
+
+elif BUILD_TARGET == 'arduino':
+ vars.Add(PathVariable('ARDUINO_HOME', 'ARDUINO root directory', os.environ.get('ARDUINO_HOME')))
+
+if BUILD_TARGET in targets_support_cc:
+ # Set cross compile toolchain
+ vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
+ vars.Add(PathVariable('TC_PATH',
+ 'Toolchain path (Generally only be required for cross-compiling)',
+ os.environ.get('TC_PATH')))
+
+if BUILD_TARGET == 'android': # Android always uses GNU compiler regardless of the host
+ env = Environment(variables = vars,
+ tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
+ )
+else:
+ env = Environment(variables = vars, TARGET_ARCH = TARGET_CPU_ARCH, TARGET_OS = BUILD_TARGET)
+
+Help(vars.GenerateHelpText(env))
+
+RELEASE_BUILD = env.get('RELEASE') # Whethere is release build, True: release, False: debug
+
+tc_set_msg = '''
+************************************ Warning **********************************
+* Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default *
+* toolchain, if it isn't what you expect you should unset it, otherwise it may*
+* cause inexplicable errors. *
+*******************************************************************************
+'''
+
+if BUILD_TARGET in targets_support_cc:
+ prefix = ARGUMENTS.get('TC_PREFIX', os.environ.get('TC_PREFIX'))
+ tc_path = ARGUMENTS.get('TC_PATH', os.environ.get('TC_PATH'))
+ if prefix:
+ env.Replace(CC = prefix + 'gcc')
+ env.Replace(CXX = prefix + 'g++')
+ env.Replace(AR = prefix + 'ar')
+ env.Replace(AS = prefix + 'as')
+ env.Replace(LINK = prefix + 'ld')
+ env.Replace(RANLIB = prefix + 'ranlib')
+
+ if tc_path:
+ env.PrependENVPath('PATH', tc_path)
+ sys_root = os.path.abspath(tc_path + '/../')
+ env.AppendUnique(CFLAGS = ['--sysroot=' + sys_root])
+ env.AppendUnique(CXXFLAGS = ['--sysroot=' + sys_root])
+ env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+ if prefix or tc_path:
+ print tc_set_msg
+
+# Ensure scons be able to change its working directory
+env.SConscriptChdir(1)
+
+Export('env', 'RELEASE_BUILD', 'BUILD_TARGET', 'TARGET_CPU_ARCH',
+ 'ANDROID_NDK', 'SYS_VERSION', 'ARDUINO_HOME')
+
+# Load config of specific platform(build target)
+env.SConscript(BUILD_TARGET + '/SConscript')
+
+Return('env')
\ No newline at end of file
--- /dev/null
+##
+# This script includes android specific config (GNU GCC)
+##
+import os
+import platform
+import subprocess
+
+Import('env', 'RELEASE_BUILD', 'TARGET_CPU_ARCH', 'ANDROID_NDK')
+
+if not ANDROID_NDK:
+ print '''
+*************************************** Error *********************************
+* Android NDK path (ANDROID_NDK) isn't set, you can set enviornment variable*
+* ANDROID_NDK or add it in command line as: *
+* # scons ANDROID_NDK=<path to android NDK> ... *
+*******************************************************************************
+'''
+ Exit(1)
+
+# Overwrite suffixes and prefixes
+if env['HOST_OS'] == 'win32':
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJSUFFIX'] = '.os'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = 'lib'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = ['lib']
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+elif platform.system().lower() == 'darwin':
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+
+######################################################################
+# Set common flags
+######################################################################
+
+# Android build system default cofig
+env.AppendUnique(CPPDEFINES = ['ANDROID'])
+env.AppendUnique(CFLAGS = ['-Wa,--noexecstack'])
+env.AppendUnique(CXXFLAGS = ['-Wa,--noexecstack', '-fstack-protector'])
+env.AppendUnique(LINKFLAGS = ['-Wl,--gc-sections', '-Wl,-z,nocopyreloc'])
+
+######################################################################
+# Probe Android NDK default flags
+######################################################################
+ndk_build_cmd = ANDROID_NDK + '/ndk-build'
+if env['HOST_OS'] == 'win32':
+ if os.path.isfile(ndk_build_cmd + '.cmd'):
+ ndk_build_cmd += '.cmd'
+
+if not os.path.isfile(ndk_build_cmd):
+ print '''
+*************************************** Error *********************************
+* It seems android ndk path is not set properly, please check if "%s"
+* is the root directory of android ndk. *
+*******************************************************************************
+''' % ANDROID_NDK
+ Exit(1)
+
+ANDROID_HOME = os.environ.get('ANDROID_HOME')
+if ANDROID_HOME is not None:
+ ANDROID_HOME = os.path.abspath(ANDROID_HOME)
+
+if ANDROID_HOME is None or not os.path.exists(ANDROID_HOME):
+ print '''
+*************************************** Warning *******************************
+* Enviornment variable ANDROID_HOME is not set properly. It should be the *
+* root directory of android sdk. If you'd like build Java code, it's required.*
+*******************************************************************************
+'''
+
+# Android ndk early version doesn't support C++11. Detect the toolchain
+# and platform version to make sure the newest version is used.
+
+# Detect toolchain version
+for tc_ver in ['4.9', '4.8', '4.7', '']:
+ if os.path.exists(ANDROID_NDK + '/sources/cxx-stl/gnu-libstdc++/' + tc_ver):
+ break
+
+# Detect platform version.
+platform_ver = ''
+for pf_ver in range(0, 100): # 100 should be big enough :)
+ if os.path.exists(ANDROID_NDK + '/platforms/android-%d' % pf_ver):
+ platform_ver = "%d" % pf_ver
+
+cmd = [ndk_build_cmd]
+cmd.append('APP_ABI=' + TARGET_CPU_ARCH)
+cmd.append('APP_STL=gnustl_static')
+if RELEASE_BUILD:
+ cmd.append('APP_OPTIM=release')
+else:
+ cmd.append('APP_OPTIM=debug')
+if tc_ver != '':
+ cmd.append('NDK_TOOLCHAIN_VERSION=' + tc_ver)
+else:
+ print '''
+*************************************** Warning *******************************
+* To support C++11, the toolchain should be >= 4.7, please make sure your *
+* android NDK is at least r8e! *
+*******************************************************************************
+'''
+
+if platform_ver != '':
+ cmd.append('APP_PLATFORM=android-' + platform_ver)
+cmd.append('-n')
+
+p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
+
+for flags in p.stdout.readlines():
+ if cmp(flags[0:10], 'TC_PREFIX=') == 0: # toolchain prefix (include path)
+ prefix = flags[10:].strip()
+ env.Replace(CC = prefix + 'gcc')
+ env.Replace(CXX = prefix + 'g++')
+ env.Replace(AR = prefix + 'ar')
+ env.Replace(RANLIB = prefix + 'ranlib')
+
+ elif cmp(flags[0:7], 'CFLAGS=') == 0:
+ env.AppendUnique(CFLAGS = Split(flags[7:]))
+
+ elif cmp(flags[0:9], 'CXXFLAGS=') == 0:
+ env.AppendUnique(CXXFLAGS = Split(flags[9:]))
+
+ elif cmp(flags[0:8], 'CPPPATH=') == 0:
+ env.AppendUnique(CPPPATH = Split(flags[8:]))
+
+ elif cmp(flags[0:8], 'SYSROOT=') == 0:
+ env.AppendUnique(LINKFLAGS = ['--sysroot=' + flags[8:].strip()])
+ env.AppendUnique(LIBPATH = [flags[8:].strip() + '/usr/lib'])
+
+ elif cmp(flags[0:8], 'LDFLAGS=') == 0:
+ env.AppendUnique(LINKFLAGS = Split(flags[8:]))
+
+ elif cmp(flags[0:7], 'TC_VER=') == 0: # set gnustl library path
+ ver = flags[7:].strip()
+ env.AppendUnique(LIBPATH = [ANDROID_NDK + '/sources/cxx-stl/gnu-libstdc++/'
+ + ver + '/libs/' + TARGET_CPU_ARCH])
+
+######################################################################
+# Set release/debug flags
+######################################################################
+if RELEASE_BUILD:
+ env.AppendUnique(CFLAGS = ['-Os'])
+ env.AppendUnique(CXXFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ env.AppendUnique(LINKFLAGS = ['-s'])
+else:
+ env.AppendUnique(CFLAGS = ['-g'])
+ env.AppendUnique(CXXFLAGS = ['-g'])
\ No newline at end of file
--- /dev/null
+include $(CLEAR_VARS)
+LOCAL_MODULE := flags_probe
+include $(BUILD_SHARE_LIBRARY)
+
+$(info TC_PREFIX=$(TOOLCHAIN_PREFIX))
+$(info CFLAGS=$(TARGET_CFLAGS))
+$(info CXXFLAGS=$(TARGET_CXXFLAGS) $(TARGET_NO_EXECUTE_CFLAGS))
+$(info CPPPATH=$(TARGET_C_INCLUDES) $(__ndk_modules.$(APP_STL).EXPORT_C_INCLUDES))
+$(info SYSROOT=$(SYSROOT_LINK))
+$(info LDFLAGS=$(TARGET_LDFLAGS) $(TARGET_NO_EXECUTE_LDFLAGS) $(TARGET_NO_UNDEFINED_LDFLAGS) $(TARGET_RELRO_LDFLAGS))
+$(info TC_VER=$(TOOLCHAIN_VERSION))
--- /dev/null
+##
+# This script includes arduino specific config
+##
+import os
+import platform
+
+Import('env', 'RELEASE_BUILD', 'TARGET_CPU_ARCH', 'ARDUINO_HOME')
+
+if not ARDUINO_HOME:
+ print '''
+************************************* Error ***********************************
+* Arduino root directory (ARDUINO_HOME) isn't set, you can set enviornment *
+* variable ARDUINO_HOME or add it in command line as: *
+* # scons ARDUINO_HOME=<path to arduino root directory> ... *
+*******************************************************************************
+'''
+ Exit(1)
+
+# Overwrite suffixes and prefixes
+if env['HOST_OS'] == 'win32':
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJSUFFIX'] = '.os'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = 'lib'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = ['lib']
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+elif platform.system().lower() == 'darwin':
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+
+# Set toolchain
+def find_toolchain(dir, tc):
+ for root, dirs, files in os.walk(dir, True, None, False):
+ for f in files:
+ lf = f.lower()
+ if lf == tc:
+ return root
+ return None
+
+if TARGET_CPU_ARCH == 'arm':
+ prefix = 'arm-none-eabi-'
+else:
+ prefix = 'avr-'
+
+tc_path = find_toolchain(ARDUINO_HOME + '/hardware/tools/', prefix + 'g++')
+if not tc_path:
+ print '''
+************************************* Error ***********************************
+* Arduino toolchain isn't detected. Please specify the toolchain prefix and *
+* path, you can do it by setting enviornment variable TC_PREFIX and TC_PATH or*
+* add it in command line as: *
+* # scons TC_PREFIX=<prefix> TC_PATH=<path to toolchain> ... *
+* e.g. scons TC_PREFIX=avr- TC_PATH=/opt/arduino-1.5.7/hardware/tools/avr/bin * *
+* Note: TC_PREFIX shouldn't include path *
+*******************************************************************************
+'''
+ Exit(1)
+
+env.PrependENVPath('PATH', tc_path)
+env.Replace(CC = prefix + 'gcc')
+env.Replace(CXX = prefix + 'g++')
+env.Replace(AR = prefix + 'ar')
+env.Replace(AS = prefix + 'as')
+env.Replace(LINK = prefix + 'ld')
+env.Replace(RANLIB = prefix + 'ranlib')
+
+sys_root = os.path.abspath(os.path.join(tc_path, '..'))
+env.AppendUnique(CFLAGS = ['--sysroot=' + sys_root])
+env.AppendUnique(CXXFLAGS = ['--sysroot=' + sys_root])
+env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+# Debug/release relative flags
+if RELEASE_BUILD:
+ env.AppendUnique(CFLAGS = ['-Os'])
+ env.AppendUnique(CXXFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ env.AppendUnique(LINKFLAGS = ['-s'])
+else:
+ env.AppendUnique(CFLAGS = ['-g'])
+ env.AppendUnique(CXXFLAGS = ['-g'])
\ No newline at end of file
--- /dev/null
+##
+# This script set darwin specific flags (GNU GCC)
+#
+##
+import platform
+
+Import('env', 'RELEASE_BUILD', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'SYS_VERSION')
+
+if SYS_VERSION is None:
+ print '''
+*********************************** Error *************************************
+* MAC OSX/IOS version isn't set, please set it in command line as : *
+* # scons SYS_VERSION=<version> ... *
+* To get the version, please see: *
+* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ *
+* /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ *
+*******************************************************************************
+'''
+ Exit(1)
+
+# Set release/debug flags
+if RELEASE_BUILD:
+ env.AppendUnique(CFLAGS = ['-Os'])
+ env.AppendUnique(CXXFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+else:
+ env.AppendUnique(CFLAGS = ['-g'])
+ env.AppendUnique(CXXFLAGS = ['-g'])
+
+if BUILD_TARGET == 'darwin':
+ SYS_ROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + SYS_VERSION + '.sdk/'
+else:
+ if TARGET_CPU_ARCH in ['i386', 'x86_64']:
+ SYS_ROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + SYS_VERSION + '.sdk/'
+ else:
+ SYS_ROOT = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + SYS_VERSION + '.sdk/'
+
+# Set arch flags
+env.AppendUnique(CXXFLAGS = ['-arch', TARGET_CPU_ARCH, '-isysroot', SYS_ROOT])
+env.AppendUnique(CCFLAGS = ['-arch', TARGET_CPU_ARCH, '-isysroot', SYS_ROOT])
+env.AppendUnique(LINKFLAGS = ['-arch', TARGET_CPU_ARCH, '-isysroot', SYS_ROOT])
+
+if BUILD_TARGET == 'darwin':
+ flag = '-mmacosx-version-min=' + SYS_VERSION
+ env.AppendUnique(CXXFLAGS = [flag])
+ env.AppendUnique(CCFLAGS = [flag])
+ env.AppendUnique(LINKFLAGS = [flag])
\ No newline at end of file
--- /dev/null
+##
+# This script set ios specific flags (GNU GCC)
+#
+##
+Import('env', 'TARGET_CPU_ARCH', 'SYS_VERSION')
+
+# setting of IOS is almost the same as Darwin(MAC OSX)
+env.SConscript('../darwin/SConscript')
+
+if TARGET_CPU_ARCH in ['i386', 'x86_64']: #Simulator
+ flag = '-mios-simulator-version-min=' + SYS_VERSION
+ env.AppendUnique(CXXFLAGS = [flag])
+ env.AppendUnique(CCFLAGS = [flag])
+ env.AppendUnique(LINKFLAGS = [flag])
+else:
+ flag = '-miphoneos-version-min=' + SYS_VERSION
+ env.AppendUnique(CXXFLAGS = [flag])
+ env.AppendUnique(CCFLAGS = [flag])
+ env.AppendUnique(LINKFLAGS = [flag])
\ No newline at end of file
--- /dev/null
+##
+# This script set linux specific flags (GNU GCC)
+#
+##
+Import('env', 'RELEASE_BUILD', 'TARGET_CPU_ARCH')
+
+# Set release/debug flags
+if RELEASE_BUILD:
+ env.AppendUnique(CFLAGS = ['-Os'])
+ env.AppendUnique(CXXFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ env.AppendUnique(LINKFLAGS = ['-s'])
+else:
+ env.AppendUnique(CFLAGS = ['-g'])
+ env.AppendUnique(CXXFLAGS = ['-g'])
+
+# Set arch flags
+if TARGET_CPU_ARCH in ['x86']:
+ env.AppendUnique(CFLAGS = ['-m32'])
+ env.AppendUnique(CXXFLAGS = ['-m32'])
+ env.AppendUnique(LINKFLAGS = ['-m32'])
+elif TARGET_CPU_ARCH in ['x86_64']:
+ env.AppendUnique(CXXFLAGS = ['-m64'])
+ env.AppendUnique(CFLAGS = ['-m64'])
+ env.AppendUnique(LINKFLAGS = ['-m64'])
+elif TARGET_CPU_ARCH.find('v7a-hard') > 0:
+ env.AppendUnique(CPPFLAGS = ['-march=armv7-a'])
+ env.AppendUnique(CPPFLAGS = ['-mfloat-abi=hard'])
+ env.AppendUnique(CFLAGS = ['-mfloat-abi=hard'])
+ env.AppendUnique(CXXFLAGS = ['-mfloat-abi=hard'])
+ env.AppendUnique(LINKFLAGS = ['-mfloat-abi=hard'])
+elif TARGET_CPU_ARCH.find('v7a') > 0:
+ env.AppendUnique(CPPFLAGS = ['-march=armv7-a'])
+elif TARGET_CPU_ARCH.find('arm64') > 0:
+ env.AppendUnique(CPPFLAGS = ['-march=armv8-a'])
+else:
+ env.AppendUnique(CPPFLAGS = ['-march=armv5te'])
\ No newline at end of file
--- /dev/null
+##
+# This script includes windows specific config (MSVS/MSVC)
+##
+Import('env', 'RELEASE_BUILD', 'TARGET_CPU_ARCH')
+
+# Set common flags
+env.AppendUnique(CXXFLAGS=['/wd4244', '/wd4267','/wd4345', '/wd4355', '/wd4800', '/wd4996'])
+env.AppendUnique(CFLAGS=['/EHsc'])
+env.AppendUnique(CXXFLAGS=['/EHsc'])
+
+# Set release/debug flags
+if RELEASE_BUILD:
+ env.AppendUnique(CFLAGS = ['/MD', '/O2', '/GF'])
+ env.AppendUnique(CXXFLAGS = ['/MD', '/O2', '/GF'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+else:
+ env.AppendUnique(CFLAGS = ['/MDd', '/Od', '/ZI', '/GZ', '/Gm'])
+ env.AppendUnique(CXXFLAGS = ['/MDd', '/Od', '/ZI', '/GZ', '/Gm'])
+ env.AppendUnique(CPPDEFINES = ['_DEBUG'])
+ env.AppendUnique(LINKFLAGS = ['/debug'])
\ No newline at end of file
--- /dev/null
+##
+# liboctbstack (static library) build script
+##
+
+Import('env', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'RELEASE_BUILD', 'BUILD_DIR', 'SRC_TOP_DIR')
+
+liboctbstack_env = env.Clone()
+
+# Add third party libraries
+SConscript(SRC_TOP_DIR + '/third_party_libs.scons')
+Import('OIC_UTILS')
+
+# As in the source code, it includes arduino Time library (C++)
+# It requires compile the .c with g++
+if BUILD_TARGET == 'arduino':
+ liboctbstack_env.Replace(CC = env.get('CXX'))
+ liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+
+######################################################################
+# Build flags
+######################################################################
+liboctbstack_env.PrependUnique(CPPPATH = [
+ OIC_UTILS + '/tb/cJSON/',
+ 'ocsocket/include',
+ 'logger/include',
+ 'ocrandom/include',
+ 'ocmalloc/include',
+ 'libcoap',
+ 'occoap/include',
+ 'stack/include',
+ 'stack/include/internal',
+ '../oc_logger/include'
+ ])
+
+if BUILD_TARGET not in ['arduino', 'windows', 'winrt']:
+ liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
+ liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
+
+if BUILD_TARGET not in ['windows', 'winrt']:
+ liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
+
+if not RELEASE_BUILD:
+ liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+OCTBSTACK_SRC = 'stack/src/'
+liboctbstack_src = [
+ 'occoap/src/occoap.c',
+ 'occoap/src/occoaphelper.c',
+ OCTBSTACK_SRC + 'ocstack.c',
+ OCTBSTACK_SRC + 'occlientcb.c',
+ OCTBSTACK_SRC + 'ocresource.c',
+ OCTBSTACK_SRC + 'ocobserve.c',
+ OCTBSTACK_SRC + 'occollection.c',
+ ]
+
+if RELEASE_BUILD:
+ prefix = TARGET_CPU_ARCH + '-'
+else:
+ prefix = TARGET_CPU_ARCH + 'd-'
+cjson_obj = liboctbstack_env.Object(OIC_UTILS + '/tb/cJSON/cJSON.c', OBJPREFIX=prefix)
+liboctbstack_src.append(cjson_obj)
+
+liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
+i_lctbs = liboctbstack_env.Install(BUILD_DIR, liboctbstack)
+Alias('liboctbstack', i_lctbs)
+env.AppendUnique(TS = ['liboctbstack'])
--- /dev/null
+##
+# libcoap (static library) build script
+##
+
+Import('env', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'RELEASE_BUILD', 'BUILD_DIR', 'ARDUINO_HOME')
+
+libcoap_env = env.Clone()
+
+# As in the source code, it includes arduino Time library (C++)
+# It requires compile the .c with g++
+if BUILD_TARGET == 'arduino':
+ libcoap_env.Replace(CC = env.get('CXX'))
+ libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+
+######################################################################
+# Build flags
+######################################################################
+libcoap_env.PrependUnique(CPPPATH = [
+ '../ocsocket/include',
+ '../ocmalloc/include',
+ '../logger/include',
+ '../ocrandom/include',
+ '../stack',
+ '../../oc_logger/include'
+ ])
+
+if BUILD_TARGET not in ['arduino', 'windows', 'winrt']:
+ libcoap_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
+ libcoap_env.AppendUnique(CFLAGS = ['-std=gnu99'])
+
+if BUILD_TARGET not in ['windows', 'winrt']:
+ libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
+ '-fdata-sections', '-fno-exceptions'])
+
+if not RELEASE_BUILD:
+ libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+######################################################################
+# Source files and Target(s)
+######################################################################
+libcoap_src = [
+ 'pdu.c',
+ 'net.c',
+ 'debug.c',
+ 'encode.c',
+ 'uri.c',
+ 'coap_list.c',
+ 'resource.c',
+ 'hashkey.c',
+ 'str.c',
+ 'option.c',
+ 'async.c',
+ 'subscribe.c',
+ 'block.c',
+ '../logger/src/logger.c',
+ '../ocrandom/src/ocrandom.c',
+ '../ocmalloc/src/ocmalloc.c',
+ '../../oc_logger/c/oc_logger.c',
+ '../../oc_logger/c/oc_console_logger.c'
+ ]
+
+if BUILD_TARGET == 'arduino':
+ if env.get('NET') == 'Wifi':
+ libcoap_src.append(['../ocsocket/src/ocsocket_arduino_wifi.cpp'])
+ else:
+ libcoap_src.append(['../ocsocket/src/ocsocket_arduino.cpp'])
+
+ if RELEASE_BUILD:
+ prefix = TARGET_CPU_ARCH + '-'
+ else:
+ prefix = TARGET_CPU_ARCH + 'd-'
+ time_obj = libcoap_env.Object(ARDUINO_HOME + '/libraries/Time/Time.cpp', OBJPREFIX=prefix)
+ libcoap_src.append(time_obj)
+else:
+ libcoap_src.append(['../ocsocket/src/ocsocket.c'])
+
+libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap')
+i_lc = libcoap_env.Install(BUILD_DIR, libcoap)
+Alias('libcoap', i_lc)
+env.AppendUnique(TS = ['libcoap'])
\ No newline at end of file
--- /dev/null
+##
+# Examples build script
+##
+Import('env', 'RELEASE_BUILD', 'BUILD_TARGET', 'BUILD_DIR', 'SRC_TOP_DIR')
+# Add third party libraries
+SConscript(SRC_TOP_DIR + '/third_party_libs.scons')
+examples_env = env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+examples_env.AppendUnique(CPPPATH = [
+ '../include/',
+ '../csdk/stack/include',
+ '../csdk/ocsocket/include',
+ '../csdk/ocrandom/include',
+ '../csdk/logger/include',
+ '../csdk/libcoap',
+ '../oc_logger/include'
+ ])
+
+if BUILD_TARGET not in ['windows', 'winrt']:
+ examples_env.AppendUnique(CXXFLAGS = ['-std=c++11', '-Wall'])
+
+examples_env.AppendUnique(LIBPATH = [BUILD_DIR])
+examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'oc_logger'])
+
+if BUILD_TARGET == 'android':
+ examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ examples_env.AppendUnique(LIBS = ['gnustl_static'])
+ examples_env.AppendUnique(LINKFLAGS = ['-static'])
+ examples_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
+
+ if not RELEASE_BUILD:
+ examples_env.AppendUnique(LIBS = ['log'])
+######################################################################
+# Source files and Targets
+######################################################################
+simpleserver = examples_env.Program('simpleserver', 'simpleserver.cpp')
+simpleclient = examples_env.Program('simpleclient', 'simpleclient.cpp')
+presenceserver = examples_env.Program('presenceserver', 'presenceserver.cpp')
+presenceclient = examples_env.Program('presenceclient', 'presenceclient.cpp')
+simpleclientserver = examples_env.Program('simpleclientserver', 'simpleclientserver.cpp')
+roomserver = examples_env.Program('roomserver', 'roomserver.cpp')
+roomclient = examples_env.Program('roomclient', 'roomclient.cpp')
+
+Alias("examples", [simpleserver, simpleclient, presenceserver, presenceclient,
+ simpleclientserver, roomserver, roomclient])
+env.AppendUnique(TS = ['examples'])
+
+if BUILD_TARGET not in ['ios']:
+ SConscript(BUILD_DIR + 'examples/ocicuc/SConscript')
--- /dev/null
+##
+# Examples build script
+##
+Import('env', 'RELEASE_BUILD', 'BUILD_TARGET', 'BUILD_DIR', 'SRC_TOP_DIR')
+# Add third party libraries
+SConscript(SRC_TOP_DIR + '/third_party_libs.scons')
+ocicuc_env = env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+ocicuc_env.AppendUnique(CPPPATH = [
+ '../../include/',
+ '../../csdk/stack/include',
+ '../../csdk/ocsocket/include',
+ '../../csdk/ocrandom/include',
+ '../../csdk/logger/include',
+ '../../oc_logger/include'
+ ])
+
+ocicuc_env.AppendUnique(LIBPATH = [BUILD_DIR])
+ocicuc_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'oc_logger'])
+
+if BUILD_TARGET not in ['windows', 'winrt']:
+ ocicuc_env.AppendUnique(CXXFLAGS = ['-std=c++11'])
+
+if BUILD_TARGET == 'android':
+ ocicuc_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ ocicuc_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
+ ocicuc_env.AppendUnique(LIBS = ['boost_program_options-gcc-mt-1_49', 'boost_thread-gcc-mt-1_49', 'gnustl_static'])
+ ocicuc_env.AppendUnique(LINKFLAGS = ['-static'])
+
+ if not RELEASE_BUILD:
+ ocicuc_env.AppendUnique(LIBS = ['log'])
+
+if BUILD_TARGET == 'darwin':
+ ocicuc_env.AppendUnique(LIBS = ['boost_program_options'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+client = ocicuc_env.Program('client', ['client.cpp', 'driver.cpp', 'utility.cpp'])
+server = ocicuc_env.Program('server', ['server.cpp', 'driver.cpp', 'utility.cpp', 'light_resource.cpp'])
+monoprocess = ocicuc_env.Program('monoprocess',
+ ['monoprocess.cpp', 'driver.cpp', 'utility.cpp', 'light_resource.cpp'])
+
+Alias("examples_ocicuc", [client, server, monoprocess])
+env.AppendUnique(TS = ['examples_ocicuc'])
--- /dev/null
+##
+# liboctbstack (static library) build script
+##
+
+Import('env', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'BUILD_DIR', 'SRC_TOP_DIR')
+
+# Add third party libraries
+SConscript(SRC_TOP_DIR + '/third_party_libs.scons')
+
+liboc_logger_env = env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+liboc_logger_env.PrependUnique(CPPPATH = ['include'])
+
+if BUILD_TARGET == 'android':
+ liboc_logger_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ liboc_logger_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
+
+if BUILD_TARGET not in ['arduino', 'windows', 'winrt']:
+ liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99'])
+ liboc_logger_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+liboc_logger_core = liboc_logger_env.StaticLibrary('oc_logger_core', 'c/oc_logger.c', OBJPREFIX='core')
+liboc_logger = liboc_logger_env.StaticLibrary('oc_logger',
+ ['c/oc_logger.c', 'c/oc_console_logger.c', 'cpp/oc_ostream_logger.cpp'])
+i_loggers = liboc_logger_env.Install(BUILD_DIR, [liboc_logger_core, liboc_logger])
+Alias('liboc_logger', i_loggers)
+env.AppendUnique(TS = ['liboc_logger'])
\ No newline at end of file
--- /dev/null
+##
+# OCLib (static library) build script
+##
+Import('env', 'BUILD_TARGET', 'BUILD_DIR', 'SRC_TOP_DIR')
+
+# Add third party libraries
+SConscript(SRC_TOP_DIR + '/third_party_libs.scons')
+
+oclib_env = env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+oclib_env.AppendUnique(CPPPATH = [
+ '../include/',
+ '../csdk/stack/include',
+ '../csdk/ocsocket/include',
+ '../csdk/ocrandom/include',
+ '../csdk/logger/include',
+ '../csdk/libcoap',
+ '../oc_logger/include'
+ ])
+
+if BUILD_TARGET not in ['windows', 'winrt']:
+ oclib_env.AppendUnique(CXXFLAGS = ['-std=c++11', '-Wall'])
+
+if BUILD_TARGET == 'android':
+ oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ oclib_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+oclib_src = [
+ 'OCPlatform.cpp',
+ 'OCResource.cpp',
+ 'OCUtilities.cpp',
+ 'OCException.cpp',
+ 'InProcServerWrapper.cpp',
+ 'InProcClientWrapper.cpp'
+ ]
+
+oclib = oclib_env.StaticLibrary('oc', oclib_src)
+i_ocl = oclib_env.Install(BUILD_DIR, oclib)
+Alias('liboc', i_ocl)
+env.AppendUnique(TS = ['liboc'])
\ No newline at end of file
--- /dev/null
+######################################################################
+# This script manages third party libraries
+#
+#Note: The paths must keep consistent with oic-utilities
+######################################################################
+import os
+
+Import('env', 'BUILD_TARGET', 'TARGET_CPU_ARCH', 'SRC_TOP_DIR')
+
+# Add 'OIC_UTILS' build option for user to set oic-utilities project path
+default_dir = os.path.abspath(SRC_TOP_DIR + '/../oic-utilities')
+OIC_UTILS = ARGUMENTS.get('OIC_UTILS', default_dir)
+if not os.path.exists(OIC_UTILS):
+ print '''
+*********************************** Error: ************************************
+* oic-utilities project directory(OIC_UTILS) isn't set properly, please set *
+* enviornment variable OIC_UTILS or set it in command line: *
+* # scons OIC_UTILS=<path to oic-utilities> ... *
+*******************************************************************************
+'''
+ Exit(1)
+
+if env.get('OIC_UTILS') is None:
+ vars = Variables()
+ vars.Add(PathVariable('OIC_UTILS', 'oic-utilities project path', OIC_UTILS))
+ vars.Update(env)
+ Help(vars.GenerateHelpText(env))
+ Export('OIC_UTILS')
+
+ ######################################################################
+ # Check dependent packages (Linux)
+ ######################################################################
+ if BUILD_TARGET == 'linux':
+ # Delete the temp files of configuration
+ if env.GetOption('clean'):
+ if os.path.exists(SRC_TOP_DIR + 'config.log'):
+ Execute(Delete(SRC_TOP_DIR + 'config.log'))
+ Execute(Delete(SRC_TOP_DIR + '.sconsign.dblite'))
+ Execute(Delete(SRC_TOP_DIR + '.sconf_temp'))
+ elif not env.GetOption('help'):
+ conf = Configure(env)
+
+ if not conf.CheckLib('boost_program_options'):
+ print 'Did not find boost_program_options, exiting!'
+ Exit(1)
+
+ conf.Finish()
+
+ ######################################################################
+ # The 'include' path of third party libraries
+ ######################################################################
+
+ if BUILD_TARGET == 'android':
+ env.AppendUnique(CPPPATH = [OIC_UTILS + '/android/boost/include'])
+
+ ######################################################################
+ # The path of third party libraries binary
+ ######################################################################
+ if BUILD_TARGET == 'android':
+ arch = TARGET_CPU_ARCH
+ if arch == 'armeabi-v7a-hard':
+ arch = 'armeabi-v7a'
+
+ if arch not in ['x86', 'armeabi', 'armeabi-v7a']:
+ print '''
+*********************************** Warning ***********************************
+* current only x86, armeabi, armeabi-v7a libraries are offered! *
+*******************************************************************************
+'''
+ else:
+ env.AppendUnique(LIBPATH = [OIC_UTILS + '/android/boost/libs/' + arch])
+
+ elif BUILD_TARGET == 'ios':
+ env.AppendUnique(FRAMEWORKPATH = [OIC_UTILS + '/ios/frameworks/'])
+ env.AppendUnique(FRAMEWORKS = ['boost'])
+ elif BUILD_TARGET == 'darwin':
+ env.AppendUnique(CPPPATH = ['/usr/local/include'])
+ env.AppendUnique(LIBPATH = ['/usr/local/lib'])
\ No newline at end of file