2021-03-25 02:40:09 +03:00
|
|
|
# Copyright (C) 2018-2021 Intel Corporation
|
2019-04-12 18:25:53 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
file(REMOVE "${OUTPUT_FILE}")
|
|
|
|
|
|
2020-04-13 21:17:23 +03:00
|
|
|
set(DEFAULT_FILTER "
|
|
|
|
|
-build/header_guard,\
|
|
|
|
|
-build/include,\
|
|
|
|
|
-build/include_order,\
|
|
|
|
|
-build/include_subdir,\
|
|
|
|
|
-build/include_what_you_use,\
|
|
|
|
|
-build/namespaces,\
|
|
|
|
|
-build/c++11,\
|
|
|
|
|
-whitespace/indent,\
|
|
|
|
|
-whitespace/comments,\
|
|
|
|
|
-whitespace/ending_newline,\
|
|
|
|
|
-runtime/references,\
|
|
|
|
|
-runtime/int,\
|
|
|
|
|
-runtime/explicit,\
|
|
|
|
|
-readability/todo,\
|
|
|
|
|
-readability/fn_size,\
|
|
|
|
|
")
|
|
|
|
|
set(FILTER "${DEFAULT_FILTER}${CUSTOM_FILTER}")
|
|
|
|
|
|
2019-04-12 18:25:53 +03:00
|
|
|
execute_process(
|
|
|
|
|
COMMAND
|
2021-06-07 10:52:48 +03:00
|
|
|
"${PYTHON_EXECUTABLE}"
|
2019-04-12 18:25:53 +03:00
|
|
|
"${CPPLINT_SCRIPT}"
|
|
|
|
|
"--linelength=160"
|
|
|
|
|
"--counting=detailed"
|
2020-04-13 21:17:23 +03:00
|
|
|
"--quiet"
|
|
|
|
|
"--filter=${FILTER}"
|
2019-04-12 18:25:53 +03:00
|
|
|
"${INPUT_FILE}"
|
|
|
|
|
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
|
OUTPUT_VARIABLE output
|
|
|
|
|
ERROR_VARIABLE output)
|
|
|
|
|
|
|
|
|
|
# Store cpplint output to file (replace problematic symbols)
|
2020-04-13 21:17:23 +03:00
|
|
|
string(REPLACE "\"" ""\;" formatted_output "${output}")
|
|
|
|
|
string(REPLACE "<" "<\;" formatted_output "${formatted_output}")
|
|
|
|
|
string(REPLACE ">" ">\;" formatted_output "${formatted_output}")
|
|
|
|
|
string(REPLACE "'" "&apos\;" formatted_output "${formatted_output}")
|
|
|
|
|
string(REPLACE "&" "&\;" formatted_output "${formatted_output}")
|
|
|
|
|
file(WRITE "${OUTPUT_FILE}" "${formatted_output}")
|
2019-04-12 18:25:53 +03:00
|
|
|
|
|
|
|
|
if(NOT SKIP_RETURN_CODE)
|
|
|
|
|
# Pass through the cpplint return code
|
2020-04-27 21:21:29 +03:00
|
|
|
if(NOT result EQUAL "0")
|
2020-04-13 21:17:23 +03:00
|
|
|
# Display the cpplint output to console (to parse it form IDE)
|
|
|
|
|
message("${output}")
|
2019-04-12 18:25:53 +03:00
|
|
|
message(FATAL_ERROR "[cpplint] Code style check failed for : ${INPUT_FILE}")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|