From 9ab3b89c53aa0153111398b08f880f68bb7e497d Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Sun, 27 Jul 2014 16:35:35 +0400 Subject: [PATCH] pass header list to gen2.py by a text file (avoid command line length limit on windows) --- modules/python/CMakeLists.txt | 36 +++++++++++++---------------------- modules/python/src2/gen2.py | 3 +-- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index cccf0c3915..57a8ed7b4f 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -12,18 +12,17 @@ endif() set(the_description "The python bindings") -set(candidate_deps) +set(candidate_deps "") foreach(mp ${OPENCV_MODULES_PATH} ${OPENCV_EXTRA_MODULES_PATH}) file(GLOB names "${mp}/*") foreach(m IN LISTS names) if(IS_DIRECTORY ${m}) get_filename_component(m ${m} NAME) - if (NOT ${m} MATCHES "^cud(a|ev)") - list(APPEND candidate_deps "opencv_${m}") - endif() + list(APPEND candidate_deps "opencv_${m}") endif() endforeach(m) endforeach(mp) +ocv_list_filterout(candidate_deps "^opencv_cud(a|ev)") ocv_add_module(python BINDINGS OPTIONAL ${candidate_deps}) @@ -34,27 +33,16 @@ ocv_module_include_directories( ) -set(opencv_hdrs_blacklist - ".h$" - "opencv2/core/cuda" - "opencv2/objdetect/detection_based_tracker.hpp" - "opencv2/optim.hpp") - -set(opencv_hdrs) +set(opencv_hdrs "") foreach(m IN LISTS OPENCV_MODULE_opencv_python_DEPS) - foreach(hdr IN LISTS 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) + list(APPEND opencv_hdrs ${OPENCV_MODULE_${m}_HEADERS}) 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 "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.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_const_reg.h") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs}") add_custom_command( 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/hdr_parser.py + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt DEPENDS ${opencv_hdrs}) add_library(${the_module} SHARED src2/cv2.cpp ${cv2_generated_hdrs}) diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 9488107715..684b80f4e8 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -831,7 +831,6 @@ class PythonWrapperGenerator(object): # step 1: scan the headers and build more descriptive maps of classes, consts, functions for hdr in srcfiles: - print(hdr) decls = parser.parse(hdr) if len(decls) == 0: continue @@ -904,6 +903,6 @@ if __name__ == "__main__": if len(sys.argv) > 1: dstdir = sys.argv[1] if len(sys.argv) > 2: - srcfiles = sys.argv[2:] + srcfiles = open(sys.argv[2], 'r').read().split(';') generator = PythonWrapperGenerator() generator.gen(srcfiles, dstdir)