pass header list to gen2.py by a text file (avoid command line length limit on windows)
This commit is contained in:
parent
42ecfc5538
commit
9ab3b89c53
@ -12,18 +12,17 @@ endif()
|
|||||||
|
|
||||||
set(the_description "The python bindings")
|
set(the_description "The python bindings")
|
||||||
|
|
||||||
set(candidate_deps)
|
set(candidate_deps "")
|
||||||
foreach(mp ${OPENCV_MODULES_PATH} ${OPENCV_EXTRA_MODULES_PATH})
|
foreach(mp ${OPENCV_MODULES_PATH} ${OPENCV_EXTRA_MODULES_PATH})
|
||||||
file(GLOB names "${mp}/*")
|
file(GLOB names "${mp}/*")
|
||||||
foreach(m IN LISTS names)
|
foreach(m IN LISTS names)
|
||||||
if(IS_DIRECTORY ${m})
|
if(IS_DIRECTORY ${m})
|
||||||
get_filename_component(m ${m} NAME)
|
get_filename_component(m ${m} NAME)
|
||||||
if (NOT ${m} MATCHES "^cud(a|ev)")
|
list(APPEND candidate_deps "opencv_${m}")
|
||||||
list(APPEND candidate_deps "opencv_${m}")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
endforeach(m)
|
endforeach(m)
|
||||||
endforeach(mp)
|
endforeach(mp)
|
||||||
|
ocv_list_filterout(candidate_deps "^opencv_cud(a|ev)")
|
||||||
|
|
||||||
ocv_add_module(python BINDINGS OPTIONAL ${candidate_deps})
|
ocv_add_module(python BINDINGS OPTIONAL ${candidate_deps})
|
||||||
|
|
||||||
@ -34,27 +33,16 @@ ocv_module_include_directories(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
set(opencv_hdrs_blacklist
|
set(opencv_hdrs "")
|
||||||
".h$"
|
|
||||||
"opencv2/core/cuda"
|
|
||||||
"opencv2/objdetect/detection_based_tracker.hpp"
|
|
||||||
"opencv2/optim.hpp")
|
|
||||||
|
|
||||||
set(opencv_hdrs)
|
|
||||||
foreach(m IN LISTS OPENCV_MODULE_opencv_python_DEPS)
|
foreach(m IN LISTS OPENCV_MODULE_opencv_python_DEPS)
|
||||||
foreach(hdr IN LISTS OPENCV_MODULE_${m}_HEADERS)
|
list(APPEND opencv_hdrs ${OPENCV_MODULE_${m}_HEADERS})
|
||||||
set(good TRUE)
|
|
||||||
foreach(s IN LISTS opencv_hdrs_blacklist)
|
|
||||||
if (${hdr} MATCHES ${s})
|
|
||||||
set(good FALSE)
|
|
||||||
endif()
|
|
||||||
endforeach(s)
|
|
||||||
if(${good})
|
|
||||||
list(APPEND opencv_hdrs ${hdr})
|
|
||||||
endif()
|
|
||||||
endforeach(hdr)
|
|
||||||
endforeach(m)
|
endforeach(m)
|
||||||
|
|
||||||
|
ocv_list_filterout(opencv_hdrs ".h$")
|
||||||
|
ocv_list_filterout(opencv_hdrs "opencv2/core/cuda")
|
||||||
|
ocv_list_filterout(opencv_hdrs "opencv2/objdetect/detection_based_tracker.hpp")
|
||||||
|
ocv_list_filterout(opencv_hdrs "opencv2/optim.hpp")
|
||||||
|
|
||||||
set(cv2_generated_hdrs
|
set(cv2_generated_hdrs
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h"
|
||||||
@ -63,11 +51,13 @@ set(cv2_generated_hdrs
|
|||||||
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_const_reg.h")
|
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_const_reg.h")
|
||||||
|
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs}")
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${cv2_generated_hdrs}
|
OUTPUT ${cv2_generated_hdrs}
|
||||||
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs}
|
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/headers.txt"
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py
|
||||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/hdr_parser.py
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/hdr_parser.py
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
|
||||||
DEPENDS ${opencv_hdrs})
|
DEPENDS ${opencv_hdrs})
|
||||||
|
|
||||||
add_library(${the_module} SHARED src2/cv2.cpp ${cv2_generated_hdrs})
|
add_library(${the_module} SHARED src2/cv2.cpp ${cv2_generated_hdrs})
|
||||||
|
@ -831,7 +831,6 @@ class PythonWrapperGenerator(object):
|
|||||||
|
|
||||||
# step 1: scan the headers and build more descriptive maps of classes, consts, functions
|
# step 1: scan the headers and build more descriptive maps of classes, consts, functions
|
||||||
for hdr in srcfiles:
|
for hdr in srcfiles:
|
||||||
print(hdr)
|
|
||||||
decls = parser.parse(hdr)
|
decls = parser.parse(hdr)
|
||||||
if len(decls) == 0:
|
if len(decls) == 0:
|
||||||
continue
|
continue
|
||||||
@ -904,6 +903,6 @@ if __name__ == "__main__":
|
|||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
dstdir = sys.argv[1]
|
dstdir = sys.argv[1]
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
srcfiles = sys.argv[2:]
|
srcfiles = open(sys.argv[2], 'r').read().split(';')
|
||||||
generator = PythonWrapperGenerator()
|
generator = PythonWrapperGenerator()
|
||||||
generator.gen(srcfiles, dstdir)
|
generator.gen(srcfiles, dstdir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user