2014-12-12 18:20:34 -07:00
|
|
|
get_filename_component(LINT_DIR ${LINT_DIR} ABSOLUTE)
|
|
|
|
get_filename_component(LINT_PREFIX ${LINT_DIR} PATH)
|
2015-08-16 22:54:12 -07:00
|
|
|
set(LINT_SUPPRESS_FILE "${LINT_PREFIX}/errors.json")
|
|
|
|
|
2014-12-12 18:20:34 -07:00
|
|
|
file(GLOB_RECURSE LINT_FILES ${LINT_DIR}/*.c ${LINT_DIR}/*.h)
|
|
|
|
|
2015-08-16 22:54:12 -07:00
|
|
|
set(LINT_ARGS)
|
|
|
|
|
|
|
|
if(LINT_SUPPRESS_URL)
|
|
|
|
file(DOWNLOAD ${LINT_SUPPRESS_URL} ${LINT_SUPPRESS_FILE})
|
|
|
|
list(APPEND LINT_ARGS "--suppress-errors=${LINT_SUPPRESS_FILE}")
|
2014-12-12 18:20:34 -07:00
|
|
|
endif()
|
|
|
|
|
2015-08-16 22:54:12 -07:00
|
|
|
foreach(lint_file ${LINT_FILES})
|
|
|
|
file(RELATIVE_PATH lint_file "${LINT_PREFIX}" "${lint_file}")
|
|
|
|
list(APPEND LINT_ARGS "${lint_file}")
|
|
|
|
endforeach()
|
|
|
|
|
2014-12-12 18:20:34 -07:00
|
|
|
execute_process(
|
2015-08-16 22:54:12 -07:00
|
|
|
COMMAND ${LINT_PRG} ${LINT_ARGS}
|
|
|
|
RESULT_VARIABLE res
|
|
|
|
WORKING_DIRECTORY "${LINT_PREFIX}")
|
|
|
|
|
|
|
|
file(REMOVE ${LINT_SUPPRESS_FILE})
|
2014-12-12 18:20:34 -07:00
|
|
|
|
|
|
|
if(NOT res EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Linting failed: ${res}.")
|
|
|
|
endif()
|