Moved code style cmake scripts to a common place (#3228)

This commit is contained in:
Ilya Lavrenov authored and GitHub committed 2020-11-26 15:38:55 +03:00
1 parent 92e3972853
commit 6f2bca0000
14 files changed
+32 -119

No files matched your search

@@ -76,10 +76,10 @@ function(add_clang_format_target TARGET_NAME)
-D "CLANG_FORMAT=${CLANG_FORMAT}"
-D "INPUT_FILE=${source_file}"
-D "OUTPUT_FILE=${output_file}"
-P "${IE_MAIN_SOURCE_DIR}/cmake/clang_format_check.cmake"
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/clang_format/clang_format_check.cmake"
DEPENDS
"${source_file}"
"${IE_MAIN_SOURCE_DIR}/cmake/clang_format_check.cmake"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/clang_format/clang_format_check.cmake"
COMMENT
"[clang-format] ${source_file}"
VERBATIM)
@@ -102,10 +102,10 @@ function(add_clang_format_target TARGET_NAME)
-D "CLANG_FORMAT=${CLANG_FORMAT}"
-D "INPUT_FILES=${CLANG_FORMAT_FOR_SOURCES}"
-D "EXCLUDE_PATTERNS=${CLANG_FORMAT_EXCLUDE_PATTERNS}"
-P "${IE_MAIN_SOURCE_DIR}/cmake/clang_format_fix.cmake"
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/clang_format/clang_format_fix.cmake"
DEPENDS
"${CLANG_FORMAT_FOR_SOURCES}"
"${IE_MAIN_SOURCE_DIR}/cmake/clang_format_fix.cmake"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/clang_format/clang_format_fix.cmake"
COMMENT
"[clang-format] ${TARGET_NAME}_fix"
VERBATIM)
@@ -68,17 +68,17 @@ function(add_cpplint_target TARGET_NAME)
"${output_file}"
COMMAND
"${CMAKE_COMMAND}"
-D "CPPLINT_SCRIPT=${IE_MAIN_SOURCE_DIR}/scripts/cpplint.py"
-D "CPPLINT_SCRIPT=${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint.py"
-D "INPUT_FILE=${source_file}"
-D "OUTPUT_FILE=${output_file}"
-D "WORKING_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}"
-D "SKIP_RETURN_CODE=${ENABLE_CPPLINT_REPORT}"
-D "CUSTOM_FILTER=${custom_filter}"
-P "${IE_MAIN_SOURCE_DIR}/cmake/cpplint_run.cmake"
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_run.cmake"
DEPENDS
"${source_file}"
"${IE_MAIN_SOURCE_DIR}/scripts/cpplint.py"
"${IE_MAIN_SOURCE_DIR}/cmake/cpplint_run.cmake"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint.py"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_run.cmake"
COMMENT
"[cpplint] ${source_file}"
VERBATIM)
@@ -118,10 +118,10 @@ function(add_cpplint_report_target)
"${CMAKE_COMMAND}"
-D "FINAL_OUTPUT_FILE=${cpplint_output_file}"
-D "OUTPUT_FILES=${CPPLINT_ALL_OUTPUT_FILES}"
-P "${IE_MAIN_SOURCE_DIR}/cmake/cpplint_merge.cmake"
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_merge.cmake"
DEPENDS
${CPPLINT_ALL_OUTPUT_FILES}
"${IE_MAIN_SOURCE_DIR}/cmake/cpplint_merge.cmake"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_merge.cmake"
COMMENT
"[cpplint] Merge all output files"
VERBATIM)
@@ -133,19 +133,19 @@ function(add_cpplint_report_target)
COMMAND
"${CMAKE_COMMAND}"
-D "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
-D "CONVERT_SCRIPT=${IE_MAIN_SOURCE_DIR}/scripts/cpplint_to_cppcheckxml.py"
-D "CONVERT_SCRIPT=${OpenVINO_MAIN_SOURCE_DIR}/scripts/cpplint_to_cppcheckxml.py"
-D "INPUT_FILE=${cpplint_output_file}"
-D "OUTPUT_FILE=${cppcheck_output_file}"
-P "${IE_MAIN_SOURCE_DIR}/cmake/cpplint_to_cppcheck_xml.cmake"
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_to_cppcheck_xml.cmake"
DEPENDS
"${cpplint_output_file}"
"${IE_MAIN_SOURCE_DIR}/scripts/cpplint_to_cppcheckxml.py"
"${IE_MAIN_SOURCE_DIR}/cmake/cpplint_to_cppcheck_xml.cmake"
"${OpenVINO_MAIN_SOURCE_DIR}/scripts/cpplint_to_cppcheckxml.py"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_to_cppcheck_xml.cmake"
COMMENT
"[cpplint] Convert to cppcheck XML format"
VERBATIM)
set(report_dir "${IE_MAIN_SOURCE_DIR}/report/cpplint")
set(report_dir "${OpenVINO_MAIN_SOURCE_DIR}/report/cpplint")
set(html_output_file "${report_dir}/index.html")
add_custom_command(
OUTPUT
@@ -153,16 +153,16 @@ function(add_cpplint_report_target)
COMMAND
"${CMAKE_COMMAND}"
-D "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
-D "CONVERT_SCRIPT=${IE_MAIN_SOURCE_DIR}/scripts/cppcheck-htmlreport.py"
-D "CONVERT_SCRIPT=${OpenVINO_MAIN_SOURCE_DIR}/scripts/cppcheck-htmlreport.py"
-D "INPUT_FILE=${cppcheck_output_file}"
-D "REPORT_DIR=${report_dir}"
-D "SOURCE_DIR=${IE_MAIN_SOURCE_DIR}"
-D "SOURCE_DIR=${OpenVINO_MAIN_SOURCE_DIR}"
-D "TITLE=${CMAKE_PROJECT_NAME}"
-P "${IE_MAIN_SOURCE_DIR}/cmake/cpplint_html.cmake"
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_html.cmake"
DEPENDS
"${cppcheck_output_file}"
"${IE_MAIN_SOURCE_DIR}/scripts/cppcheck-htmlreport.py"
"${IE_MAIN_SOURCE_DIR}/cmake/cpplint_html.cmake"
"${OpenVINO_MAIN_SOURCE_DIR}/scripts/cppcheck-htmlreport.py"
"${OpenVINO_MAIN_SOURCE_DIR}/cmake/cpplint/cpplint_html.cmake"
COMMENT
"[cpplint] Generate HTML report"
VERBATIM)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+5
View File
@@ -249,3 +249,8 @@ endfunction()
set_ci_build_number()
include(vs_version/vs_version)
# Code style utils
include(cpplint/cpplint)
include(clang_format/clang_format)
+7 -3
View File
@@ -46,8 +46,7 @@ ie_dependent_option (ENABLE_AVX512F "Enable AVX512 optimizations" ON "X86_64 OR
ie_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pre-built ittnotify library though INTEL_VTUNE_DIR variable." OFF)
# Documentation build
ie_option (ENABLE_DOCS "build docs using Doxygen" OFF)
ie_option (ENABLE_DOCS "Build docs using Doxygen" OFF)
ie_dependent_option (ENABLE_FASTER_BUILD "Enable build features (PCH, UNITY) to speed up build time" OFF "CMAKE_VERSION VERSION_GREATER_EQUAL 3.16" OFF)
@@ -55,8 +54,13 @@ ie_dependent_option (ENABLE_FASTER_BUILD "Enable build features (PCH, UNITY) to
# FIXME: Ah this moment setting this to OFF will only build ngraph a static library
ie_option (BUILD_SHARED_LIBS "Build as a shared library" ON)
ie_dependent_option(ENABLE_CPPLINT "Enable cpplint checks during the build" ON "UNIX;NOT ANDROID" OFF)
ie_dependent_option(ENABLE_CPPLINT_REPORT "Build cpplint report instead of failing the build" OFF "ENABLE_CPPLINT" OFF)
ie_option(ENABLE_CLANG_FORMAT "Enable clang-format checks during the build" ON)
ie_option_enum(SELECTIVE_BUILD "Enable OpenVINO conditional compilation or statistics collection. \
In case SELECTIVE_BUILD is enabled, the SELECTIVE_BUILD_STAT variable should contain the path to the collected InelSEAPI statistics. \
Usage: -DSELECTIVE_BUILD=ON -DSELECTIVE_BUILD_STAT=/path/*.csv" OFF
ALLOWED_VALUES ON OFF COLLECT)
@@ -2,9 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
#
include(cpplint)
include(clang_format)
set(TBB_FIND_RELEASE_ONLY ${ENABLE_TBB_RELEASE_ONLY})
include(plugins/plugins)
-8
View File
@@ -98,14 +98,6 @@ ie_option (ENABLE_PYTHON "enables ie python bridge build" OFF)
ie_option (ENABLE_V7_SERIALIZE "enables serialization to IR v7" OFF)
ie_option (ENABLE_JAVA "enables ie java bridge build" OFF)
ie_dependent_option(ENABLE_CPPLINT "Enable cpplint checks during the build" ON "UNIX;NOT ANDROID" OFF)
ie_dependent_option(ENABLE_CPPLINT_REPORT "Build cpplint report instead of failing the build" OFF "ENABLE_CPPLINT" OFF)
ie_option(ENABLE_CLANG_FORMAT "Enable clang-format checks during the build" ON)
set(IE_EXTRA_MODULES "" CACHE STRING "Extra paths for extra modules to include into OpenVINO build")
ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are linked to the Inference Engine binaries" ON "THREADING MATCHES TBB;LINUX" OFF)
@@ -1,85 +0,0 @@
#!/bin/bash
# Copyright (C) 2018-2020 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
command -v realpath >/dev/null 2>&1 || { echo >&2 "cpplint require realpath executable but it's not installed. Aborting."; exit 1; }
SOURCE_DIR=$(realpath "${CURRENT_DIR}/..")
REPORT_DIR="${SOURCE_DIR}/report"
CPPLINT_REPORT_DIR="${REPORT_DIR}/cpplint"
PROJECT_NAME="Inference Engine"
function run_cpplint() {
echo "-> CppLint started..."
if [ -d "${CPPLINT_REPORT_DIR}" ]; then
rm -Rf "${CPPLINT_REPORT_DIR}"
fi
mkdir -p "${CPPLINT_REPORT_DIR}"
python "${CURRENT_DIR}/cpplint.py" --linelength=160 --counting=detailed --quiet --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
" $(find "${SOURCE_DIR}" -name '*.h' -or -name '*.cc' -or -name '*.c' -or -name '*.cpp' -or -name '*.hpp' |
grep -v 'inference-engine/bin\|inference-engine/build\|inference-engine/report\|inference-engine/scripts\|inference-engine/temp\|inference-engine/tests_deprecated/\|gtest\|inference-engine/ie_bridges\|pugixml\|inference-engine/tools/vpu_perfcheck\|thirdparty/gflags\|thirdparty/ade\|thirdparty/fluid\|thirdparty/mkl-dnn\|thirdparty/movidius\|thirdparty/ocv\|thirdparty/plugixml\|thirdparty/std_lib\|thirdparty/clDNN/common\|thirdparty/clDNN/tutorial\|thirdparty/clDNN/utils' |
grep 'include\|src\|inference-engine/samples\|thirdparty/clDNN/kernel_selector\|thirdparty/clDNN/api\|thirdparty/clDNN/api_extension\|inference-engine/tests_' ) 2>&1 |
sed 's/"/\&quot;/g' >&1| sed 's/</\&lt;/g' >&1| sed 's/>/\&gt;/g' >&1| sed "s/'/\&apos;/g" >&1|
sed 's/\&/\&amp;/g' >&1| python "${CURRENT_DIR}/cpplint_to_cppcheckxml.py" &> "${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml"
# Generate html from it
"${CURRENT_DIR}/cppcheck-htmlreport.py" --file="${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml" --report-dir="${CPPLINT_REPORT_DIR}" --source-dir="${SOURCE_DIR}" --title="${PROJECT_NAME}"
# Change Cppcheck things to cpplint
sed -i.bak 's/Cppcheck/cpplint/g' "${CPPLINT_REPORT_DIR}/index.html"
sed -i.bak 's/a\ tool\ for\ static\ C\/C++\ code\ analysis/an\ open\ source\ lint\-like\ tool\ from\ Google/g' "${CPPLINT_REPORT_DIR}/index.html"
sed -i.bak 's/http:\/\/cppcheck.sourceforge.net/http:\/\/google\-styleguide.googlecode.com\/svn\/trunk\/cpplint\/cpplint.py/g' "${CPPLINT_REPORT_DIR}/index.html"
sed -i.bak 's/IRC: <a href=\"irc:\/\/irc.freenode.net\/cppcheck\">irc:\/\/irc.freenode.net\/cppcheck<\/a>/\ /g' "${CPPLINT_REPORT_DIR}/index.html"
echo "-> CppLint finished..."
}
function run_cpp_check() {
echo "-> Cppcheck started..."
CPPCHECK_REPORT_DIR="${REPORT_DIR}/cppcheck"
if [ -d "${CPPCHECK_REPORT_DIR}" ]; then
rm -Rf "${CPPCHECK_REPORT_DIR}"
fi
mkdir -p "${CPPCHECK_REPORT_DIR}"
# Generate cppcheck xml
cppcheck -v --enable=all --suppress=missingIncludeSystem --std=c++11 "${SOURCE_DIR}" -i"${SOURCE_DIR}/thirdparty" -i"${SOURCE_DIR}/tests/libs" -i"${SOURCE_DIR}/temp" -i"${SOURCE_DIR}/build" \
-i"${SOURCE_DIR}/bin" -i"${SOURCE_DIR}/report" -I"${SOURCE_DIR}/include" -I"${SOURCE_DIR}/src" -I"${SOURCE_DIR}/thirdparty/pugixml/src" -I"${SOURCE_DIR}/thirdparty/gflags/src" -I"${SOURCE_DIR}/samples/scoring_agent/HTTPClient" -I"${SOURCE_DIR}/src/inference_engine" --xml-version=2 2> "${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml"
# Generate html from it
python "${CURRENT_DIR}/cppcheck-htmlreport.py" \
--file="${CPPCHECK_REPORT_DIR}/cppcheck-only-result.xml" \
--report-dir="${CPPCHECK_REPORT_DIR}" \
--source-dir="${SOURCE_DIR}" \
--title="${PROJECT_NAME}"
echo "-> Cppcheck finished..."
}
if [ ! -d "${REPORT_DIR}" ]; then
mkdir -p "${REPORT_DIR}"
fi
run_cpplint
out_cpp_lint=`cat "${CPPLINT_REPORT_DIR}/cpplint-cppcheck-result.xml"`
if [[ "${out_cpp_lint}" == *"error"* ]]; then
exit 1
fi
#run_cpp_check