From 445991795522998753dbdde21eb9ba392df7b5c2 Mon Sep 17 00:00:00 2001 From: "heesung84.kim" Date: Sat, 20 Dec 2014 10:05:54 +0900 Subject: [PATCH] Fixed Scons build Error. Before scons build is not working because of cpluff build and mqtt build. It is resolved. Remove null check point cpluff. PluginManger will pass the argument to plugins later. Currently it is not needed yet. Comment out related code. Modify the readme file for scons build Before readme file is for makefile. Comment Out Notification build in the Scons script. Because of scons build error. Change-Id: I1d74179ee6439535f218bb45a2f93248fb731228 Signed-off-by: heesung84.kim --- service/SConscript | 7 ++----- service/protocol-plugin/lib/cpluff/SConscript | 21 +++++++++++--------- .../protocol-plugin/lib/cpluff/libcpluff/psymbol.c | 2 +- service/protocol-plugin/plugin-manager/SConscript | 18 +++++++++++++++-- .../plugin-manager/src/CpluffAdapter.cpp | 2 +- .../plugin-manager/src/CpluffAdapter.h | 2 -- .../plugin-manager/src/FelixAdapter.h | 2 -- service/protocol-plugin/plugins/SConscript | 11 +++++++++-- .../plugins/mqtt-fan/src/fanserver_mqtt_plugin.cpp | 4 ++-- .../mqtt-light/src/lightserver_mqtt_plugin.cpp | 4 ++-- service/protocol-plugin/readme | 23 ++++++++++++---------- .../protocol-plugin/sample-app/linux/SConscript | 13 +++++++----- 12 files changed, 66 insertions(+), 43 deletions(-) diff --git a/service/SConscript b/service/SConscript index 4f49777..28c0d38 100644 --- a/service/SConscript +++ b/service/SConscript @@ -14,12 +14,9 @@ if target_os != 'arduino': SConscript('soft-sensor-manager/SConscript') # Build protocol plugin project - # protocol-plugin use 'sys/inotify.h', this header file doesn't - # exist on MAC OSX - if target_os not in ['darwin', 'ios']: - SConscript('protocol-plugin/SConscript') + SConscript('protocol-plugin/SConscript') # Build notification manager project - SConscript('notification-manager/SConscript') +# SConscript('notification-manager/SConscript') else: SConscript('notification-manager/SampleApp/arduino/SConscript') diff --git a/service/protocol-plugin/lib/cpluff/SConscript b/service/protocol-plugin/lib/cpluff/SConscript index 58e79f7..b7ea4df 100644 --- a/service/protocol-plugin/lib/cpluff/SConscript +++ b/service/protocol-plugin/lib/cpluff/SConscript @@ -12,15 +12,18 @@ target_os = env.get('TARGET_OS') ###################################################################### # Build flags ###################################################################### -cpluff_env.AppendUnique(CPPPATH = ['libcpluff/']) -if target_os not in ['windows', 'winrt']: - cpluff_env.AppendUnique(CFLAGS = ['-g','-fPIC', '-DPIC', - '-DDLOPEN_POSIX', - '-DCP_HOST=\\"' + platform.platform() + '\\"', - '-DCP_SHREXT=\\".so\\"', - '-DCP_FNAMESEP_CHAR=\\"\'/\'\\"', - '-DCP_THREADS=\\"Posix\\"']) - cpluff_env.AppendUnique(LIBS = ['dl']) +cpluff_env.AppendUnique(CPPDEFINES = ['CP_C_API=CP_EXPORT', + 'CP_HOST=\"\\"'+env.get('TARGET_OS')+'\\"\"', + 'CP_DATADIR=\"\\\"/usr/local/share\\\"\"', + 'DLOPEN_POSIX', + 'DPIC', + 'CP_THREADS=\"\\\"Posix\\"\"', + 'CP_SHREXT=\"\\".so\\"\"', + 'CP_FNAMESEP_CHAR=\"\'/\'\"', + 'CP_FNAMESEP_STR=\"\\\"/\\"\"', + 'PACKAGE=\"\\\"cpluff\\\"\"']) +cpluff_env.AppendUnique(LIBS = ['dl']) +cpluff_env.PrependUnique(CCFLAGS = ['-fPIC']) ###################################################################### # Source files and Targets ###################################################################### diff --git a/service/protocol-plugin/lib/cpluff/libcpluff/psymbol.c b/service/protocol-plugin/lib/cpluff/libcpluff/psymbol.c index ccf9ea6..a2bca4a 100644 --- a/service/protocol-plugin/lib/cpluff/libcpluff/psymbol.c +++ b/service/protocol-plugin/lib/cpluff/libcpluff/psymbol.c @@ -74,7 +74,7 @@ CP_C_API cp_status_t cp_define_symbol(cp_context_t *context, const char *name, v CHECK_NOT_NULL(context); CHECK_NOT_NULL(name); - CHECK_NOT_NULL(ptr); +// CHECK_NOT_NULL(ptr); if (context->plugin == NULL) { cpi_fatalf(_("Only plug-ins can define context specific symbols.")); } diff --git a/service/protocol-plugin/plugin-manager/SConscript b/service/protocol-plugin/plugin-manager/SConscript index 1e7d42b..e15658f 100644 --- a/service/protocol-plugin/plugin-manager/SConscript +++ b/service/protocol-plugin/plugin-manager/SConscript @@ -15,7 +15,8 @@ target_os = env.get('TARGET_OS') ###################################################################### plugin_manager_env.AppendUnique(CPPPATH = [ '../lib/cpluff/libcpluff', - 'src' + 'src', + '../lib/rapidxml' ]) if target_os not in ['windows', 'winrt']: @@ -26,6 +27,18 @@ if target_os == 'android': plugin_manager_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions']) plugin_manager_env.AppendUnique(LIBS = ['boost_thread-gcc-mt-1_49', 'gnustl_static']) +plugin_manager_env.AppendUnique(CPPDEFINES = ['CP_C_API=CP_EXPORT', + 'CP_HOST=\"\\"'+env.get('TARGET_OS')+'\\"\"', + 'CP_DATADIR=\"\\\"/usr/local/share\\\"\"', + 'DLOPEN_POSIX', + 'DPIC', + 'CP_THREADS=\"\\\"Posix\\"\"', + 'CP_SHREXT=\"\\".so\\"\"', + 'CP_FNAMESEP_CHAR=\"\'/\'\"', + 'CP_FNAMESEP_STR=\"\\\"/\\"\"', + 'PACKAGE=\"\\\"cpluff\\\"\"']) + + plugin_manager_env.AppendUnique(LIBS = ['oc', 'octbstack', 'expat', 'dl']) ###################################################################### # Source files and Targets @@ -37,7 +50,8 @@ pmimpl_src = [ 'src/CpluffAdapter.cpp', 'src/FelixAdapter.cpp', 'src/Plugin.cpp', - 'src/PluginManagerImpl.cpp'] + 'src/PluginManagerImpl.cpp', + 'src/Config.cpp'] pmimpl_env = plugin_manager_env.Clone() pmimpl_env.PrependUnique(CCFLAGS = ['-fPIC']) diff --git a/service/protocol-plugin/plugin-manager/src/CpluffAdapter.cpp b/service/protocol-plugin/plugin-manager/src/CpluffAdapter.cpp index addc2a7..3acd2f5 100644 --- a/service/protocol-plugin/plugin-manager/src/CpluffAdapter.cpp +++ b/service/protocol-plugin/plugin-manager/src/CpluffAdapter.cpp @@ -457,7 +457,7 @@ int CpluffAdapter::start(Plugin *const plugin, void *const arg) { ctx = cpi_new_context((cp_plugin_t *)hnode_get(hash_lookup(m_context->env->plugins, id.c_str())), m_context->env, &status); - cp_define_symbol(ctx, "START_ARGUMENT", arg); + //cp_define_symbol(ctx, "START_ARGUMENT", arg); //printf("start ocplatform address : %x\n", arg); if ((status = cp_start_plugin(m_context, (char *)id.c_str()) ) != CP_OK) diff --git a/service/protocol-plugin/plugin-manager/src/CpluffAdapter.h b/service/protocol-plugin/plugin-manager/src/CpluffAdapter.h index e0b934f..6c108d0 100644 --- a/service/protocol-plugin/plugin-manager/src/CpluffAdapter.h +++ b/service/protocol-plugin/plugin-manager/src/CpluffAdapter.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,6 @@ #include "Plugin.h" #include "Config.h" -#define EVENT_SIZE ( sizeof (struct inotify_event) ) #define BUF_LEN (int)( 1024 * ( EVENT_SIZE + 16 ) ) namespace OIC diff --git a/service/protocol-plugin/plugin-manager/src/FelixAdapter.h b/service/protocol-plugin/plugin-manager/src/FelixAdapter.h index 7c6398c..7f03f7f 100644 --- a/service/protocol-plugin/plugin-manager/src/FelixAdapter.h +++ b/service/protocol-plugin/plugin-manager/src/FelixAdapter.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,6 @@ #include "Plugin.h" #include "Config.h" -#define EVENT_SIZE ( sizeof (struct inotify_event) ) #define BUF_LEN (int)( 1024 * ( EVENT_SIZE + 16 ) ) namespace OIC diff --git a/service/protocol-plugin/plugins/SConscript b/service/protocol-plugin/plugins/SConscript index 0d9e0cf..e00a35e 100644 --- a/service/protocol-plugin/plugins/SConscript +++ b/service/protocol-plugin/plugins/SConscript @@ -18,6 +18,7 @@ plugins_env.AppendUnique(CPPPATH = ['../lib/cpluff/libcpluff']) if target_os not in ['windows', 'winrt']: plugins_env.AppendUnique(CXXFLAGS = ['-g3', '-Wall', '-pthread', '-std=c++0x']) + plugins_env.PrependUnique(CCFLAGS = ['-fPIC']) plugins_env.AppendUnique(LINKFLAGS = ['-fPIC']) if target_os not in ['arduino', 'android']: @@ -28,13 +29,19 @@ if target_os == 'android': plugins_env.AppendUnique(LIBS = ['gnustl_static']) plugins_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1']) +plugins_env.AppendUnique(LIBS = [File(env.get('BUILD_DIR') + '/libmosquitto.a'), + 'mosquitto', 'ssl', 'rt']) + + ###################################################################### # Source files and Targets ###################################################################### +plugins_env['LIBPREFIX'] = '' + mqtt_fan_src = Glob('mqtt-fan/src/' + '*.cpp') -fanserver = plugins_env.SharedLibrary('fanserver_mqtt_plugin', mqtt_fan_src) +fanserver = plugins_env.SharedLibrary('mqtt-fan/fanserver_mqtt_plugin', mqtt_fan_src) mqtt_light_src = Glob('mqtt-light/src/' + '*.cpp') -lightserver = plugins_env.SharedLibrary('lightserver_mqtt_plugin', mqtt_light_src) +lightserver = plugins_env.SharedLibrary('mqtt-light/lightserver_mqtt_plugin', mqtt_light_src) SConscript('mqtt-fan/lib/SConscript') diff --git a/service/protocol-plugin/plugins/mqtt-fan/src/fanserver_mqtt_plugin.cpp b/service/protocol-plugin/plugins/mqtt-fan/src/fanserver_mqtt_plugin.cpp index f93be96..82cedfc 100644 --- a/service/protocol-plugin/plugins/mqtt-fan/src/fanserver_mqtt_plugin.cpp +++ b/service/protocol-plugin/plugins/mqtt-fan/src/fanserver_mqtt_plugin.cpp @@ -43,7 +43,7 @@ static int start(void *d) { plugin_data_t *data = (plugin_data_t *)d; - data->str = (void *)cp_resolve_symbol(data->ctx, "fanserver_mqtt_plugin", "START_ARGUMENT", NULL); + //data->str = (void *)cp_resolve_symbol(data->ctx, "fanserver_mqtt_plugin", "START_ARGUMENT", NULL); //cp_run_function(data->ctx, (cp_run_func_t)start_fanserver); // 1 pthread_create(&(data->m_thread), NULL, start_fanserver, data); // 2 @@ -56,7 +56,7 @@ static void stop(void *d) plugin_data_t *data = (plugin_data_t *)d; data->flag = false; - cp_release_symbol(data->ctx, data->str); + //cp_release_symbol(data->ctx, data->str); pthread_join(data->m_thread, (void **)NULL); } diff --git a/service/protocol-plugin/plugins/mqtt-light/src/lightserver_mqtt_plugin.cpp b/service/protocol-plugin/plugins/mqtt-light/src/lightserver_mqtt_plugin.cpp index 28b1c5d..dccac9f 100644 --- a/service/protocol-plugin/plugins/mqtt-light/src/lightserver_mqtt_plugin.cpp +++ b/service/protocol-plugin/plugins/mqtt-light/src/lightserver_mqtt_plugin.cpp @@ -43,7 +43,7 @@ static int start(void *d) { plugin_data_t *data = (plugin_data_t *)d; - data->str = (void *)cp_resolve_symbol(data->ctx, "lightserver_mqtt_plugin", "START_ARGUMENT", NULL); + //data->str = (void *)cp_resolve_symbol(data->ctx, "lightserver_mqtt_plugin", "START_ARGUMENT", NULL); //cp_run_function(data->ctx, (cp_run_func_t)start_fanserver); // 1 pthread_create(&(data->m_thread), NULL, start_lightserver, data); // 2 @@ -56,7 +56,7 @@ static void stop(void *d) plugin_data_t *data = (plugin_data_t *)d; data->flag = false; - cp_release_symbol(data->ctx, data->str); + //cp_release_symbol(data->ctx, data->str); pthread_join(data->m_thread, (void **)NULL); } diff --git a/service/protocol-plugin/readme b/service/protocol-plugin/readme index c9f3ad2..94f5841 100644 --- a/service/protocol-plugin/readme +++ b/service/protocol-plugin/readme @@ -38,6 +38,8 @@ The Protocol Plug-in directory includes following sub directories; /build Directory for Building and Binary Release +If you build by scons skip 2,3. + 2. Compiling C-Pluff library Before building Protocol-Plugin Manager, C-Pluff library should be compiled as follows. @@ -60,18 +62,19 @@ NOTE: To build plugins in 64-bit Ubuntu Linux, OCLib.a and libcoap.a library sho 4. Using Plugins This version of protocol plug-in source code has following functionality. -1) provides plug-in manager which can start and stop plug-in library. -2) provides plug-in library which can communicate with MQTT protocol Fan and Light. -3) provides OIC Sample Client which can get info about Fan and Light with configuration file(pluginmanager.xml). - before starting sample app need as below command. - $export LD_LIBRARY_PATH={Top_Dir}/out/linux/x86/release/:$LD_LIBRARY_PATH +1) Provides plug-in manager which can start and stop plug-in library. +2) Provides plug-in library which can communicate with MQTT protocol Fan and Light. +3) Locate shared plug-in library and XML file in a specific folder. So, to test a plug-in, follow below steps. -1) Locate shared plug-in library and XML file in a specific folder. -2) Register the plug-in with directory path input from plug-in manager sample. -3) Start the plug-in from plug-in manager sample. -4) Run OIC sample client. +1) Copy libpmimple.so from {Top_Dir}/out/linux/x86/release to sample-app folder. +2) Provides OIC Sample Client which can get info about Fan and Light with configuration file(pluginmanager.xml). +3) Copy the pluginmanager.xml from ~/service/protocol-plugin/sample-app/linux/mqtt/ to sample-app folder. +4) Modifty the pluginmanager.xml +5) Before starting sample app need as below command. + $export LD_LIBRARY_PATH={Top_Dir}/out/linux/x86/release/:$LD_LIBRARY_PATH +6) Start the plug-in from plug-in manager sample. ex)~service/protocol-plugin/sample-app/linux/mqtt$./mqttclient - (mqtt broker is already installed in the local system.) + (Need mqtt broker working in the local system(127.0.0.1) for test.) diff --git a/service/protocol-plugin/sample-app/linux/SConscript b/service/protocol-plugin/sample-app/linux/SConscript index 339d4bb..2e6b311 100644 --- a/service/protocol-plugin/sample-app/linux/SConscript +++ b/service/protocol-plugin/sample-app/linux/SConscript @@ -13,16 +13,19 @@ target_os = env.get('TARGET_OS') ###################################################################### # Build flags ###################################################################### -sample_env.AppendUnique(CPPPATH = ['../../plugin-manager/src/', - '../../lib/cpluff/libcpluff/']) +sample_env.AppendUnique(CPPPATH = [ + '../../plugin-manager/src/', + '../../lib/cpluff/libcpluff/', + '../../lib/rapidxml']) if target_os not in ['windows', 'winrt']: sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-pthread', '-std=c++0x']) +sample_env.AppendUnique(LIBS = ['pthread']) sample_env.AppendUnique(LIBS = ['oc', 'oc_logger', 'octbstack', 'coap', 'ppm', 'pmimpl', 'dl']) ###################################################################### # Source files and Targets ###################################################################### -fanclient = sample_env.Program('fanclient', 'fan-control/fanclient.cpp') +mqttclient = sample_env.Program('mqtt/mqttclient', 'mqtt/mqttclient.cpp') -Alias('fanclient', fanclient) -env.AppendTarget('fanclient') \ No newline at end of file +Alias('mqttclient', mqttclient) +env.AppendTarget('mqttclient') \ No newline at end of file -- 2.7.4