From c0208be2fdd6d30d59b534b848c1f4ce39a764d5 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Wed, 27 May 2020 14:24:22 -0400 Subject: [PATCH] Update to use CMake app template Rework CMake files to actually use the CMake app template macros, with an update of the autobuild script to fix test widget building to match the state of the other bindings. Bug-AGL: SPEC-2049 Signed-off-by: Scott Murray Change-Id: I88c438ed4dafd631646769d7b6dc3debd1ccd6de --- CMakeLists.txt | 20 +-- autobuild/agl/autobuild | 3 +- conf.d/cmake/config.cmake | 207 ++++++++++++++++++++++++++++++ conf.d/wgt/config.xml.in | 23 ++++ conf.d/wgt/icon.svg | 283 ++++++++++++++++++++++++++++++++++++++++++ export.map | 1 - package/root/config.xml | 19 --- policy_manager/CMakeLists.txt | 10 +- src/CMakeLists.txt | 127 ++++++------------- 9 files changed, 564 insertions(+), 129 deletions(-) create mode 100644 conf.d/cmake/config.cmake create mode 100644 conf.d/wgt/config.xml.in create mode 100644 conf.d/wgt/icon.svg delete mode 100644 export.map delete mode 100644 package/root/config.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a69a43..98f77f4 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,24 +15,13 @@ # limitations under the License. # -cmake_minimum_required(VERSION 2.8) - project(WindowManagerTMC) -set(PACKAGE_VERSION_MAJOR 0) -set(PACKAGE_VERSION_MINOR 0) -set(PACKAGE_VERSION_REVISION 1) -set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_REVISION}") - -find_package(PkgConfig REQUIRED) -include(GNUInstallDirs) - -set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. 'address', 'thread', 'leak', 'undefined'), depends on compiler; default none") - -set(LINK_LIBCXX OFF CACHE BOOL "Link against LLVMs libc++") +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) # Add PolicyManager as plugin set(PLUGIN_PM policy_manager) -add_subdirectory(${PLUGIN_PM}) -add_subdirectory(src) +set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. 'address', 'thread', 'leak', 'undefined'), depends on compiler; default none") + +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/autobuild/agl/autobuild b/autobuild/agl/autobuild index 994ca4b..7816b3d 100755 --- a/autobuild/agl/autobuild +++ b/autobuild/agl/autobuild @@ -23,7 +23,7 @@ BUILD_DIR_DEBUG_TEST := $(abspath $(dir $(THISFILE))/../../build-debug-test) BUILD_DIR_COVERAGE_TEST := $(abspath $(dir $(THISFILE))/../../build-coverage-test) DEST := ${BUILD_DIR} -.PHONY: all clean distclean configure build package help update configure-debug configure-coverage build-test build-debug build-coverage package-test package-debug package-coverage package-debug package-debug-test package-coverage-test package-all +.PHONY: all clean distclean configure build package help update configure-debug configure-coverage build-debug build-coverage package-test package-debug package-coverage package-debug package-debug-test package-coverage-test package-all all: help help: @@ -95,6 +95,7 @@ package-test: build-test @mkdir -p ${BUILD_DIR_TEST}/$@/htdocs @mkdir -p ${BUILD_DIR_TEST}/$@/var @cmake --build ${BUILD_DIR_TEST} ${PACKAGE_ARGS} --target widget + @cmake --build ${BUILD_DIR_TEST} ${PACKAGE_ARGS} --target test_widget @if [ "${DEST}" != "${BUILD_DIR_TEST}" ]; then \ mkdir -p ${DEST} && cp ${BUILD_DIR_TEST}/*.wgt ${DEST}; \ fi diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake new file mode 100644 index 0000000..1f5a5f2 --- /dev/null +++ b/conf.d/cmake/config.cmake @@ -0,0 +1,207 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# Copyright (C) 2020 Konsulko Group +# +# author: Fulup Ar Foll +# +# 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. +########################################################################### + +# Project Info +# ------------------ +set(PROJECT_NAME "windowmanager-service") +set(API_NAME "windowmanager") +set(PROJECT_PRETTY_NAME "Window Manager") +set(PROJECT_DESCRIPTION "Window Manager Service") +set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/apps/agl-service-windowmanager") +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 "*") + +# Where are stored the project configuration files +# relative to the root project directory +set(PROJECT_CMAKE_CONF_DIR "conf.d") + +# Compilation Mode (DEBUG, RELEASE, COVERAGE or PROFILING) +# ---------------------------------- +set(BUILD_TYPE "RELEASE") +#set(USE_EFENCE 1) + +# Kernel selection if needed. You can choose between a +# mandatory version to impose a minimal version. +# Or check Kernel minimal version and just print a Warning +# about missing features and define a preprocessor variable +# to be used as preprocessor condition in code to disable +# incompatibles features. Preprocessor define is named +# KERNEL_MINIMAL_VERSION_OK. +# +# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and +# Yocto SDK Kernel version. +# ----------------------------------------------- +#set (kernel_mandatory_version 4.8) +#set (kernel_minimal_version 4.8) + +# Compiler selection if needed. Impose a minimal version. +# ----------------------------------------------- +set (gcc_minimal_version 4.9) + +# PKG_CONFIG required packages +# ----------------------------- +set (PKG_REQUIRED_LIST + json-c + afb-daemon + ilmControl + ilmCommon +) + +# You can also consider to include libsystemd +# ----------------------------------- +list (APPEND PKG_REQUIRED_LIST libsystemd>=222) + +# Prefix path where will be installed the files +# Default: /usr/local (need root permission to write in) +# ------------------------------------------------------ +#set(INSTALL_PREFIX /opt/AGL CACHE PATH "INSTALL PREFIX PATH") + +# Customize link option +# ----------------------------- +list (APPEND link_libraries -pthread) + +# Compilation options definition +# Use CMake generator expressions to specify only for a specific language +# Values are prefilled with default options that is currently used. +# Either separate options with ";", or each options must be quoted separately +# DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED ! +# ---------------------------------------------------------------------------- +#set(COMPILE_OPTIONS +# -Wall +# -Wextra +# -Wconversion +# -Wno-unused-parameter +# -Wno-sign-compare +# -Wno-sign-conversion +# -Werror=maybe-uninitialized +# -Werror=implicit-function-declaration +# -ffunction-sections +# -fdata-sections +# -fPIC +# CACHE STRING "Compilation flags") +#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.") +#set(CXX_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C++ language.") +#set(PROFILING_COMPILE_OPTIONS +# -g +# -O0 +# -pg +# -Wp,-U_FORTIFY_SOURCE +# CACHE STRING "Compilation flags for PROFILING build type.") +#set(DEBUG_COMPILE_OPTIONS +# -g +# -ggdb +# CACHE STRING "Compilation flags for DEBUG build type.") +#set(COVERAGE_COMPILE_OPTIONS +# -g +# -O0 +# --coverage +# CACHE STRING "Compilation flags for COVERAGE build type.") +#set(RELEASE_COMPILE_OPTIONS +# -O2 +# -pipe +# -D_FORTIFY_SOURCE=2 +# -fstack-protector-strong +# -Wformat -Wformat-security +# -Werror=format-security +# -feliminate-unused-debug-types +# -Wl,-O1 +# -Wl,--hash-style=gnu +# -Wl,--as-needed +# -fstack-protector-strong +# -Wl,-z,relro,-z,now +# CACHE STRING "Compilation flags for RELEASE build type.") + +# Location for config.xml.in template file. +# +# If you keep them commented then it will build with a default minimal widget +# template which is very simple and it is highly probable that it will not suit +# to your app. +# ----------------------------------------- +set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in) + +# Mandatory widget Mimetype specification of the main unit +# -------------------------------------------------------------------------- +# Choose between : +#- text/html : HTML application, +# content.src designates the home page of the application +# +#- application/vnd.agl.native : AGL compatible native, +# content.src designates the relative path of the binary. +# +# - application/vnd.agl.service: AGL service, content.src is not used. +# +#- ***application/x-executable***: Native application, +# content.src designates the relative path of the binary. +# For such application, only security setup is made. +# +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 lib/windowmanager-service.so) + +# Optional dependencies order +# --------------------------- +#set(EXTRA_DEPENDENCIES_ORDER) + +# Optional Extra global include path +# ----------------------------------- +#set(EXTRA_INCLUDE_DIRS) + +# Optional extra libraries +# ------------------------- +#set(EXTRA_LINK_LIBRARIES) + +# Optional force binding Linking flag +# ------------------------------------ +# set(BINDINGS_LINK_FLAG LinkOptions ) + +# Optional force package prefix generation, like widget +# ----------------------------------------------------- +# set(PKG_PREFIX DestinationPath) + +# Optional Application Framework security token +# and port use for remote debugging. +#------------------------------------------------------------ +set(AFB_TOKEN "" CACHE PATH "Default binder security token") +set(AFB_REMPORT "1234" CACHE PATH "Default binder listening port") + +# Print a helper message when every thing is finished +# ---------------------------------------------------- +set(CLOSING_MESSAGE "Typical binding launch: cd ${CMAKE_BINARY_DIR}/package \\&\\& afb-daemon --port=${AFB_REMPORT} --workdir=. --ldpaths=lib --roothttp=htdocs --token=\"${AFB_TOKEN}\" --tracereq=common --verbose") +set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") + +# Optional schema validator about now only XML, LUA and JSON +# are supported +#------------------------------------------------------------ +#set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler") +#set(XML_CHECKER "xmllint" CACHE STRING "XML linter") +#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter") + +include(CMakeAfbTemplates) diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in new file mode 100644 index 0000000..1c5c24b --- /dev/null +++ b/conf.d/wgt/config.xml.in @@ -0,0 +1,23 @@ + + + @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/export.map b/export.map deleted file mode 100644 index ee2f413..0000000 --- a/export.map +++ /dev/null @@ -1 +0,0 @@ -{ global: afbBindingV*; local: *; }; diff --git a/package/root/config.xml b/package/root/config.xml deleted file mode 100644 index 375dc54..0000000 --- a/package/root/config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - windowmanager-service - - Window Manager - TOYOTA - APL 2.0 - - - - - - - - - - - - diff --git a/policy_manager/CMakeLists.txt b/policy_manager/CMakeLists.txt index 3ec4c39..77ddd36 100644 --- a/policy_manager/CMakeLists.txt +++ b/policy_manager/CMakeLists.txt @@ -96,9 +96,9 @@ if (LINK_LIBCXX) endif() add_custom_command(TARGET ${TARGETS_PM} POST_BUILD - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib - COMMAND cp -f ${PROJECT_BINARY_DIR}/${PLUGIN_PM}/lib${PLUGIN_PM}.so ${PROJECT_BINARY_DIR}/package/root/lib - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/etc - COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/states.db ${PROJECT_BINARY_DIR}/package/root/etc - COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/${ROLES_DB_NAME} ${PROJECT_BINARY_DIR}/package/root/etc/roles.db + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/lib + COMMAND cp -f ${PROJECT_BINARY_DIR}/${PLUGIN_PM}/lib${PLUGIN_PM}.so ${PROJECT_BINARY_DIR}/package/lib + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/etc + COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/states.db ${PROJECT_BINARY_DIR}/package/etc + COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/${ROLES_DB_NAME} ${PROJECT_BINARY_DIR}/package/etc/roles.db ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1449da0..d35c17e 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,68 +15,38 @@ # limitations under the License. # -include(FindPkgConfig) -pkg_check_modules(AFB REQUIRED afb-daemon) -pkg_check_modules(ILM REQUIRED ilmControl ilmCommon) -pkg_check_modules(SD REQUIRED libsystemd>=222) - -# We do not want a prefix for our module -set(CMAKE_SHARED_MODULE_PREFIX "") - -set(TARGETS_WM windowmanager-service) - -add_library(${TARGETS_WM} MODULE - main.cpp - util.cpp - json_helper.cpp - applist.cpp - request.cpp - pm_wrapper.cpp - window_manager.cpp - wm_client.cpp - wm_error.cpp - wm_layer.cpp - wm_layer_control.cpp) - -target_include_directories(${TARGETS_WM} - PRIVATE - ${AFB_INCLUDE_DIRS} - ${SD_INCLUDE_DIRS} - ${ILM_INCLUDE_DIRS} - ../include - ../src - ../${PLUGIN_PM}) - -target_link_libraries(${TARGETS_WM} - PRIVATE - ${AFB_LIBRARIES} - ${WLC_LIBRARIES} - ${ILM_LIBRARIES} - ${SD_LIBRARIES} - ${PLUGIN_PM}) - -target_compile_definitions(${TARGETS_WM} - PRIVATE +PROJECT_TARGET_ADD(windowmanager-service) + +# Define project Targets +add_library(${TARGET_NAME} MODULE + main.cpp + util.cpp + json_helper.cpp + applist.cpp + request.cpp + pm_wrapper.cpp + window_manager.cpp + wm_client.cpp + wm_error.cpp + wm_layer.cpp + wm_layer_control.cpp) + +target_include_directories(${TARGET_NAME} PRIVATE + ../${PLUGIN_PM}) + +target_compile_definitions(${TARGET_NAME} PRIVATE AFB_BINDING_VERSION=3 # We do not want source location of messages AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS - WINMAN_VERSION_STRING="${PACKAGE_VERSION}" - _GNU_SOURCE) - -if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release") - target_compile_definitions(${TARGETS_WM} - PRIVATE - _GLIBCXX_DEBUG) -endif() + WINMAN_VERSION_STRING="${PACKAGE_VERSION}") -target_compile_options(${TARGETS_WM} - PRIVATE - -Wall -Wextra -Wno-unused-parameter -Wno-comment -Wno-missing-field-initializers) - -set_target_properties(${TARGETS_WM} - PROPERTIES - # INTERPROCEDURAL_OPTIMIZATION ON +set_target_properties(${TARGET_NAME} PROPERTIES + LABELS "BINDING" + PREFIX "" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${TARGET_NAME} + # INTERPROCEDURAL_OPTIMIZATION ON CXX_EXTENSIONS OFF CXX_STANDARD 14 CXX_STANDARD_REQUIRED ON @@ -83,43 +54,23 @@ set_target_properties(${TARGETS_WM} C_EXTENSIONS OFF C_STANDARD 99 C_STANDARD_REQUIRED ON +) - LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map -Wl,-rpath,'$ORIGIN'") +target_link_libraries(${TARGET_NAME} PRIVATE ${PLUGIN_PM}) -if (LINK_LIBCXX) - set_target_properties(${TARGETS_WM} - PROPERTIES - LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map -lc++ -Wl,-rpath,'$ORIGIN'") -endif() +target_link_options(${TARGET_NAME} PRIVATE "-Wl,-rpath,'$ORIGIN'") if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "") - target_compile_options(${TARGETS_WM} - PRIVATE - -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer) - set_target_properties(${TARGETS_WM} - PROPERTIES - LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g") + target_compile_options(${TARGET_NAME} PRIVATE + -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer) + set_target_properties(${TARGET_NAME} PROPERTIES + LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g") endif() -if(NOT EXISTS ${PROJECT_BINARY_DIR}/package) - add_custom_command(TARGET ${TARGETS_WM} POST_BUILD - COMMAND cp -rf ${PROJECT_SOURCE_DIR}/package ${PROJECT_BINARY_DIR} - ) -endif() - -add_custom_command(TARGET ${TARGETS_WM} POST_BUILD - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib - COMMAND cp -rf ${PROJECT_BINARY_DIR}/src/${TARGETS_WM}.so ${PROJECT_BINARY_DIR}/package/root/lib - COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/etc - COMMAND cp -f ${CMAKE_SOURCE_DIR}/conf/layers.json ${PROJECT_BINARY_DIR}/package/root/etc - COMMAND cp -f ${CMAKE_SOURCE_DIR}/conf/areas.json ${PROJECT_BINARY_DIR}/package/root/etc +add_custom_command(TARGET ${TARGET_NAME} POST_BUILD + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/etc + COMMAND cp -f ${CMAKE_SOURCE_DIR}/conf/layers.json ${PROJECT_BINARY_DIR}/package/etc + COMMAND cp -f ${CMAKE_SOURCE_DIR}/conf/areas.json ${PROJECT_BINARY_DIR}/package/etc ) -add_custom_target(package DEPENDS ${PROJECT_BINARY_DIR}/package/root - COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/${TARGETS_WM}.wgt ${PROJECT_BINARY_DIR}/package/root -) -add_custom_target(widget DEPENDS ${PROJECT_BINARY_DIR}/package/${TARGETS_WM}.wgt - COMMAND cp -f ${PROJECT_BINARY_DIR}/package/${TARGETS_WM}.wgt ${PROJECT_BINARY_DIR}/${TARGETS_WM}.wgt -) -add_dependencies(widget package) -- 2.16.6