js: use generated list of OpenCV headers

- replaces hand-written list
pull/12362/head
Alexander Alekhin 6 years ago
parent 32a02544de
commit d52cef1719
  1. 2
      modules/js/CMakeLists.txt
  2. 9
      modules/js/src/core_bindings.cpp
  3. 5
      modules/js/src/embindgen.py

@ -56,7 +56,7 @@ add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/embindgen.py
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/templates.py
DEPENDS ${scripts_hdr_parser}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
#(not needed - generated by CMake) DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
DEPENDS ${opencv_hdrs}
DEPENDS ${JS_HELPER})

@ -68,15 +68,10 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//M*/
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/video/background_segm.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/dnn.hpp"
#include <emscripten/bind.h>
@INCLUDES@
using namespace emscripten;
using namespace cv;
using namespace dnn;

@ -733,12 +733,14 @@ class JSWrapperGenerator(object):
def gen(self, dst_file, src_files, core_bindings):
# step 1: scan the headers and extract classes, enums and functions
headers = []
for hdr in src_files:
decls = self.parser.parse(hdr)
# print(hdr);
# self.print_decls(decls);
if len(decls) == 0:
continue
headers.append(hdr[hdr.rindex('opencv2/'):])
for decl in decls:
name = decl[0]
type = name[:name.find(" ")]
@ -890,6 +892,9 @@ class JSWrapperGenerator(object):
with open(core_bindings) as f:
ret = f.read()
header_includes = '\n'.join(['#include "{}"'.format(hdr) for hdr in headers])
ret = ret.replace('@INCLUDES@', header_includes)
defis = '\n'.join(self.wrapper_funcs)
ret += wrapper_codes_template.substitute(ns=wrapper_namespace, defs=defis)
ret += emscripten_binding_template.substitute(binding_name='testBinding', bindings=''.join(self.bindings))

Loading…
Cancel
Save