Commit bff0ed25 authored by Sandipan Patra's avatar Sandipan Patra Committed by Madan Lanka

[ENROLLEE] Tizen enrollee sample application build using scons command

[CODING STANDARD] Enrollee files rename as per iotivity coding standard

Change-Id: Ib873ede13d6b1539e812e535676c2c33d34b9481
Signed-off-by: default avatarSandipan Patra <sandipan.p@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4967Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarSooho Chang <sooho.chang@samsung.com>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent ff830bb8
......@@ -44,8 +44,7 @@ cp ./SConstruct ./tmp
# copy dependency RPMs and conf files for tizen build
cp ./tools/tizen/*.rpm ./tmp
cp ./tools/tizen/.gbs.conf ./tmp
cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
cd $sourcedir/tmp
......@@ -72,28 +71,6 @@ else
exit 1
fi
cd service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
echo `pwd`
if [ ! -d .git ]; then
git init ./
git config user.email "you@example.com"
git config user.name "Your Name"
git add ./
git commit -m "Initial commit"
fi
echo "Calling sample gbs build command"
gbscommand="gbs build -A armv7l -B ~/GBS-ROOT --include-all --repository ./ --define 'TARGET_TRANSPORT IP' --define 'SECURED 0' --define 'RELEASE 0' --define 'LOGGING True' --define 'ROUTING EP' --define 'TARGET_ENROLLEE tizen
'"
echo $gbscommand
if eval $gbscommand; then
echo "Sample build is successful"
else
echo "Sample build is failed. "
exit 1
fi
cd $sourcedir
rm -rf $sourcedir/tmp
......
......@@ -142,8 +142,8 @@ if target_os == 'arduino':
es_sdk_static = easy_setup_env.StaticLibrary('ESSDKLibrary',
['sdk/enrollee/src/easysetup.cpp',
'sdk/enrollee/src/onboarding.cpp',
'sdk/enrollee/src/resourceHandler.cpp',
'sdk/enrollee/arduino/wifi/networkHandler.cpp'])
'sdk/enrollee/src/resourcehandler.cpp',
'sdk/enrollee/arduino/wifi/networkhandler.cpp'])
easy_setup_env.InstallTarget(es_sdk_static, 'libESSDK')
if target_os == 'android':
......@@ -158,8 +158,8 @@ if target_os == 'tizen':
['sdk/enrollee/src/easysetup.cpp',
'sdk/enrollee/src/onboarding.cpp',
'sdk/enrollee/src/softap.cpp',
'sdk/enrollee/src/resourceHandler.cpp',
'sdk/enrollee/tizen/wifi/networkHandler.cpp',
'sdk/enrollee/src/resourcehandler.cpp',
'sdk/enrollee/tizen/wifi/networkhandler.cpp',
'sdk/enrollee/tizen/wifi/softapnative.cpp'])
easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
......
......@@ -42,7 +42,7 @@ enrollee_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESWIFI'])
enrollee_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
enrollee_env.PrependUnique(LIBS = ['octbstack','ocsrm','connectivity_abstraction','coap', 'ESSDKLibrary'])
enrollee = enrollee_env.Program('enrollee', 'enrollee_wifi.cpp')
enrollee = enrollee_env.Program('enrollee', 'enrolleewifi.cpp')
env.CreateBin('enrollee')
i_enrollee = enrollee_env.Install(env.get('BUILD_DIR'), enrollee)
......
......@@ -181,7 +181,7 @@ void StartEasySetup()
g_isInitialized = true;
OC_LOG_V(ERROR, TAG, "OnBoarding succeeded. Successfully connected to ssid : %s",ssid);
OC_LOG_V(ERROR, TAG, "OnBoarding succeded. Successfully connected to ssid : %s",ssid);
}
void StartProvisioning()
......
##
# This script includes generic build options:
# release/debug, target os, target arch, cross toolchain, build environment etc
##
import os
import platform
# Map of host os and allowed target os (host: allowed target os)
host_target_map = {
'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
'windows': ['windows', 'winrt', 'android', 'arduino'],
'darwin': ['darwin', 'ios', 'android', 'arduino'],
}
# Map of os and allowed archs (os: allowed archs)
os_arch_map = {
'linux': ['x86', 'x86_64', 'arm', 'arm64'],
'tizen': ['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'],
'yocto': ['i586', 'x86_64', 'arm', 'powerpc', 'powerpc64', 'mips', 'mipsel'],
}
host = platform.system().lower()
if not host_target_map.has_key(host):
print "\nError: Current system (%s) isn't supported\n" % host
Exit(1)
######################################################################
# Get build options (the optins from command line)
######################################################################
target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
if target_os not in host_target_map[host]:
print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
Exit(1)
default_arch = platform.machine()
if default_arch not in os_arch_map[target_os]:
default_arch = os_arch_map[target_os][0].lower()
target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
# True if binary needs to be installed on board. (Might need root permissions)
# set to 'no', 'false' or 0 for only compilation
require_upload = ARGUMENTS.get('UPLOAD', True)
# Get the device name
device_name = ARGUMENTS.get('DEVICE_NAME', "OIC-DEVICE")
######################################################################
# Common build options (release, target os, target arch)
######################################################################
help_vars = Variables()
help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
help_vars.Add(BoolVariable('LOGGING', 'Enable stack logging', False))
help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'BT', 'BLE', 'IP', 'TCP']))
help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_upload))
help_vars.Add(EnumVariable('ROUTING', 'Enable routing', 'EP', allowed_values=('GW', 'EP')))
help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
help_vars.AddVariables(('DEVICE_NAME', 'Network display name for device', 'OIC-DEVICE', None, None),)
AddOption('--prefix',
dest='prefix',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='installation prefix')
######################################################################
# Platform(build target) specific options: SDK/NDK & toolchain
######################################################################
targets_support_cc = ['linux', 'arduino', 'tizen']
if target_os in targets_support_cc:
# Set cross compile toolchain
help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
help_vars.Add(PathVariable('TC_PATH',
'Toolchain path (Generally only be required for cross-compiling)',
os.environ.get('TC_PATH')))
if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
env = Environment(variables = help_vars,
tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
)
else:
env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os, PREFIX = GetOption('prefix'))
Help(help_vars.GenerateHelpText(env))
# Set device name to __OIC_DEVICE_NAME__
env.AppendUnique(CPPDEFINES = ['-D__OIC_DEVICE_NAME__=' + "\'\"" + device_name + "\"\'"])
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 target_os in targets_support_cc:
prefix = env.get('TC_PREFIX')
tc_path = env.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(CCFLAGS = ['--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)
# Set the source directory and build directory
# Source directory: 'dir'
# Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
#
# You can get the directory as following:
# env.get('SRC_DIR')
# env.get('BUILD_DIR')
def __set_dir(env, dir):
if not os.path.exists(dir + '/SConstruct'):
print '''
*************************************** Error *********************************
* The directory(%s) seems isn't a source code directory, no SConstruct file is
* found. *
*******************************************************************************
''' % dir
Exit(1)
if env.get('RELEASE'):
build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
else:
build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
env.VariantDir(build_dir, dir, duplicate=0)
env.Replace(BUILD_DIR = build_dir)
env.Replace(SRC_DIR = dir)
def __src_to_obj(env, src, home = ''):
obj = env.get('BUILD_DIR') + src.replace(home, '')
if env.get('OBJSUFFIX'):
obj += env.get('OBJSUFFIX')
return env.Object(obj, src)
def __install(ienv, targets, name):
i_n = ienv.Install(env.get('BUILD_DIR'), targets)
Alias(name, i_n)
env.AppendUnique(TS = [name])
def __installlib(ienv, targets, name):
user_prefix = env.get('PREFIX')
if user_prefix:
i_n = ienv.Install(user_prefix + '/lib', targets)
else:
i_n = ienv.Install(env.get('BUILD_DIR'), targets)
ienv.Alias("install", i_n)
def __installbin(ienv, targets, name):
user_prefix = env.get('PREFIX')
if user_prefix:
i_n = ienv.Install(user_prefix + '/bin', targets)
else:
i_n = ienv.Install(env.get('BUILD_DIR'), targets)
ienv.Alias("install", i_n)
def __append_target(ienv, target):
env.AppendUnique(TS = [target])
def __print_targets(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]
===============================================================================
''')
env.AddMethod(__set_dir, 'SetDir')
env.AddMethod(__print_targets, 'PrintTargets')
env.AddMethod(__src_to_obj, 'SrcToObj')
env.AddMethod(__append_target, 'AppendTarget')
env.AddMethod(__install, 'InstallTarget')
env.AddMethod(__installlib, 'UserInstallTargetLib')
env.AddMethod(__installbin, 'UserInstallTargetBin')
env.SetDir(env.GetLaunchDir())
env['ROOT_DIR']=env.GetLaunchDir()+'/..'
Export('env')
# Delete the temp files of configuration
if env.GetOption('clean'):
dir = env.get('SRC_DIR')
if os.path.exists(dir + '/config.log'):
Execute(Delete(dir + '/config.log'))
Execute(Delete(dir + '/.sconsign.dblite'))
Execute(Delete(dir + '/.sconf_temp'))
Return('env')
##
# override with `make BUILD=debug`
# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
# default to release build
# default to build for linux
BUILD := debug
PLATFORM := tizen
OBJ_DIR := ./bin
ROOT_DIR := .
VERSION_MAJOR := 0
VERSION_MINOR := 1
VERSION_PATCH := 0
ADAPTER_MACRO := -DWIFI_ADAPTER
$(info *******************tizen Build !!******************)
CC=gcc
LIBCOAP=./lib/libcoap-4.1.1/
LIBCOAP_OBJ_DIR=./lib/libcoap-4.1.1/obj
TINYDTLS=./lib/extlibs/tinydtls
TINYDTLS_OBJ_DIR=./lib/extlibs/tinydtls/obj
# TODO : Currently Hardcoded WIFI_ADAPTER. Change it to generic
CFLAGS.debug = -DWITH_POSIX -D__TIZEN__ -Wall -std=c99 -DSLP_SDK_LOG -g -D_GNU_SOURCE -DTIZEN_DEBUG_ENABLE -DTB_LOG $(ADAPTER_MACRO)
CFLAGS.release = -DWITH_POSIX -D__TIZEN__ -Wall -std=c99 -DSLP_SDK_LOG -D_GNU_SOURCE -DTIZEN_DEBUG_ENABLE -DTB_LOG $(ADAPTER_MACRO)
COMPILEFLAG = `pkg-config --cflags --libs capi-network-wifi dlog capi-network-bluetooth glib-2.0`
# Include files will be copied into a single folder on gbsbuild.
# NO NEED to mention the path explicitly.
CA_INC = $(ROOT_DIR)/
DTLS_INC = $(ROOT_DIR)/dtls/
INC_DIRS := -I$(CA_INC)
INC_DIRS += -I$(DTLS_INC)
SRC = $(wildcard *.c)
OBJECTS = $(patsubst %.c, %.o, $(SRC))
#Currently compiling libcoap objects. If it's provided by external party.
#Then don't compile, Instead directly extract objects and create liboicinterface.a
all: $(OBJECTS)
$(MAKE) -C $(LIBCOAP) clean
$(MAKE) -C $(LIBCOAP)
-mkdir $(LIBCOAP_OBJ_DIR)
@cd $(LIBCOAP_OBJ_DIR) && $(AR) -x ../libcoap.a
ar rcs liboicinterface.a $(OBJECTS) $(LIBCOAP_OBJ_DIR)/*.o
%.o : %.c
$(CC) -c $(CFLAGS.$(BUILD)) $(COMPILEFLAG) $(INC_DIRS) $< -o $@
pack:
#$(CC) $(CFLAGS) $(COMPILEFLAG) WiFiInterface.c bt_interface.c tc_interface.c sample_main.c -o sample /usr/lib/liboctbstack.a -lm -pthread
$(info **************************************TEST***************************)
install:
#cp -rf sample ./usr/apps/com.samsung.oicca/bin/sample
clean:
rm -rf *.o sample
rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *-
rm -rf $(OBJ_DIR)
rm -rf $(LIBCOAP_OBJ_DIR)
##
# Enrollee sample build script
##
SConscript('./service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/SConscript')
Import('env')
target_os = env.get('TARGET_OS')
transport = env.get('TARGET_TRANSPORT')
buildsample = env.get('BUILD_SAMPLE')
release_mode = env.get('RELEASE')
secured = env.get('SECURED')
logging = env.get('LOGGING')
routing = env.get('ROUTING')
print "Given Transport is %s" % transport
print "Given OS is %s" % target_os
if target_os == 'tizen':
command = "sh service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh %s %s %s %s %s %s" % (transport, secured, buildsample, routing, release_mode, logging)
print "Created Command is %s" % command
gbs_script = env.Command('gbs_build', None, command)
AlwaysBuild ('gbs_script')
\ No newline at end of file
##
# The main build script
#
##
# Load common build config
# Load common build config
SConscript('SConscript')
Import('env')
target_os = env.get('TARGET_OS')
transport = env.get('TARGET_TRANSPORT')
print "Given Transport is %s" % transport
print "Given OS is %s" % target_os
print "Secured %s" % env.get('SECURED')
if target_os == 'tizen':
SConscript('scons/SConscript')
else:
print "Given platform is not supported"
#!/bin/sh
cur_dir="./service/easy-setup"
spec=`ls ./service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/packaging/*.spec`
version=`rpm --query --queryformat '%{version}\n' --specfile $spec`
name=`echo $name|cut -d" " -f 1`
version=`echo $version|cut -d" " -f 1`
name=iotivity
rm -rf $name-$version
builddir=`pwd`
sourcedir=`pwd`
echo `pwd`
rm -rf ./tmp
# Create directory structure for GBS Build
mkdir ./tmp
mkdir ./tmp/con/
mkdir ./tmp/extlibs/
mkdir ./tmp/packaging
cp -R ./build_common $sourcedir/tmp
cp -R ./examples $sourcedir/tmp
# tinycbor is available as soft-link, so copying with 'dereference' option.
cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
cp -R ./extlibs/sqlite3 $sourcedir/tmp/extlibs
cp -R ./extlibs/timer $sourcedir/tmp/extlibs
cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
cp -R ./resource $sourcedir/tmp
cp -R ./service $sourcedir/tmp
cp ./extra_options.scons $sourcedir/tmp
cp ./tools/tizen/*.spec ./tmp/packaging
cp ./tools/tizen/*.manifest ./tmp/packaging
cp ./SConstruct ./tmp
# copy dependency RPMs and conf files for tizen build
cp ./tools/tizen/*.rpm ./tmp
cp ./tools/tizen/.gbs.conf ./tmp
cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
cd $sourcedir/tmp
echo `pwd`
whoami
# Initialize Git repository
if [ ! -d .git ]; then
git init ./
git config user.email "you@example.com"
git config user.name "Your Name"
git add ./
git commit -m "Initial commit"
fi
echo "Calling core gbs build command"
gbscommand="gbs build -A armv7l --include-all --repository ./ --define 'TARGET_TRANSPORT IP' --define 'SECURED 0' --define 'RELEASE 0' --define 'LOGGING true'"
echo $gbscommand
if eval $gbscommand; then
echo "Core build is successful"
else
echo "Core build failed."
cd $sourcedir
rm -rf $sourcedir/tmp
exit 1
fi
cd service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
echo `pwd`
# Initialize Git repository
if [ ! -d .git ]; then
git init ./
git config user.email "you@example.com"
git config user.name "Your Name"
git add ./
git commit -m "Initial commit"
fi
echo "Calling sample gbs build command"
gbscommand="gbs build -A armv7l -B ~/GBS-ROOT --include-all --repository ./ --define 'TARGET_TRANSPORT IP' --define 'SECURED 0' --define 'RELEASE 0' --define 'LOGGING True' --define 'ROUTING EP' --define 'TARGET_ENROLLEE tizen
'"
echo $gbscommand
if eval $gbscommand; then
echo "Sample build is successful"
else
echo "Sample build is failed."
exit 1
fi
rm -rf tmp
cd $sourcedir
rm -rf $sourcedir/tmp
exit 0
......@@ -47,5 +47,5 @@ if secured == '1':
env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__'])
env.Append(LIBS=['-ltinydtls'])
env.Program('enrollee_wifi', [sample_dir + 'enrollee_wifi.cpp'])
env.Program('enrollee_wifi', [sample_dir + 'enrolleewifi.cpp'])
......@@ -27,9 +27,11 @@ Build Procedure
2) Go to "iotivity/" folder.
3) Execute following command(s) to start build based on transport selection required :
sh gbsbuild.sh
Note :- Upon successful execution of above command(s) RI library and sample applications will be
generated at path "~/GBS-ROOT/local/repos/<target>/armv7l/RPMS".
scons -f service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP ROUTING=EP RELEASE=0 LOGGING=true
(If needed, modify the parameters accordingly)
Note :- Upon successful execution of above command(s) RI library and sample console application(for tizen enrollee)
will be generated at path "~/GBS-ROOT/local/repos/<target>/armv7l/RPMS".
Procedure to Execute Sample App:
================================
......
......@@ -18,7 +18,7 @@
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "networkHandler.h"
#include "networkhandler.h"
// Arduino WiFi Shield includes
#include <SPI.h>
......
......@@ -25,7 +25,7 @@
extern "C" {
#endif // __cplusplus:$
#include "networkHandler.h"
#include "networkhandler.h"
/**
* It will on-board the Enrollee device. This is a template method that has
......
......@@ -24,7 +24,7 @@
#include "logger.h"
#include "ocstack.h"
#include "escommon.h"
#include "networkHandler.h"
#include "networkhandler.h"
#include "octypes.h"
#ifndef ES_RESOURCE_HANDLER_H_
......
......@@ -22,7 +22,7 @@
#define EASYSETUP_ENROLLEE_SOFTAP_H__
#include "escommon.h"