From 474a2e91501c5620e2eef651c8305f2ae7aacd19 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 15 Aug 2017 19:03:55 +0200 Subject: [PATCH] Ease standard target DATA and HTDOCS creation This will create a custom target which make sure input files are correct (linting or compiling them) then copying them into the target build dir Change-Id: I1d346d4611a6d97682a00d2038de41a643b28928 Signed-off-by: Romain Forlot --- cmake/cmake.d/01-variables.cmake | 4 ++++ cmake/cmake.d/02-macros.cmake | 22 ++++++++++++++++++++++ samples.d/config.cmake.sample | 7 +++++++ 3 files changed, 33 insertions(+) diff --git a/cmake/cmake.d/01-variables.cmake b/cmake/cmake.d/01-variables.cmake index 867a723..a9fbc6e 100644 --- a/cmake/cmake.d/01-variables.cmake +++ b/cmake/cmake.d/01-variables.cmake @@ -147,3 +147,7 @@ endif() # Break After Binding are loaded but before they get initialised set(GDB_INITIAL_BREAK "personality" CACHE STRING "Initial Break Point for GDB remote") + +set(LUA_CHECKER "luac" CACHE STRING "LUA compiler") +set(XML_CHECKER "xmllint" CACHE STRING "XML linter") +set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter") diff --git a/cmake/cmake.d/02-macros.cmake b/cmake/cmake.d/02-macros.cmake index 3787817..3e4b919 100644 --- a/cmake/cmake.d/02-macros.cmake +++ b/cmake/cmake.d/02-macros.cmake @@ -48,6 +48,28 @@ macro(configure_files_in_dir dir) endforeach() endmacro(configure_files_in_dir) +# Create custom target dedicated for HTML5 and DATA AGL target type +macro(add_input_files INPUT_FILES) + add_custom_target(${TARGET_NAME} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + ) + + add_custom_command(TARGET ${TARGET_NAME} + PRE_BUILD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND [ -f *xml ] && ${XML_CHECKER} ${INPUT_FILES} + COMMAND [ -f *lua ] && ${LUA_CHECKER} ${INPUT_FILES} + COMMAND [ -f *json ] && for f in ${INPUT_FILES}; do cat ${INPUT_FILES} | ${JSON_CHECKER}; done + ) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + DEPENDS ${INPUT_FILES} + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + COMMAND cp -r ${INPUT_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME} + ) +endmacro() # Pre-packaging macro(project_targets_populate) # Default Widget default directory diff --git a/samples.d/config.cmake.sample b/samples.d/config.cmake.sample index f5ac42a..8ca0349 100644 --- a/samples.d/config.cmake.sample +++ b/samples.d/config.cmake.sample @@ -161,6 +161,13 @@ set(WIDGET_ENTRY_POINT EntryPoint_Path_Not_Set) #set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN") #set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN") +# Optional schema validator about now only XML, LUA and JSON +# are supported +#------------------------------------------------------------ +#set(LUA_CHECKER "luac" CACHE STRING "LUA compiler") +#set(XML_CHECKER "xmllint" CACHE STRING "XML linter") +#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter") + # This include is mandatory and MUST happens at the end # of this file, else you expose you to unexpected behavior # ----------------------------------------------------------- -- 2.16.6