summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-01-16 14:55:20 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-01-24 10:41:40 +0100
commit2fd0e000fe6206a113f1def04363e7412a2a5007 (patch)
treed813a613dfc2d8953792694b5274e65b9b71d957
parent8f7623339beb1ba07a41a016fa0a1507da92a03e (diff)
Adds more details about the library migration
- adds the controller binder definitions migration to binder functions definitions and instructions using a sed script to migrate the old functions definition. - adds requirement reminder to af-binder version >= FF - fix wrong git submodule name given as example - Use AGLVERSION variable to set the PROJECT_VERSION. AGLVERSION could then be overwriten using command-line. - Use ${libdir} instead of CMake variable to set the Libs pkg-config variable. Bug-AGL: SPEC-1689 Change-Id: If03f35bab9501fbcb97244836692301c36d6d74c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--ctl-lib/CMakeLists.txt8
-rw-r--r--ctl-lib/appcontroller.pc.in30
-rw-r--r--ctl-lib/ctl-utilities.pc.in7
-rw-r--r--docs/Usage.md116
-rw-r--r--docs/controller.md16
5 files changed, 164 insertions, 13 deletions
diff --git a/ctl-lib/CMakeLists.txt b/ctl-lib/CMakeLists.txt
index 914e11c..278ebd0 100644
--- a/ctl-lib/CMakeLists.txt
+++ b/ctl-lib/CMakeLists.txt
@@ -15,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################
-set(TARGET_NAME "ctl-utilities")
+set(TARGET_NAME "appcontroller")
+set(LEGACY_NAME "ctl-utilities")
+set(AGLVERSION 6.99 CACHE STRING "Current AGL Version")
+set(PROJECT_VERSION ${AGLVERSION} CACHE STRING "Project version can override AGLVERSION")
set(PROJECT_PRETTY_NAME "Controller")
set(PROJECT_DESCRIPTION "controller")
set(PROJECT_URL "https://gerrit.automotivelinux.org:29418/src/libappcontroller")
@@ -24,7 +27,6 @@ set(PROJECT_AUTHOR_MAIL "fulup@iot.bzh")
set(PROJECT_LICENSE "APL2.0")
set(PROJECT_LANGUAGES "C")
-
if(DEFINED ENV{SDKTARGETSYSROOT})
file(STRINGS $ENV{SDKTARGETSYSROOT}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE")
set(BUILD_ENV_SYSROOT $ENV{SDKTARGETSYSROOT})
@@ -111,8 +113,10 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
)
CONFIGURE_FILE(${TARGET_NAME}.pc.in ${TARGET_NAME}.pc @ONLY)
+CONFIGURE_FILE(${LEGACY_NAME}.pc.in ${LEGACY_NAME}.pc @ONLY)
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc
+ ${CMAKE_CURRENT_BINARY_DIR}/${LEGACY_NAME}.pc
DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
diff --git a/ctl-lib/appcontroller.pc.in b/ctl-lib/appcontroller.pc.in
new file mode 100644
index 0000000..5980576
--- /dev/null
+++ b/ctl-lib/appcontroller.pc.in
@@ -0,0 +1,30 @@
+##
+## Copyright (C) 2016, 2017, 2018 "IoT.bzh"
+##
+## This file is part of afb-daemon project.
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: @TARGET_NAME@
+Description: @PROJECT_DESCRIPTION@
+Version: @PROJECT_VERSION@
+URL: @PROJECT_URL@
+Requires.private: afb-helpers
+Libs: -L${libdir} -l@TARGET_NAME@
+Cflags: -I${includedir}
diff --git a/ctl-lib/ctl-utilities.pc.in b/ctl-lib/ctl-utilities.pc.in
index 845ab0d..0094b54 100644
--- a/ctl-lib/ctl-utilities.pc.in
+++ b/ctl-lib/ctl-utilities.pc.in
@@ -21,11 +21,10 @@ exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
-Name: @TARGET_NAME@
+Name: @LEGACY_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
URL: @PROJECT_URL@
-Libs.private: -lafb-helpers
-Libs: -L@CMAKE_INSTALL_LIBDIR@ -l@TARGET_NAME@
+Requires.private: afb-helpers
+Libs: -L${libdir} -l@TARGET_NAME@
Cflags: -I${includedir}
-
diff --git a/docs/Usage.md b/docs/Usage.md
index e64c533..4bf1063 100644
--- a/docs/Usage.md
+++ b/docs/Usage.md
@@ -1,6 +1,8 @@
# Usage
-## (Optional) Remove the git submodule version
+## (Optional) Migrate from the git submodule version
+
+### Remove the git submodule version
If you already use the controller component but use the submodule version then
you have to get rid of it to be sure to link and use the library version. To do
@@ -9,9 +11,9 @@ so, you have to do the following:
* deinitialize the submodule using `git`
```bash
-# This example assumes that the git submodule is named app-afb-helpers-submodule
+# This example assumes that the git submodule is named app-controller-submodule
# and is located at your root project repository.
-git submodule deinit app-afb-helpers-submodule
+git submodule deinit app-controller-submodule
```
* remove the relative submodule lines from the `.gitmodules` file
@@ -30,6 +32,109 @@ TARGET_LINK_LIBRARIES(${TARGET_NAME}
)
```
+### Use the native af-binder functions
+
+The controller redefined some binder's functions to add an abstraction between
+several binding versions. But now, as the controller is binding v3 only, the
+abstraction layer from the controller has been removed and you should switch
+your functions from the old controller's definitions to binder's definitions.
+
+You have to replace any `include` statements of `afb-definitions.h` by
+`afb/afb-binding.h` if you included it somewhere. If you have only included
+`ctl-config.h` file then you are fine.
+
+```diff
+- #include <afb-definitions.h>
++ #include <afb/afb-binding.h>
+```
+
+To help migrating gracefully the old controller's definitions, you could use the
+sed script to automate the migration for you. From your project root directory,
+executes the following commands:
+
+```bash
+wget -O controller-migration.sed https://iot.bzh/download/public/tools/controller-migration.sed
+for f in $(find . -name *.c -o -name *.h)
+do
+sed -i -rf controller-migration.sed ${f}
+done
+```
+
+> **NOTE**: `AFB_ServiceCall` and `AFB_ServiceSync` has been migrated to their
+> homologue `afb_api_call_legacy` and `afb_api_call_sync_legacy` respectively
+> but you have to be aware that they are *legacy* functions and you should use
+> the news call functions `afb_api_call` and `afb_api_call_sync` instead.
+> Cf [Binder API functions reference](../af-binder/reference-v3/func-api.html#calls-and-job-functions)
+> for more details on these functions.
+
+As a reminder, here are the old controller's functions definitions that you
+should migrate:
+
+```c
+ #define AFB_ReqNone NULL
+ typedef afb_req_t AFB_ReqT;
+ typedef afb_api_t AFB_ApiT;
+ typedef afb_event_t AFB_EventT;
+
+ #define AFB_EventIsValid(eventid) eventid
+ #define AFB_EventPush afb_event_push
+ #define AFB_ReqSubscribe afb_req_subscribe
+ #define AFB_EventMake(api, name) afb_api_make_event(api, name)
+
+ #define AFB_ReqJson(request) afb_req_json(request)
+
+ #define AFB_ReqSuccess afb_req_success
+ #define AFB_ReqSuccessF afb_req_success_f
+ #define AFB_ReqFail afb_req_fail
+ #define AFB_ReqFailF afb_req_fail_f
+
+ #define AFB_ReqNotice(request, ...) AFB_REQ_NOTICE (request, __VA_ARGS__)
+ #define AFB_ReqWarning(request, ...) AFB_REQ_WARNING (request, __VA_ARGS__)
+ #define AFB_ReqDebug(request, ...) AFB_REQ_DEBUG (request, __VA_ARGS__)
+ #define AFB_ReqError(request, ...) AFB_REQ_ERROR (request, __VA_ARGS__)
+ #define AFB_ReqInfo(request, ...) AFB_REQ_INFO (request, __VA_ARGS__)
+
+ #define AFB_ApiVerbose(api, level, ...) afb_api_verbose(api, level, __VA_ARGS__)
+ #define AFB_ApiNotice(api, ...) AFB_API_NOTICE (api, __VA_ARGS__)
+ #define AFB_ApiWarning(api, ...) AFB_API_WARNING (api, __VA_ARGS__)
+ #define AFB_ApiDebug(api, ...) AFB_API_DEBUG (api, __VA_ARGS__)
+ #define AFB_ApiError(api, ...) AFB_API_ERROR (api, __VA_ARGS__)
+ #define AFB_ApiInfo(api, ...) AFB_API_INFO (api, __VA_ARGS__)
+
+ #define AFB_GetApiSettings afb_api_settings
+
+ #define AFB_ReqIsValid(request) request
+ #define AFB_EvtIsValid(evtHandle) evtHandle
+
+ #define AFB_ServiceCall(api, ...) afb_api_call_legacy(api, __VA_ARGS__)
+ #define AFB_ServiceSync(api, ...) afb_api_call_sync_legacy(api, __VA_ARGS__)
+
+ #define AFB_ApiCall(api, ...) afb_api_call(api, __VA_ARGS__)
+ #define AFB_ApiSync(api, ...) afb_api_call_sync(api, __VA_ARGS__)
+
+ #define AFB_ReqVCBData afb_req_get_vcbdata
+ #define AFB_ReqGetApi afb_req_get_api
+ #define AFB_GetEventLoop(api) afb_api_get_event_loop(api)
+ #define AFB_RootDirGetFD(api) afb_api_rootdir_get_fd(api)
+ #define AFB_RequireApi(api, ...) afb_api_require_api(api, __VA_ARGS__)
+
+ #define AFB_ClientCtxSet(request, replace, createCB, freeCB, handle) afb_req_context(request, replace, createCB, freeCB, handle)
+ #define AFB_ClientCtxClear(request) afb_req_context_clear(request)
+
+ #define AFB_ReqSetLOA(request, level) afb_req_session_set_LOA(request, level)
+
+ #define AFB_NewApi afb_api_new_api
+
+ #define AFB_ApiAddVerb afb_api_add_verb
+
+ #define AFB_ApiSetUserData afb_api_set_userdata
+ #define AFB_ApiGetUserData afb_api_get_userdata
+
+ #define AFB_ApiOnEvent afb_api_on_event
+ #define AFB_ApiOnInit afb_api_on_init
+ #define AFB_ApiSeal afb_api_seal
+```
+
## Add libappcontroller as a static library to your binding
In your `config.cmake` file, add a dependency to the controller library, i.e:
@@ -38,11 +143,12 @@ In your `config.cmake` file, add a dependency to the controller library, i.e:
set(PKG_REQUIRED_LIST
json-c
afb-daemon
- ctl-utilities --> this is the controller library dependency name
+ appcontroller --> this is the controller library dependency name.
)
```
-Or you can also use the `FIND_PACKAGE` CMake command to add it.
+Or you can also use the [FIND_PACKAGE](https://cmake.org/cmake/help/v3.6/command/find_package.html?highlight=find_package)
+CMake command to add it.
## Declare your controller config section in your binding
diff --git a/docs/controller.md b/docs/controller.md
index 861b487..fe5a964 100644
--- a/docs/controller.md
+++ b/docs/controller.md
@@ -4,6 +4,7 @@
* Status: Release Candidate
* Author: Fulup Ar Foll fulup@iot.bzh
* Date : May-2018
+* Require : af-binder version >= FF (handle only bindings v3)
## Features
@@ -23,8 +24,19 @@
and [libafb-helpers](https://gerrit.automotivelinux.org/gerrit/p/src/libafb-helpers.git).
* Controller relies on Lua-5.3, when not needed Lua might be removed at compilation time.
-The controller library is integrated by default in the AGL SDK since GG (>=7)
-and is also available as a package for the AGL supported linux distributions.
+The controller library is integrated by default in the AGL SDK since the Guppy
+version (>=7) and is also available as a package for the AGL supported linux
+distributions.
+
+You could find the SDK build from Yocto which embed the afb-helpers library
+here:
+
+* For [releases](https://download.automotivelinux.org/AGL/release/) >= Guppy, in
+ the latest machine's deploy directory. (e.g for Guppy in
+ `latest/<yourmachine>/deploy/sdk` directory)
+* For the [master](https://download.automotivelinux.org/AGL/snapshots/master/)
+ development branch, in the latest machine's deploy directory. (e.g in
+ `latest/<yourmachine>/deploy/sdk` directory)
To install the native package please refer to [this chapter](../host-configuration/docs/1_Prerequisites.md)
in the AGL documentation to install the AGL repository for your distribution.