diff options
author | Manuel Bachmann <manuel.bachmann@iot.bzh> | 2015-12-21 06:57:05 +0100 |
---|---|---|
committer | Manuel Bachmann <manuel.bachmann@iot.bzh> | 2015-12-21 07:00:46 +0100 |
commit | 98f5843474dcec55827279b6f42007341c171ae0 (patch) | |
tree | 010c6328cda7ef2b2577eb00ffca14c931dfbc3b /plugins | |
parent | 03bebc12f0fd5006a72e430084146a36d2db7c8d (diff) |
Switch to a plugin model
Each API now compiles to a ".so" file, which gets searched
for in the "${libdir}/afb" directory at startup.
We can now load an arbitrary number of plugins (> 10).
Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CMakeLists.txt | 18 | ||||
-rw-r--r-- | plugins/audio/CMakeLists.txt | 10 | ||||
-rw-r--r-- | plugins/audio/audio-api.c | 2 | ||||
-rw-r--r-- | plugins/radio/CMakeLists.txt | 10 | ||||
-rw-r--r-- | plugins/radio/radio-api.c | 2 | ||||
-rw-r--r-- | plugins/samples/CMakeLists.txt | 11 | ||||
-rw-r--r-- | plugins/samples/HelloWorld.c | 4 | ||||
-rw-r--r-- | plugins/samples/SamplePost.c | 4 | ||||
-rw-r--r-- | plugins/session/CMakeLists.txt | 6 | ||||
-rw-r--r-- | plugins/session/token-api.c | 4 |
10 files changed, 49 insertions, 22 deletions
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 7e3e0807..c66de5e7 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,14 +1,4 @@ -SET(SESSION_PLUGIN session/token-api.c) -SET(HELLOWORLD_PLUGINS samples/HelloWorld.c) -SET(SAMPLEPOST_PLUGINS samples/SamplePost.c) -IF(alsa_FOUND) - SET(AUDIO_PLUGIN audio/audio-api.c audio/audio-alsa.c) -ENDIF(alsa_FOUND) -IF(librtlsdr_FOUND) - SET(RADIO_PLUGIN radio/radio-api.c radio/radio-rtlsdr.c) -ENDIF(librtlsdr_FOUND) - -SET(PLUGINS_SOURCES ${SESSION_PLUGIN} ${HELLOWORLD_PLUGINS} ${SAMPLEPOST_PLUGINS} ${AUDIO_PLUGIN} ${RADIO_PLUGIN}) - -ADD_LIBRARY(plugins OBJECT ${PLUGINS_SOURCES}) -INCLUDE_DIRECTORIES(${include_dirs}) +ADD_SUBDIRECTORY(session) +ADD_SUBDIRECTORY(samples) +ADD_SUBDIRECTORY(audio) +ADD_SUBDIRECTORY(radio) diff --git a/plugins/audio/CMakeLists.txt b/plugins/audio/CMakeLists.txt new file mode 100644 index 00000000..b5adc643 --- /dev/null +++ b/plugins/audio/CMakeLists.txt @@ -0,0 +1,10 @@ +IF(alsa_FOUND) + + INCLUDE_DIRECTORIES(${include_dirs}) + + ADD_LIBRARY(audio-api MODULE audio-api.c audio-alsa.c) + SET_TARGET_PROPERTIES(audio-api PROPERTIES PREFIX "") + INSTALL(TARGETS audio-api + LIBRARY DESTINATION ${plugin_install_dir}) + +ENDIF(alsa_FOUND) diff --git a/plugins/audio/audio-api.c b/plugins/audio/audio-api.c index 53a4beab..60a5a962 100644 --- a/plugins/audio/audio-api.c +++ b/plugins/audio/audio-api.c @@ -223,7 +223,7 @@ STATIC AFB_restapi pluginApis[]= { {NULL} }; -PUBLIC AFB_plugin *audioRegister () { +PUBLIC AFB_plugin *pluginRegister () { AFB_plugin *plugin = malloc (sizeof(AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; plugin->info = "Application Framework Binder - Audio plugin"; diff --git a/plugins/radio/CMakeLists.txt b/plugins/radio/CMakeLists.txt new file mode 100644 index 00000000..c7c85411 --- /dev/null +++ b/plugins/radio/CMakeLists.txt @@ -0,0 +1,10 @@ +IF(librtlsdr_FOUND) + + INCLUDE_DIRECTORIES(${include_dirs}) + + ADD_LIBRARY(radio-api MODULE radio-api.c radio-rtlsdr.c) + SET_TARGET_PROPERTIES(radio-api PROPERTIES PREFIX "") + INSTALL(TARGETS radio-api + LIBRARY DESTINATION ${plugin_install_dir}) + +ENDIF(librtlsdr_FOUND) diff --git a/plugins/radio/radio-api.c b/plugins/radio/radio-api.c index 3de8e044..cfa25995 100644 --- a/plugins/radio/radio-api.c +++ b/plugins/radio/radio-api.c @@ -327,7 +327,7 @@ STATIC AFB_restapi pluginApis[]= { {NULL} }; -PUBLIC AFB_plugin* radioRegister () { +PUBLIC AFB_plugin* pluginRegister () { AFB_plugin *plugin = malloc (sizeof(AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; plugin->info = "Application Framework Binder - Radio plugin"; diff --git a/plugins/samples/CMakeLists.txt b/plugins/samples/CMakeLists.txt new file mode 100644 index 00000000..ef5b449e --- /dev/null +++ b/plugins/samples/CMakeLists.txt @@ -0,0 +1,11 @@ +INCLUDE_DIRECTORIES(${include_dirs}) + +ADD_LIBRARY(helloWorld-api MODULE HelloWorld.c) +SET_TARGET_PROPERTIES(helloWorld-api PROPERTIES PREFIX "") +INSTALL(TARGETS helloWorld-api + LIBRARY DESTINATION ${plugin_install_dir}) + +ADD_LIBRARY(samplePost-api MODULE SamplePost.c) +SET_TARGET_PROPERTIES(samplePost-api PROPERTIES PREFIX "") +INSTALL(TARGETS samplePost-api + LIBRARY DESTINATION ${plugin_install_dir}) diff --git a/plugins/samples/HelloWorld.c b/plugins/samples/HelloWorld.c index 4117c26a..5638b427 100644 --- a/plugins/samples/HelloWorld.c +++ b/plugins/samples/HelloWorld.c @@ -84,11 +84,11 @@ STATIC AFB_restapi pluginApis[]= { }; -PUBLIC AFB_plugin *helloWorldRegister () { +PUBLIC AFB_plugin *pluginRegister () { AFB_plugin *plugin = malloc (sizeof (AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; plugin->info = "Application Framework Binder Service"; plugin->prefix= "dbus"; plugin->apis = pluginApis; return (plugin); -};
\ No newline at end of file +}; diff --git a/plugins/samples/SamplePost.c b/plugins/samples/SamplePost.c index 85485015..223f74e8 100644 --- a/plugins/samples/SamplePost.c +++ b/plugins/samples/SamplePost.c @@ -165,7 +165,7 @@ STATIC AFB_restapi pluginApis[]= { {NULL} }; -PUBLIC AFB_plugin *samplePostRegister () { +PUBLIC AFB_plugin *pluginRegister () { AFB_plugin *plugin = malloc (sizeof (AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; plugin->info = "Application Framework Binder Service"; @@ -174,4 +174,4 @@ PUBLIC AFB_plugin *samplePostRegister () { plugin->handle= (void*) "What ever you want"; return (plugin); -};
\ No newline at end of file +}; diff --git a/plugins/session/CMakeLists.txt b/plugins/session/CMakeLists.txt new file mode 100644 index 00000000..ddd185df --- /dev/null +++ b/plugins/session/CMakeLists.txt @@ -0,0 +1,6 @@ +INCLUDE_DIRECTORIES(${include_dirs}) + +ADD_LIBRARY(token-api MODULE token-api.c) +SET_TARGET_PROPERTIES(token-api PROPERTIES PREFIX "") +INSTALL(TARGETS token-api + LIBRARY DESTINATION ${plugin_install_dir}) diff --git a/plugins/session/token-api.c b/plugins/session/token-api.c index b6ebb8ad..ba6d2761 100644 --- a/plugins/session/token-api.c +++ b/plugins/session/token-api.c @@ -94,7 +94,7 @@ STATIC AFB_restapi pluginApis[]= { {NULL} }; -PUBLIC AFB_plugin *tokenRegister () { +PUBLIC AFB_plugin *pluginRegister () { AFB_plugin *plugin = malloc (sizeof (AFB_plugin)); plugin->type = AFB_PLUGIN_JSON; plugin->info = "Application Framework Binder Service"; @@ -104,4 +104,4 @@ PUBLIC AFB_plugin *tokenRegister () { plugin->freeCtxCB= (void*) clientContextFree; return (plugin); -};
\ No newline at end of file +}; |