feat: add conditional inclusion support to header parser#27325
Conversation
2392492 to
4a93fbd
Compare
4a93fbd to
d32123c
Compare
Thank you. This patch resolves both mentioned issues. For #10175 if |
4d8c249 to
4b68d2c
Compare
4b68d2c to
6ac0816
Compare
6ac0816 to
b3e17ea
Compare
|
@mshabunin @opencv-alalek could you take a look too? |
| "Failed to evaluate '{}' directive, stripped down to '{}'".format( | ||
| input_directive, directive | ||
| ) | ||
| ) from e |
There was a problem hiding this comment.
Please check failed build https://pullrequest.opencv.org/buildbot/builders/precommit_windows64/builds/109668/steps/compile%20release/logs/stdio:
Traceback (most recent call last):
File "C:/build/precommit_windows64/4.x/opencv/modules/java/generator/../generator/gen_java.py", line 1422, in <module>
import hdr_parser
File "C:\build\precommit_windows64\4.x\opencv\modules\python\src2\hdr_parser.py", line 154
) from e
^
SyntaxError: invalid syntax
opencv_gapi_SSE4_1.vcxproj -> C:\build\precommit_windows64\build\modules\gapi\opencv_gapi_SSE4_1.dir\Release\opencv_gapi_SSE4_1.lib
Generate files for Python bindings and documentation
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:\build\precommit_windows64\build\modules\java_bindings_generator\gen_opencv_java_source.vcxproj]
Traceback (most recent call last):
File "C:/build/precommit_windows64/4.x/opencv/modules/python/src2/gen2.py", line 4, in <module>
import hdr_parser, sys, re
File "C:\build\precommit_windows64\4.x\opencv\modules\python\src2\hdr_parser.py", line 154
) from e
^
SyntaxError: invalid syntax
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:
There was a problem hiding this comment.
It requires Python update. I notified Alexander about it.
|
Thanks for the patch, that really helps. I have a different build system though (blaze) so I generate the binding files in CMake and then include them in blaze which works fine. Some users might need DNN in the bindings, others might not (typically, Java and Android Java) and one header for both is easier. Would the following be possible: keep your patch but keep the guards in the bindings instead of removing the guarded sections. This way, the binding headers would be usable for different configurations (e.g. with or without HAVE_OPENCV_DNN being defined). |
Thank you for suggestion. Your approach requires significant changes in header parser and all bindings generators, because "availability information" should be a part of "function/enum/class/struct" definition. We can consider doing it once we begin reworking the header parser, updating intermediate representation and unifying all bindings generation. |
Brings support for conditional inclusion directives evaluation and proper
#if/#else/#elifbranches support.Generated diffs are attached:
cv::Feature2Dhas a valid base class now, because#elseis not discardedBuild warning is resolved:
Related diff in
pyopencv_generated_types.hDuplicate for
cv::RotationWarper::warpPointBackwardis removed from function dispatch.Related diff in
pyopencv_generated_types_content.hBefore
After
Closes #27064
Closes #10175
Closes #12972
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.