mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
feat: add conditional inclusion support to header parser
This commit is contained in:
@@ -38,6 +38,13 @@ if(HAVE_opencv_objc)
|
||||
set(__objc_build_dir "\"objc_build_dir\": \"${CMAKE_CURRENT_BINARY_DIR}/../objc\",")
|
||||
endif()
|
||||
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVBindingsPreprocessorDefinitions.cmake")
|
||||
|
||||
ocv_bindings_generator_populate_preprocessor_definitions(
|
||||
OPENCV_MODULES_BUILD
|
||||
opencv_preprocessor_defs
|
||||
)
|
||||
|
||||
set(CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/gen_objc.json")
|
||||
set(__config_str
|
||||
"{
|
||||
@@ -45,7 +52,10 @@ set(__config_str
|
||||
${__objc_build_dir}
|
||||
\"modules\": [
|
||||
${__modules_config}
|
||||
]
|
||||
],
|
||||
\"preprocessor_definitions\": {
|
||||
${opencv_preprocessor_defs}
|
||||
}
|
||||
}
|
||||
")
|
||||
#TODO: ocv_update_file("${CONFIG_FILE}" "${__config_str}" ON_CHANGE_REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source")
|
||||
|
||||
@@ -894,7 +894,8 @@ class ObjectiveCWrapperGenerator(object):
|
||||
namespace = self.classes[cname].namespace if cname in self.classes else "cv"
|
||||
return namespace.replace(".", "::") + "::"
|
||||
|
||||
def gen(self, srcfiles, module, output_path, output_objc_path, common_headers, manual_classes):
|
||||
def gen(self, srcfiles, module, output_path, output_objc_path,
|
||||
common_headers, manual_classes, preprocessor_definitions=None):
|
||||
self.clear()
|
||||
self.module = module
|
||||
self.objcmodule = make_objcmodule(module)
|
||||
@@ -903,7 +904,10 @@ class ObjectiveCWrapperGenerator(object):
|
||||
extension_signatures = []
|
||||
|
||||
# TODO: support UMat versions of declarations (implement UMat-wrapper for Java)
|
||||
parser = hdr_parser.CppHeaderParser(generate_umat_decls=False)
|
||||
parser = hdr_parser.CppHeaderParser(
|
||||
generate_umat_decls=False,
|
||||
preprocessor_definitions=preprocessor_definitions
|
||||
)
|
||||
|
||||
module_ci = self.add_class( ['class ' + self.Module, '', [], []]) # [ 'class/struct cname', ':bases', [modlist] [props] ]
|
||||
module_ci.header_import = module + '.hpp'
|
||||
@@ -1715,7 +1719,9 @@ if __name__ == "__main__":
|
||||
manual_classes = [x for x in [x[x.rfind('/')+1:-2] for x in [x for x in copied_files if x.endswith('.h')]] if x in type_dict]
|
||||
|
||||
if len(srcfiles) > 0:
|
||||
generator.gen(srcfiles, module, dstdir, objc_base_path, common_headers, manual_classes)
|
||||
generator.gen(srcfiles, module, dstdir, objc_base_path,
|
||||
common_headers, manual_classes,
|
||||
config.get("preprocessor_definitions"))
|
||||
else:
|
||||
logging.info("No generated code for module: %s", module)
|
||||
generator.finalize(args.target, objc_base_path, objc_build_dir)
|
||||
|
||||
Reference in New Issue
Block a user