From e1ef035594fc80baaf5cd571ab4d04023309a906 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 10 Aug 2017 18:25:48 +0200 Subject: [PATCH] Extending pluggable arch for templates Idea is to be able to use custom templates from home dir and system dir Change-Id: I74b48458f3dcc26b49f8144e042c213691028167 Signed-off-by: Romain Forlot --- cmake/cmake.d/01-variables.cmake | 9 ++--- cmake/cmake.d/02-macros.cmake | 22 ++++++------ cmake/cmake.d/03-extra_targets.cmake | 40 +++++++++++----------- {cmake => samples.d}/CMakeLists.txt.sample | 0 {cmake => samples.d}/config.cmake.sample | 0 {wgt => samples.d}/config.xml.in.sample | 0 {xds => samples.d}/xds-config.env.sample | 0 .../autobuild}/agl/autobuild.in | 0 .../autobuild}/linux/autobuild.in | 0 {wgt => template.d}/config.xml.in | 0 {deb => template.d}/deb-config.dsc.in | 0 {deb => template.d}/deb-config.install.in | 0 {deb => template.d}/debian.changelog.in | 0 {deb => template.d}/debian.compat.in | 0 {deb => template.d}/debian.control.in | 0 {deb => template.d}/debian.rules.in | 0 {gdb => template.d}/gdb-native-target.ini.in | 0 {wgt => template.d}/install-wgt-on-target.sh.in | 0 {rpm => template.d}/rpm-config.spec.in | 0 {ssh => template.d}/start-on-target.sh.in | 0 20 files changed, 34 insertions(+), 37 deletions(-) rename {cmake => samples.d}/CMakeLists.txt.sample (100%) rename {cmake => samples.d}/config.cmake.sample (100%) rename {wgt => samples.d}/config.xml.in.sample (100%) rename {xds => samples.d}/xds-config.env.sample (100%) rename {autobuild => template.d/autobuild}/agl/autobuild.in (100%) rename {autobuild => template.d/autobuild}/linux/autobuild.in (100%) rename {wgt => template.d}/config.xml.in (100%) rename {deb => template.d}/deb-config.dsc.in (100%) rename {deb => template.d}/deb-config.install.in (100%) rename {deb => template.d}/debian.changelog.in (100%) rename {deb => template.d}/debian.compat.in (100%) rename {deb => template.d}/debian.control.in (100%) rename {deb => template.d}/debian.rules.in (100%) rename {gdb => template.d}/gdb-native-target.ini.in (100%) rename {wgt => template.d}/install-wgt-on-target.sh.in (100%) rename {rpm => template.d}/rpm-config.spec.in (100%) rename {ssh => template.d}/start-on-target.sh.in (100%) diff --git a/cmake/cmake.d/01-variables.cmake b/cmake/cmake.d/01-variables.cmake index 5118b57..867a723 100644 --- a/cmake/cmake.d/01-variables.cmake +++ b/cmake/cmake.d/01-variables.cmake @@ -116,14 +116,11 @@ endif() # Paths to templates files set (PKG_TEMPLATE_PREFIX ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR} CACHE PATH "Default Package Templates Directory") -set(SSH_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/ssh" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes") -set(GDB_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/gdb" CACHE PATH "Subpath to a directory where are stored needed files to launch debuging server on a remote target. Use gdbserver.") -set(WGT_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/wgt" CACHE PATH "Subpath to a directory where are stored needed files to build widget") +set(TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/cmake/template.d" CACHE PATH "Subpath to a directory where are stored needed files to launch on remote target to debuging purposes") + if(NOT WIDGET_CONFIG_TEMPLATE) - set(WIDGET_CONFIG_TEMPLATE ${WGT_TEMPLATE_DIR}/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)") + set(WIDGET_CONFIG_TEMPLATE ${TEMPLATE_DIR}/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)") endif() -set(RPM_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/rpm" CACHE PATH "Subpath to a directory where are stored needed files to build rpm package") -set(DEB_TEMPLATE_DIR "${PKG_TEMPLATE_PREFIX}/deb" CACHE PATH "Subpath to a directory where are stored needed files to build deb package") string(REGEX REPLACE "^(.*)/.*$" "\\1" ENTRY_POINT "${PKG_TEMPLATE_PREFIX}") set(PROJECT_PKG_ENTRY_POINT ${ENTRY_POINT}/packaging CACHE PATH "Where package build files, like rpm.spec file or config.xml, are write.") diff --git a/cmake/cmake.d/02-macros.cmake b/cmake/cmake.d/02-macros.cmake index e116d2e..3787817 100644 --- a/cmake/cmake.d/02-macros.cmake +++ b/cmake/cmake.d/02-macros.cmake @@ -185,8 +185,8 @@ macro(remote_targets_populate) endif() endif() - configure_files_in_dir(${SSH_TEMPLATE_DIR}) - configure_files_in_dir(${GDB_TEMPLATE_DIR}) + configure_files_in_dir(${TEMPLATE_DIR}) + configure_files_in_dir(${TEMPLATE_DIR}) add_custom_target(remote-target-populate COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/target/*.sh @@ -201,8 +201,8 @@ macro(wgt_package_build) if(NOT EXISTS ${WIDGET_CONFIG_TEMPLATE}) MESSAGE(FATAL_ERROR "${Red}WARNING ! Missing mandatory files to build widget file.\nYou need a config.xml template: please specify WIDGET_CONFIG_TEMPLATE correctly.${ColourReset}") endif() - if(NOT EXISTS ${WGT_TEMPLATE_DIR}/icon-default.png) - MESSAGE(FATAL_ERROR "${Red}WARNING ! Missing mandatory files to build widget file.\nYou need ${PROJECT_ICON} file in ${WGT_TEMPLATE_DIR} folder.${ColourReset}") + if(NOT EXISTS ${TEMPLATE_DIR}/icon-default.png) + MESSAGE(FATAL_ERROR "${Red}WARNING ! Missing mandatory files to build widget file.\nYou need ${PROJECT_ICON} file in ${TEMPLATE_DIR} folder.${ColourReset}") endif() if(NOT WIDGET_TYPE) MESSAGE(FATAL_ERROR "WIDGET_TYPE must be set in your config.cmake.\neg.: set(WIDGET_TYPE application/vnd.agl.service)") @@ -214,15 +214,15 @@ macro(wgt_package_build) add_custom_command(OUTPUT ${PROJECT_PKG_BUILD_DIR}/config.xml COMMAND ${CMAKE_COMMAND} -DINFILE=${WIDGET_CONFIG_TEMPLATE} -DOUTFILE=${PROJECT_PKG_BUILD_DIR}/config.xml -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND cp ${WGT_TEMPLATE_DIR}/icon-default.png ${PROJECT_PKG_BUILD_DIR}/${PROJECT_ICON} + COMMAND cp ${TEMPLATE_DIR}/icon-default.png ${PROJECT_PKG_BUILD_DIR}/${PROJECT_ICON} ) add_custom_target(packaging_wgt DEPENDS ${PROJECT_PKG_BUILD_DIR}/config.xml) # Fulup ??? copy any extra file in wgt/etc into populate package before building the widget - file(GLOB PROJECT_CONF_FILES "${WGT_TEMPLATE_DIR}/etc/*") + file(GLOB PROJECT_CONF_FILES "${TEMPLATE_DIR}/etc/*") if(${PROJECT_CONF_FILES}) - file(COPY "${WGT_TEMPLATE_DIR}/etc/*" DESTINATION ${PROJECT_PKG_BUILD_DIR}/etc/) + file(COPY "${TEMPLATE_DIR}/etc/*" DESTINATION ${PROJECT_PKG_BUILD_DIR}/etc/) endif(${PROJECT_CONF_FILES}) add_custom_command(OUTPUT ${PROJECT_NAME}.wgt @@ -241,7 +241,7 @@ macro(wgt_package_build) COMMAND exit -1 ) else() - configure_files_in_dir(${WGT_TEMPLATE_DIR}) + configure_files_in_dir(${TEMPLATE_DIR}) add_custom_target(widget-target-install DEPENDS widget COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/target/install-wgt-on-${RSYNC_TARGET}.sh @@ -279,15 +279,15 @@ macro(deb_package_build) endmacro(deb_package_build) macro(project_package_build) - if(EXISTS ${RPM_TEMPLATE_DIR}) + if(EXISTS ${TEMPLATE_DIR}) rpm_package_build() endif() - if(EXISTS ${WGT_TEMPLATE_DIR}) + if(EXISTS ${TEMPLATE_DIR}) wgt_package_build() endif() - if(EXISTS ${DEB_TEMPLATE_DIR}) + if(EXISTS ${TEMPLATE_DIR}) deb_package_build() endif() endmacro(project_package_build) diff --git a/cmake/cmake.d/03-extra_targets.cmake b/cmake/cmake.d/03-extra_targets.cmake index 61f5adb..2c635db 100644 --- a/cmake/cmake.d/03-extra_targets.cmake +++ b/cmake/cmake.d/03-extra_targets.cmake @@ -93,8 +93,8 @@ foreach (PKG_CONFIG ${PKG_REQUIRED_LIST}) endif() endforeach() -if(NOT EXISTS ${RPM_TEMPLATE_DIR}/rpm-config.spec.in) - MESSAGE(FATAL_ERROR "${Red}Missing mandatory files: you need rpm-config.spec.in in ${RPM_TEMPLATE_DIR} folder.${ColourReset}") +if(NOT EXISTS ${TEMPLATE_DIR}/rpm-config.spec.in) + MESSAGE(FATAL_ERROR "${Red}Missing mandatory files: you need rpm-config.spec.in in ${TEMPLATE_DIR} folder.${ColourReset}") endif() # Because the tool "dpkg" is used on the packages db to find the @@ -102,25 +102,25 @@ endif() # to test the OS release package type # Only doable within a native environment not under SDK if(OSRELEASE MATCHES "debian" AND NOT DEFINED ENV{SDKTARGETSYSROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - add_custom_target(packaging_deb DEPENDS ${DEB_TEMPLATE_DIR}/debian.compat.in - ${DEB_TEMPLATE_DIR}/debian.changelog.in - ${DEB_TEMPLATE_DIR}/deb-config.dsc.in - ${DEB_TEMPLATE_DIR}/deb-config.install.in - ${DEB_TEMPLATE_DIR}/debian.control.in - ${DEB_TEMPLATE_DIR}/debian.rules.in - COMMAND ${CMAKE_COMMAND} -DINFILE=${DEB_TEMPLATE_DIR}/debian.compat.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_COMPAT} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${DEB_TEMPLATE_DIR}/debian.changelog.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_CHANGELOG} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${DEB_TEMPLATE_DIR}/deb-config.dsc.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_DSC} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${DEB_TEMPLATE_DIR}/deb-config.install.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_INSTALL} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${DEB_TEMPLATE_DIR}/debian.control.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_CONTROL} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${DEB_TEMPLATE_DIR}/debian.rules.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_RULES} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + add_custom_target(packaging_deb DEPENDS ${TEMPLATE_DIR}/debian.compat.in + ${TEMPLATE_DIR}/debian.changelog.in + ${TEMPLATE_DIR}/deb-config.dsc.in + ${TEMPLATE_DIR}/deb-config.install.in + ${TEMPLATE_DIR}/debian.control.in + ${TEMPLATE_DIR}/debian.rules.in + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/debian.compat.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_COMPAT} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/debian.changelog.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_CHANGELOG} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/deb-config.dsc.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_DSC} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/deb-config.install.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_INSTALL} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/debian.control.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_CONTROL} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/debian.rules.in -DOUTFILE=${PACKAGING_DEB_OUTPUT_RULES} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake ) endif() add_custom_target(packaging) set(PACKAGING_SPEC_OUTPUT ${PROJECT_PKG_ENTRY_POINT}/${NPKG_PROJECT_NAME}.spec) -add_custom_target(packaging_rpm DEPENDS ${RPM_TEMPLATE_DIR}/rpm-config.spec.in - COMMAND ${CMAKE_COMMAND} -DINFILE=${RPM_TEMPLATE_DIR}/rpm-config.spec.in -DOUTFILE=${PACKAGING_SPEC_OUTPUT} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake +add_custom_target(packaging_rpm DEPENDS ${TEMPLATE_DIR}/rpm-config.spec.in + COMMAND ${CMAKE_COMMAND} -DINFILE=${TEMPLATE_DIR}/rpm-config.spec.in -DOUTFILE=${PACKAGING_SPEC_OUTPUT} -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake ) add_dependencies(packaging packaging_rpm) if(TARGET packaging_wgt) @@ -152,8 +152,8 @@ endforeach() # Autobuild target # ---------------------------------------------------------------------------- -add_custom_target(autobuild ALL DEPENDS ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in - ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/linux/autobuild.in - COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake - COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake +add_custom_target(autobuild ALL DEPENDS ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/template.d/autobuild/agl/autobuild.in + ${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/template.d/autobuild/linux/autobuild.in + COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/template.d/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_AGL_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake + COMMAND ${CMAKE_COMMAND} -DINFILE=${CMAKE_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/template.d/autobuild/agl/autobuild.in -DOUTFILE=${PROJECT_TEMPLATE_LINUX_AUTOBUILD_DIR}/autobuild -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_APP_TEMPLATES_DIR}/cmake/configure_file.cmake ) diff --git a/cmake/CMakeLists.txt.sample b/samples.d/CMakeLists.txt.sample similarity index 100% rename from cmake/CMakeLists.txt.sample rename to samples.d/CMakeLists.txt.sample diff --git a/cmake/config.cmake.sample b/samples.d/config.cmake.sample similarity index 100% rename from cmake/config.cmake.sample rename to samples.d/config.cmake.sample diff --git a/wgt/config.xml.in.sample b/samples.d/config.xml.in.sample similarity index 100% rename from wgt/config.xml.in.sample rename to samples.d/config.xml.in.sample diff --git a/xds/xds-config.env.sample b/samples.d/xds-config.env.sample similarity index 100% rename from xds/xds-config.env.sample rename to samples.d/xds-config.env.sample diff --git a/autobuild/agl/autobuild.in b/template.d/autobuild/agl/autobuild.in similarity index 100% rename from autobuild/agl/autobuild.in rename to template.d/autobuild/agl/autobuild.in diff --git a/autobuild/linux/autobuild.in b/template.d/autobuild/linux/autobuild.in similarity index 100% rename from autobuild/linux/autobuild.in rename to template.d/autobuild/linux/autobuild.in diff --git a/wgt/config.xml.in b/template.d/config.xml.in similarity index 100% rename from wgt/config.xml.in rename to template.d/config.xml.in diff --git a/deb/deb-config.dsc.in b/template.d/deb-config.dsc.in similarity index 100% rename from deb/deb-config.dsc.in rename to template.d/deb-config.dsc.in diff --git a/deb/deb-config.install.in b/template.d/deb-config.install.in similarity index 100% rename from deb/deb-config.install.in rename to template.d/deb-config.install.in diff --git a/deb/debian.changelog.in b/template.d/debian.changelog.in similarity index 100% rename from deb/debian.changelog.in rename to template.d/debian.changelog.in diff --git a/deb/debian.compat.in b/template.d/debian.compat.in similarity index 100% rename from deb/debian.compat.in rename to template.d/debian.compat.in diff --git a/deb/debian.control.in b/template.d/debian.control.in similarity index 100% rename from deb/debian.control.in rename to template.d/debian.control.in diff --git a/deb/debian.rules.in b/template.d/debian.rules.in similarity index 100% rename from deb/debian.rules.in rename to template.d/debian.rules.in diff --git a/gdb/gdb-native-target.ini.in b/template.d/gdb-native-target.ini.in similarity index 100% rename from gdb/gdb-native-target.ini.in rename to template.d/gdb-native-target.ini.in diff --git a/wgt/install-wgt-on-target.sh.in b/template.d/install-wgt-on-target.sh.in similarity index 100% rename from wgt/install-wgt-on-target.sh.in rename to template.d/install-wgt-on-target.sh.in diff --git a/rpm/rpm-config.spec.in b/template.d/rpm-config.spec.in similarity index 100% rename from rpm/rpm-config.spec.in rename to template.d/rpm-config.spec.in diff --git a/ssh/start-on-target.sh.in b/template.d/start-on-target.sh.in similarity index 100% rename from ssh/start-on-target.sh.in rename to template.d/start-on-target.sh.in -- 2.16.6