diff options
author | Scott Murray <scott.murray@konsulko.com> | 2020-05-26 17:49:50 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2020-05-26 18:27:40 -0400 |
commit | 89edd734c0a347dafceba1cef1ac835e0fe61e1a (patch) | |
tree | d54ef3bc130749b9c4241f22663b508c697af9f5 | |
parent | 055909f4a7b27003bdd60c1cee764cf1d23be9cc (diff) |
Fix CMake files and non-debug crashes
Changes include:
- Reworked src/CMakeLists.txt to use app template macros.
- Removed now unnecessary linker script, symbol exports are handled
in the app template macros.
- Set missing required entries in conf.d/cmake/config.cmake, and
update to match latest template version in cmake-apps-module,
as well as some naming fixes in the PROJECT* definitions.
- Move project definition to top-level CMakeLists.txt to make
tracking conf.d/cmake/config.cmake changes easier. This quiets
the warning from newer versions of CMake about needing a project
definition in the top-level CMakeLists.txt.
- Moved icon file to default location for app template.
- Added config.xml.in file to work with app template, replacing
previous hard-coded version.
- Fixed some issues in src/hs-clientmanager.{h,cpp} to address
crashes seen in the release widget now that it is actually built
without debug flags, and to quiet some warnings.
Bug-AGL: SPEC-3343
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I3741e6a307297272d5c22e894dfa9ff8b0dd1f52
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | conf.d/cmake/config.cmake | 42 | ||||
-rw-r--r-- | conf.d/wgt/config.xml.in | 32 | ||||
-rw-r--r-- | conf.d/wgt/icon.svg (renamed from package/root/icon.svg) | 0 | ||||
-rw-r--r-- | package/root/config.xml | 27 | ||||
-rw-r--r-- | src/CMakeLists.txt | 67 | ||||
-rw-r--r-- | src/export.map | 1 | ||||
-rw-r--r-- | src/hs-clientmanager.cpp | 13 | ||||
-rw-r--r-- | src/hs-clientmanager.h | 10 |
9 files changed, 82 insertions, 113 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fe99ce..097c17c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ # # Copyright (c) 2017 TOYOTA MOTOR CORPORATION +# Copyright (C) 2020 Konsulko Group # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +15,8 @@ # limitations under the License. # +project(HomeScreenService) + CMAKE_MINIMUM_REQUIRED(VERSION 3.3) include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index d60affa..ee0bb05 100644 --- a/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -1,5 +1,6 @@ ########################################################################### # Copyright 2015-2020 IoT.bzh +# Copyright (C) 2020 Konsulko Group # # author: Marec Frédéric <frederic.marec@iot.bzh> # @@ -18,26 +19,17 @@ # Project Info # ------------------ -project(HomeScreenService C CXX) - -set(PROJECT_NAME "HomeScreen Service") -set(PROJECT_VERSION "1.0") -set(PROJECT_PRETTY_NAME "HM") -set(PROJECT_DESCRIPTION "HomeScreen Service") -set(PROJECT_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) -set(PROJECT_LIBDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) -set(binding_install_dir ${PREFIX}/lib/homescreen) -set(PROJECT_BINDINGDIR ${binding_install_dir}) +set(PROJECT_NAME "agl-service-homescreen") +set(API_NAME "homescreen") +set(PROJECT_PRETTY_NAME "HomeScreen Service") +set(PROJECT_DESCRIPTION "HomeScreen Binding Service") set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/apps/agl-service-homescreen") -set(PROJECT_ICON "icon.png") - -# get pkgconfig -INCLUDE(FindPkgConfig) -link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined) - -set(CMAKE_BUILD_TYPE RELEASE) -set(DEBUGMODE "1") -add_definitions(-DDEBUGMODE) +set(PROJECT_ICON "icon.svg") +set(PROJECT_AUTHOR "TOYOTA") +set(PROJECT_AUTHOR_EMAIL "") +set(PROJECT_VERSION "0.1") +set(PROJECT_LICENSE "APL2.0") +set(PROJECT_LANGUAGES,"CXX") # Which directories inspect to find CMakeLists.txt target files # set(PROJECT_SRC_DIR_PATTERN "*") @@ -48,7 +40,7 @@ set(PROJECT_CMAKE_CONF_DIR "conf.d") # Compilation Mode (DEBUG, RELEASE, COVERAGE or PROFILING) # ---------------------------------- -#set(BUILD_TYPE "DEBUG") +set(BUILD_TYPE "RELEASE") #set(USE_EFENCE 1) # Kernel selection if needed. You can choose between a @@ -87,7 +79,7 @@ set (PKG_REQUIRED_LIST # Customize link option # ----------------------------- -#list(APPEND link_libraries -an-option) +list (APPEND link_libraries -pthread) # Compilation options definition # Use CMake generator expressions to specify only for a specific language @@ -146,9 +138,7 @@ set (PKG_REQUIRED_LIST # template which is very simple and it is highly probable that it will not suit # to your app. # ----------------------------------------- -#set(WIDGET_ICON "conf.d/wgt/${PROJECT_ICON}" CACHE PATH "Path to the widget icon") -#set(WIDGET_CONFIG_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in" CACHE PATH "Path to widget config file template (config.xml.in)") -#set(TEST_WIDGET_CONFIG_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/test-config.xml.in" CACHE PATH "Path to the test widget config file template (test-config.xml.in)") +set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in) # Mandatory widget Mimetype specification of the main unit # -------------------------------------------------------------------------- @@ -165,14 +155,14 @@ set (PKG_REQUIRED_LIST # content.src designates the relative path of the binary. # For such application, only security setup is made. # -set(WIDGET_TYPE MimeType_Not_Set) +set(WIDGET_TYPE application/vnd.agl.service) # Mandatory Widget entry point file of the main unit # -------------------------------------------------------------- # This is the file that will be executed, loaded, # at launch time by the application framework. # -set(WIDGET_ENTRY_POINT EntryPoint_Path_Not_Set) +set(WIDGET_ENTRY_POINT lib/homescreen-binding.so) # Optional dependencies order # --------------------------- diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in new file mode 100644 index 0000000..ce1d7bc --- /dev/null +++ b/conf.d/wgt/config.xml.in @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@"> + <name>@PROJECT_NAME@</name> + <icon src="@PROJECT_ICON@"/> + <content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/> + <description>@PROJECT_DESCRIPTION@</description> + <author>@PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@></author> + <license>@PROJECT_LICENSE@</license> + + <feature name="urn:AGL:widget:required-permission"> + <param name="urn:AGL:permission::public:hidden" value="required" /> + <param name="urn:AGL:permission::public:no-htdocs" value="required" /> + <param name="urn:AGL:permission::system:run-by-default" value="required" /> + <param name="http://tizen.org/privilege/internal/dbus" value="required" /> + <param name="urn:AGL:permission:afm:system:widget" value="required" /> + <param name="urn:AGL:permission:afm:system:runner" value="required" /> + <param name="urn:AGL:permission:afm:system:widget:start" value="required" /> + </feature> + + <feature name="urn:AGL:widget:provided-api"> + <param name="@API_NAME@" value="ws" /> + </feature> + + <feature name="urn:AGL:widget:required-api"> + <param name="afm-main" value="ws" /> + <param name="windowmanager" value="ws" /> + </feature> + + <feature name="urn:AGL:widget:required-binding"> + <param name="@WIDGET_ENTRY_POINT@" value="local" /> + </feature> +</widget> diff --git a/package/root/icon.svg b/conf.d/wgt/icon.svg index 6628784..6628784 100644 --- a/package/root/icon.svg +++ b/conf.d/wgt/icon.svg diff --git a/package/root/config.xml b/package/root/config.xml deleted file mode 100644 index 38c1258..0000000 --- a/package/root/config.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<widget xmlns="http://www.w3.org/ns/widgets" id="homescreen-service" version="0.1"> - <name>homescreen-service</name> - <icon src="icon.svg"/> - <content src="config.xml" type="application/vnd.agl.service"/> - <description>HomeScreen Binding service</description> - <author>TOYOTA</author> - <license>APL 2.0</license> - <feature name="urn:AGL:widget:required-permission"> - <param name="urn:AGL:permission::public:hidden" value="required" /> - <param name="urn:AGL:permission::system:run-by-default" value="required" /> - <param name="http://tizen.org/privilege/internal/dbus" value="required" /> - <param name="urn:AGL:permission:afm:system:widget" value="required" /> - <param name="urn:AGL:permission:afm:system:runner" value="required" /> - <param name="urn:AGL:permission:afm:system:widget:start" value="required" /> - </feature> - <feature name="urn:AGL:widget:provided-api"> - <param name="homescreen" value="ws" /> - </feature> - <feature name="urn:AGL:widget:required-api"> - <param name="afm-main" value="ws" /> - <param name="windowmanager" value="ws" /> - </feature> - <feature name="urn:AGL:widget:required-binding"> - <param name="lib/homescreen-service.so" value="local" /> - </feature> -</widget> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 98dc27c..b415443 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ # # Copyright (c) 2017 TOYOTA MOTOR CORPORATION +# Copyright (C) 2020 Konsulko Group # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,58 +15,26 @@ # limitations under the License. # -cmake_minimum_required(VERSION 2.8) +PROJECT_TARGET_ADD(homescreen-binding) -set(TARGETS_HSBINDER homescreen-service) +add_definitions(-DAFB_BINDING_VERSION=3) -INCLUDE(FindThreads) -FIND_PACKAGE(Threads) - -pkg_check_modules(hs_binding_depends afb-daemon glib-2.0 gio-2.0 gio-unix-2.0 json-c) -set(binding_hs_sources - homescreen.cpp - hs-helper.cpp - hs-clientmanager.cpp - hs-client.cpp - hs-proxy.cpp - hs-appinfo.cpp) - -link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined) -include_directories(${PROJECT_SOURCE_DIR}/include) -add_library(${TARGETS_HSBINDER} MODULE ${binding_hs_sources}) - -target_compile_options(${TARGETS_HSBINDER} PRIVATE ${hs_binding_depends_CFLAGS}) -if(DEFINED DEBUGMODE) - target_compile_options(${TARGETS_HSBINDER} PRIVATE -g -O0) -else(DEFINED DEBUGMODE) - target_compile_options(${TARGETS_HSBINDER} PRIVATE -g -O2) -endif(DEFINED DEBUGMODE) - -target_include_directories(${TARGETS_HSBINDER} PRIVATE ${hs_binding_depends_INCLUDE_DIRS}) -target_link_libraries(${TARGETS_HSBINDER} ${CMAKE_THREAD_LIBS_INIT} ${link_libraries} ${hs_binding_depends_LIBRARIES}) +# Define project Targets +add_library(${TARGET_NAME} MODULE + homescreen.cpp + hs-helper.cpp + hs-clientmanager.cpp + hs-client.cpp + hs-proxy.cpp + hs-appinfo.cpp) # Binder exposes a unique public entry point - -set_target_properties(${TARGETS_HSBINDER} PROPERTIES - PREFIX "" - LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.map" - ) - -# installation directory -#INSTALL(TARGETS ${TARGETS_HSBINDER} -# LIBRARY DESTINATION ${binding_install_dir}) - -if(NOT EXISTS ${PROJECT_BINARY_DIR}/package) - add_custom_command(TARGET ${TARGETS_HSBINDER} POST_BUILD - COMMAND cp -rf ${PROJECT_SOURCE_DIR}/package ${PROJECT_BINARY_DIR} - ) -endif() - -add_custom_command(TARGET ${TARGETS_HSBINDER} POST_BUILD - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib - COMMAND cp -rf ${PROJECT_BINARY_DIR}/src/${TARGETS_HSBINDER}.so ${PROJECT_BINARY_DIR}/package/root/lib +SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "BINDING" + PREFIX "" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${TARGET_NAME} ) -add_custom_target(package DEPENDS ${PROJECT_BINARY_DIR}/package/root - COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/${TARGETS_HSBINDER}.wgt ${PROJECT_BINARY_DIR}/package/root -) +# Library dependencies (include updates automatically) +TARGET_LINK_LIBRARIES(${TARGET_NAME} ${link_libraries}) diff --git a/src/export.map b/src/export.map deleted file mode 100644 index f3961c0..0000000 --- a/src/export.map +++ /dev/null @@ -1 +0,0 @@ -{ global: afbBindingV*; local: *; };
\ No newline at end of file diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp index 6e6397f..9b62808 100644 --- a/src/hs-clientmanager.cpp +++ b/src/hs-clientmanager.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * Copyright (C) 2020 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,6 +72,7 @@ HS_ClientManager* HS_ClientManager::instance(void) */ int HS_ClientManager::init(void) { + return 0; } /** @@ -89,7 +91,7 @@ HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req_t req, std::string app if (!ctxt) { AFB_INFO( "create new session for %s", appid.c_str()); - HS_ClientCtxt *ctxt = new HS_ClientCtxt(appid.c_str()); + ctxt = new HS_ClientCtxt(appid); afb_req_session_set_LOA(req, 1); afb_req_context_set(req, ctxt, cbRemoveClientCtxt); } @@ -177,14 +179,15 @@ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const c } } else { - auto ip = client_list.find(std::string(appid)); + std::string id(appid); + auto ip = client_list.find(id); if(ip != client_list.end()) { ret = ip->second->handleRequest(request, verb); } else { if(!strcasecmp(verb, "subscribe")) { - appid2ctxt[appid] = createClientCtxt(request, appid); - HS_Client* client = addClient(request, appid); + appid2ctxt[id] = createClientCtxt(request, id); + HS_Client* client = addClient(request, id); ret = client->handleRequest(request, "subscribe"); } else { @@ -230,4 +233,4 @@ int HS_ClientManager::pushEvent(const char *event, struct json_object *param, st } return 0; -}
\ No newline at end of file +} diff --git a/src/hs-clientmanager.h b/src/hs-clientmanager.h index efc36de..7ca6411 100644 --- a/src/hs-clientmanager.h +++ b/src/hs-clientmanager.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * Copyright (C) 2020 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +25,13 @@ #include "hs-helper.h" #include "hs-client.h" -typedef struct HS_ClientCtxt -{ +struct HS_ClientCtxt { std::string id; - HS_ClientCtxt(const char *appid) + HS_ClientCtxt(const std::string &appid) { id = appid; } -} HS_ClientCtxt; +}; class HS_ClientManager { @@ -61,4 +61,4 @@ private: std::mutex mtx; }; -#endif // HOMESCREEN_CLIENTMANAGER_H
\ No newline at end of file +#endif // HOMESCREEN_CLIENTMANAGER_H |