mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
cmake: added check_flake8 target
This commit is contained in:
parent
78f205ffa5
commit
43177b1f6f
@ -338,6 +338,7 @@ OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatch
|
||||
OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON)
|
||||
|
||||
OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (${BUILD_DOCS} OR ${BUILD_EXAMPLES}) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
|
||||
OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (${BUILD_DOCS} OR ${BUILD_EXAMPLES}) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
|
||||
|
||||
if(ENABLE_IMPL_COLLECTION)
|
||||
add_definitions(-DCV_COLLECT_IMPL_DATA)
|
||||
@ -645,9 +646,22 @@ if(BUILD_JAVA)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_PYLINT)
|
||||
if(ENABLE_PYLINT AND PYTHON_DEFAULT_AVAILABLE)
|
||||
include(cmake/OpenCVPylint.cmake)
|
||||
endif()
|
||||
if(ENABLE_FLAKE8 AND PYTHON_DEFAULT_AVAILABLE)
|
||||
find_package(Flake8 QUIET)
|
||||
if(NOT FLAKE8_FOUND OR NOT FLAKE8_EXECUTABLE)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlake8.cmake")
|
||||
endif()
|
||||
if(FLAKE8_FOUND)
|
||||
add_custom_target(check_flake8
|
||||
COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='.git,__pycache__,*.config.py,svgfig.py'
|
||||
WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}"
|
||||
COMMENT "Running flake8"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(ANDROID AND ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_TOOLS_Pkg_Revision GREATER 13))
|
||||
@ -1449,6 +1463,9 @@ status(" Python (for build):" PYTHON_DEFAULT_AVAILABLE THEN "${PYTHON_DEFAULT_
|
||||
if(PYLINT_FOUND AND PYLINT_EXECUTABLE)
|
||||
status(" Pylint:" PYLINT_FOUND THEN "${PYLINT_EXECUTABLE} (ver: ${PYLINT_VERSION}, checks: ${PYLINT_TOTAL_TARGETS})" ELSE NO)
|
||||
endif()
|
||||
if(FLAKE8_FOUND AND FLAKE8_EXECUTABLE)
|
||||
status(" Flake8:" FLAKE8_FOUND THEN "${FLAKE8_EXECUTABLE} (ver: ${FLAKE8_VERSION})" ELSE NO)
|
||||
endif()
|
||||
|
||||
# ========================== java ==========================
|
||||
if(BUILD_JAVA OR BUILD_opencv_java)
|
||||
|
27
cmake/FindFlake8.cmake
Normal file
27
cmake/FindFlake8.cmake
Normal file
@ -0,0 +1,27 @@
|
||||
# - Find Flake8
|
||||
# Find the Flake8 executable and extract the version number
|
||||
#
|
||||
# OUTPUT Variables
|
||||
#
|
||||
# FLAKE8_FOUND
|
||||
# True if the flake8 package was found
|
||||
# FLAKE8_EXECUTABLE
|
||||
# The flake8 executable location
|
||||
# FLAKE8_VERSION
|
||||
# A string denoting the version of flake8 that has been found
|
||||
|
||||
find_host_program(FLAKE8_EXECUTABLE flake8 PATHS /usr/bin)
|
||||
|
||||
if(FLAKE8_EXECUTABLE)
|
||||
execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version OUTPUT_VARIABLE FLAKE8_VERSION_RAW ERROR_QUIET)
|
||||
if(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])")
|
||||
set(FLAKE8_VERSION "${CMAKE_MATCH_1}")
|
||||
else()
|
||||
set(FLAKE8_VERSION "unknown")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8 DEFAULT_MSG FLAKE8_EXECUTABLE)
|
||||
|
||||
mark_as_advanced(FLAKE8_EXECUTABLE FLAKE8_VERSION)
|
Loading…
Reference in New Issue
Block a user