From 1687531ccb8b38cfe4202ff023f94147cb815f7a Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 17 Nov 2017 16:24:40 +0100 Subject: Check version between app-templates and project. PROJECT_VERSION could be detected if project is located in AGL gerrit repo or with personal tags when in personal repository This version is checked against app-templates version which is aligned on AGL tags. A warning is displayed if app-templates version is outdated related to project_version. Also a "dirty" flag is appended to the project version if git repo isn't in sync with its remote counterpart. Then you could know if see an installed widget on a target that got that "-dirty" flag appended to the version that this widget include code that could not be merged in the git repository. Bug-AGL: SPEC-951 Change-Id: I99687560d19d746c887fc7a095e71407bda34325 Signed-off-by: Romain Forlot --- cmake/cmake.d/02-variables.cmake | 28 ++++++++++++++++++++++++++++ cmake/cmake.d/03-macros.cmake | 9 +++++++++ cmake/common.cmake | 1 + samples.d/config.cmake.sample | 1 - 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/cmake/cmake.d/02-variables.cmake b/cmake/cmake.d/02-variables.cmake index da6753a..ac5c05e 100644 --- a/cmake/cmake.d/02-variables.cmake +++ b/cmake/cmake.d/02-variables.cmake @@ -55,9 +55,37 @@ math(EXPR c "(${LINUX_VERSION_CODE} & 255)") set(KERNEL_VERSION "${a}.${b}.${c}") +# Setup project and app-templates version variables +execute_process(COMMAND git describe --abbrev=0 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_PROJECT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) +execute_process(COMMAND git describe --abbrev=0 + WORKING_DIRECTORY ${PKG_TEMPLATE_PREFIX} + OUTPUT_VARIABLE APP_TEMPLATES_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Detect unstaged or untracked changes +execute_process(COMMAND git status --short + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE DIRTY_FLAG + OUTPUT_STRIP_TRAILING_WHITESPACE +) + # Include project configuration # ------------------------------ +if(NOT DEFINED PROJECT_VERSION) + set(PROJECT_VERSION ${GIT_PROJECT_VERSION}) +endif() +# Release additionnals informations isn't supported so setting project +# attributes then add the dirty flag if git repo not sync'ed project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES}) +if(NOT ${DIRTY_FLAG}) +set(PROJECT_VERSION "${PROJECT_VERSION}-dirty") +endif() + set(PROJECT_LIBDIR "${CMAKE_SOURCE_DIR}/libs" CACHE PATH "Subpath to libraries") set(PROJECT_RESOURCES "${CMAKE_SOURCE_DIR}/data" CACHE PATH "Subpath to data") diff --git a/cmake/cmake.d/03-macros.cmake b/cmake/cmake.d/03-macros.cmake index e99208b..71907af 100644 --- a/cmake/cmake.d/03-macros.cmake +++ b/cmake/cmake.d/03-macros.cmake @@ -534,3 +534,12 @@ macro(project_closing_msg) ${PROJECT_TARGETS} populate) endif() endmacro() + +macro(check_version) + if(${GIT_PROJECT_VERSION} VERSION_GREATER ${APP_TEMPLATES_VERSION}) + message(STATUS "${Yellow}.. Your app-templates submodule version seems outdated. You should update it with 'git submodule update --remote ${PROJECT_APP_TEMPLATES_DIR}'. + - App-templates version: ${APP_TEMPLATES_VERSION} + - Project version according AGL Git tag: ${GIT_PROJECT_VERSION}" + ) + endif() +endmacro() diff --git a/cmake/common.cmake b/cmake/common.cmake index 191ef9e..c6853ea 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -87,6 +87,7 @@ configure_files_in_dir(${PROJECT_APP_TEMPLATES_DIR}/${ENTRY_POINT}/template.d) configure_files_in_dir($ENV{HOME}/.config/app-templates/scripts) configure_files_in_dir(/etc/app-templates/scripts) +check_version() project_targets_populate() remote_targets_populate() project_package_build() diff --git a/samples.d/config.cmake.sample b/samples.d/config.cmake.sample index 4b152cc..5c2b440 100644 --- a/samples.d/config.cmake.sample +++ b/samples.d/config.cmake.sample @@ -19,7 +19,6 @@ # Project Info # ------------------ set(PROJECT_NAME example) -set(PROJECT_VERSION "0.0") set(PROJECT_PRETTY_NAME "Example") set(PROJECT_DESCRIPTION "AGL application example") set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/apps/app-templates") -- cgit 1.2.3-korg