Hi bazel community,
I got it to work after some experimenting and debugging work for the option of using new_local_repository_rule. There must be some directory changes in newer opencv versions, which is causing the original post to not work.
The settings need to be very specific. Then a few things needs to be changes:
1. When building opencv we need to build with a single .so file opencv_world.so. This step enables resolving issue #2 easier. Debugging message does not explicitly show this. This is done by trial and error.
2. The glob pattern actually does not work, we need to be more specific. The actual reason for this is unknown. Debugging message does not show explicitly what needs to be done.
Target //main:hello-world failed to build
INFO: Elapsed time: 0.507s, Critical Path: 0.16s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target
3. include needs to extend to include/opencv4. The debugging message is showing that some header files can't be found, so it is reasonable to inspect the specific opencv folder and check the include structure. The bafelling part is if this is fixed, if #1 and #2 are not resolved the software will not build also. We need to be mindful that the file structure of opencv or other packages such as pcl and libgeos are all changing.
main/hello-world.cc:7:10: fatal error: opencv2/core/core.hpp: No such file or directory
7 | #include <opencv2/core/core.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~
4. hdrs needs to include .h file along with .hpps. Debugging messages will only show meaningful information if #1, #2 and #3 are resolved first. This is relatively the easier one to fix.
external/opencv/include/opencv4/opencv2/core.hpp:52:10: fatal error: opencv2/core/cvdef.h: No such file or directory
52 | #include "opencv2/core/cvdef.h"
| ^~~~~~~~~~~~~~~~~~~~~~