From 89edd734c0a347dafceba1cef1ac835e0fe61e1a Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Tue, 26 May 2020 17:49:50 -0400 Subject: 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 Change-Id: I3741e6a307297272d5c22e894dfa9ff8b0dd1f52 --- CMakeLists.txt | 3 + conf.d/cmake/config.cmake | 42 +++---- conf.d/wgt/config.xml.in | 32 ++++++ conf.d/wgt/icon.svg | 283 ++++++++++++++++++++++++++++++++++++++++++++++ package/root/config.xml | 27 ----- package/root/icon.svg | 283 ---------------------------------------------- src/CMakeLists.txt | 67 +++-------- src/export.map | 1 - src/hs-clientmanager.cpp | 13 ++- src/hs-clientmanager.h | 10 +- 10 files changed, 365 insertions(+), 396 deletions(-) create mode 100644 conf.d/wgt/config.xml.in create mode 100644 conf.d/wgt/icon.svg delete mode 100644 package/root/config.xml delete mode 100644 package/root/icon.svg delete mode 100644 src/export.map 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 # @@ -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 @@ + + + @PROJECT_NAME@ + + + @PROJECT_DESCRIPTION@ + @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@> + @PROJECT_LICENSE@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf.d/wgt/icon.svg b/conf.d/wgt/icon.svg new file mode 100644 index 0000000..6628784 --- /dev/null +++ b/conf.d/wgt/icon.svg @@ -0,0 +1,283 @@ + + + +image/svg+xmlSETTINGS + \ No newline at end of file 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 @@ - - - homescreen-service - - - HomeScreen Binding service - TOYOTA - APL 2.0 - - - - - - - - - - - - - - - - - - - diff --git a/package/root/icon.svg b/package/root/icon.svg deleted file mode 100644 index 6628784..0000000 --- a/package/root/icon.svg +++ /dev/null @@ -1,283 +0,0 @@ - - - -image/svg+xmlSETTINGS - \ No newline at end of file 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 -- cgit 1.2.3-korg