From 2db45c8a8592059a3bef8d61d01bc8dbdd352dc1 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 29 Jun 2017 19:40:36 +0300 Subject: [PATCH 1/2] hdr_parser: ignore lines with 'CV__' macros --- modules/python/src2/hdr_parser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/python/src2/hdr_parser.py b/modules/python/src2/hdr_parser.py index cd50b520e8..0999a43996 100755 --- a/modules/python/src2/hdr_parser.py +++ b/modules/python/src2/hdr_parser.py @@ -769,7 +769,7 @@ class CppHeaderParser(object): for l0 in linelist: self.lineno += 1 - #print self.lineno + #print(state, self.lineno, l0) l = l0.strip() @@ -798,8 +798,13 @@ class CppHeaderParser(object): l = l[pos+2:] state = SCAN + if l.startswith('CV__'): # just ignore this lines + #print('IGNORE: ' + l) + state = SCAN + continue + if state != SCAN: - print("Error at %d: invlid state = %d" % (self.lineno, state)) + print("Error at %d: invalid state = %d" % (self.lineno, state)) sys.exit(-1) while 1: @@ -848,6 +853,7 @@ class CppHeaderParser(object): stmt = (block_head + " " + l[:pos]).strip() stmt = " ".join(stmt.split()) # normalize the statement + #print(stmt) stack_top = self.block_stack[-1] if stmt.startswith("@"): From 6ea6e4bceb17dfd09948c67a202cb074232fe51a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 30 Jun 2017 14:49:17 +0300 Subject: [PATCH 2/2] binding: fix headers processing --- modules/dnn/include/opencv2/dnn/dict.hpp | 2 ++ modules/python/common.cmake | 10 +++++++--- modules/python/src2/gen2.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/dnn/include/opencv2/dnn/dict.hpp b/modules/dnn/include/opencv2/dnn/dict.hpp index a9a70c9219..d8bc909c4e 100644 --- a/modules/dnn/include/opencv2/dnn/dict.hpp +++ b/modules/dnn/include/opencv2/dnn/dict.hpp @@ -46,6 +46,8 @@ #include #include +#include + namespace cv { namespace dnn { CV__DNN_EXPERIMENTAL_NS_BEGIN diff --git a/modules/python/common.cmake b/modules/python/common.cmake index f1d4ba1915..454c0d4271 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -32,13 +32,16 @@ foreach(m ${OPENCV_PYTHON_MODULES}) endforeach(m) # header blacklist -ocv_list_filterout(opencv_hdrs "modules/.*.h$") +ocv_list_filterout(opencv_hdrs "modules/.*\\\\.h$") ocv_list_filterout(opencv_hdrs "modules/core/.*/cuda") ocv_list_filterout(opencv_hdrs "modules/cuda.*") ocv_list_filterout(opencv_hdrs "modules/cudev") ocv_list_filterout(opencv_hdrs "modules/core/.*/hal/") ocv_list_filterout(opencv_hdrs "modules/.+/utils/.*") -ocv_list_filterout(opencv_hdrs "modules/.*/detection_based_tracker.hpp") # Conditional compilation +ocv_list_filterout(opencv_hdrs "modules/.*\\\\.inl\\\\.h*") +ocv_list_filterout(opencv_hdrs "modules/.*_inl\\\\.h*") +ocv_list_filterout(opencv_hdrs "modules/.*\\\\.details\\\\.h*") +ocv_list_filterout(opencv_hdrs "modules/.*/detection_based_tracker\\\\.hpp") # Conditional compilation set(cv2_generated_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h" @@ -47,7 +50,8 @@ set(cv2_generated_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h" "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_ns_reg.h") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs}") +string(REPLACE ";" "\n" opencv_hdrs_ "${opencv_hdrs}") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs_}") add_custom_command( OUTPUT ${cv2_generated_hdrs} COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${PYTHON_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${PYTHON}" diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 789e101a33..04c455cd78 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -977,6 +977,6 @@ if __name__ == "__main__": if len(sys.argv) > 1: dstdir = sys.argv[1] if len(sys.argv) > 2: - srcfiles = open(sys.argv[2], 'r').read().split(';') + srcfiles = [f.strip() for f in open(sys.argv[2], 'r').readlines()] generator = PythonWrapperGenerator() generator.gen(srcfiles, dstdir)