aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-20 16:50:53 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-09-20 16:50:53 +0200
commit3465ddbdec8d77e2a59315e50f954ea2d35aa1cb (patch)
tree4c0ed65fb6c2b9dfb3d3285bbbf4ed3ee9b18728
parent9116b93f53127e48f3821497440500b6b78989c6 (diff)
Fix: No build error on input files checked
Output a warning if no checker found but at usage must crash the build if input files has errors. Change-Id: I282c4eb2303922ce1cd7055b51182ed222b62d08 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--cmake/cmake.d/02-variables.cmake2
-rw-r--r--cmake/cmake.d/03-macros.cmake68
2 files changed, 53 insertions, 17 deletions
diff --git a/cmake/cmake.d/02-variables.cmake b/cmake/cmake.d/02-variables.cmake
index 0532c33..a4634d4 100644
--- a/cmake/cmake.d/02-variables.cmake
+++ b/cmake/cmake.d/02-variables.cmake
@@ -141,4 +141,4 @@ set(GDB_INITIAL_BREAK "personality" CACHE STRING "Initial Break Point for GDB re
# Dummy checker about JSON.
set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
-set(JSON_CHECKER "echo" CACHE STRING "JSON linter")
+set(JSON_CHECKER "" CACHE STRING "JSON linter")
diff --git a/cmake/cmake.d/03-macros.cmake b/cmake/cmake.d/03-macros.cmake
index 8af81d6..fa4bd1f 100644
--- a/cmake/cmake.d/03-macros.cmake
+++ b/cmake/cmake.d/03-macros.cmake
@@ -127,16 +127,31 @@ macro(add_input_files INPUT_FILES)
set(ext_reg "xml$")
set(XML_LIST ${INPUT_FILES})
list_filter(XML_LIST ext_reg)
+ execute_process(
+ COMMAND which ${XML_CHECKER}
+ RESULT_VARIABLE XML_CHECKER_PRESENT
+ OUTPUT_QUIET ERROR_QUIET
+ )
endif()
if(NOT DEFINED LUA_LIST)
set(ext_reg "lua$")
set(LUA_LIST ${INPUT_FILES})
list_filter(LUA_LIST ext_reg)
+ execute_process(
+ COMMAND which ${LUA_CHECKER}
+ RESULT_VARIABLE LUA_CHECKER_PRESENT
+ OUTPUT_QUIET ERROR_QUIET
+ )
endif()
if(NOT DEFINED JSON_FILES)
set(ext_reg "json$")
set(JSON_LIST ${INPUT_FILES})
list_filter(JSON_LIST ext_reg)
+ execute_process(
+ COMMAND which ${JSON_CHECKER}
+ RESULT_VARIABLE JSON_CHECKER_PRESENT
+ OUTPUT_QUIET ERROR_QUIET
+ )
endif()
# These are v3.6 subcommand. Not used as default for now as
@@ -149,27 +164,48 @@ macro(add_input_files INPUT_FILES)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
)
- foreach(file ${XML_LIST})
+ if(XML_CHECKER_PRESENT EQUAL 0)
+ foreach(file ${XML_LIST})
+ add_custom_command(TARGET ${TARGET_NAME}
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${XML_CHECKER} ${file}
+ )
+ endforeach()
+ elseif(XML_LIST)
+ add_custom_command(TARGET ${TARGET_NAME}
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red "Warning: XML_CHECKER not found. Not verification made on files !")
+ endif()
+ if(LUA_CHECKER_PRESENT EQUAL 0)
+ foreach(file ${LUA_LIST})
add_custom_command(TARGET ${TARGET_NAME}
PRE_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND which ${XML_CHECKER} > /dev/null 2>&1 && ${XML_CHECKER} ${file} || ${CMAKE_COMMAND} -E cmake_echo_color --red "Warning: XML_CHECKER not found"
+ COMMAND ${LUA_CHECKER} ${file}
)
- endforeach()
- foreach(file ${LUA_LIST})
- add_custom_command(TARGET ${TARGET_NAME}
- PRE_BUILD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND which ${LUA_CHECKER} > /dev/null 2>&1 && ${LUA_CHECKER} ${file} || ${CMAKE_COMMAND} -E cmake_echo_color --red "Warning: LUA_CHECKER not found"
- )
- endforeach()
- foreach(file ${JSON_LIST})
+ endforeach()
+ elseif(LUA_LIST)
+ add_custom_command(TARGET ${TARGET_NAME}
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red "Warning: LUA_CHECKER not found. Not verification made on files !")
+ endif()
+ if(JSON_CHECKER_PRESENT EQUAL 0)
+ foreach(file ${JSON_LIST})
+ add_custom_command(TARGET ${TARGET_NAME}
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${JSON_CHECKER} ${file}
+ )
+ endforeach()
+ elseif(JSON_LIST)
add_custom_command(TARGET ${TARGET_NAME}
- PRE_BUILD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND which ${JSON_CHECKER} > /dev/null 2>&1 && ${JSON_CHECKER} ${file} || ${CMAKE_COMMAND} -E cmake_echo_color --red "Warning: JSON_CHECKER not found"
- )
- endforeach()
+ PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red "Warning: JSON_CHECKER not found. Not verification made on files !")
+ endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
DEPENDS ${INPUT_FILES}