forked from opencv/opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencv#18965 from alalek:cmake_gen_js_code
- Loading branch information
Showing
8 changed files
with
120 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set(OPENCV_SKIP_LINK_AS_NEEDED 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# get list of modules to wrap | ||
if(HAVE_opencv_js) | ||
message(STATUS "Wrapped in JavaScript(js):") | ||
endif() | ||
set(OPENCV_JS_MODULES "") | ||
foreach(m ${OPENCV_MODULES_BUILD}) | ||
if(";${OPENCV_MODULE_${m}_WRAPPERS};" MATCHES ";js;" AND HAVE_${m}) | ||
list(APPEND OPENCV_JS_MODULES ${m}) | ||
if(HAVE_opencv_js) | ||
message(STATUS " ${m}") | ||
endif() | ||
endif() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
set(MODULE_NAME "js_bindings_generator") | ||
set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE) | ||
ocv_add_module(${MODULE_NAME} INTERNAL) | ||
|
||
set(OPENCV_JS_BINDINGS_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "") | ||
file(REMOVE_RECURSE "${OPENCV_JS_BINDINGS_DIR}/gen") | ||
file(MAKE_DIRECTORY "${OPENCV_JS_BINDINGS_DIR}/gen") | ||
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_js_source") # force re-run after CMake | ||
|
||
# This file is included from a subdirectory | ||
set(JS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") | ||
include(${JS_SOURCE_DIR}/common.cmake) # fill OPENCV_JS_MODULES | ||
|
||
set(opencv_hdrs "") | ||
foreach(m ${OPENCV_JS_MODULES}) | ||
list(APPEND opencv_hdrs ${OPENCV_MODULE_${m}_HEADERS}) | ||
endforeach(m) | ||
|
||
# header blacklist | ||
ocv_list_filterout(opencv_hdrs "modules/.*.h$") | ||
ocv_list_filterout(opencv_hdrs "modules/core/.*/cuda") | ||
ocv_list_filterout(opencv_hdrs "modules/core/.*/opencl") | ||
ocv_list_filterout(opencv_hdrs "modules/core/include/opencv2/core/opengl.hpp") | ||
ocv_list_filterout(opencv_hdrs "modules/core/include/opencv2/core/ocl.hpp") | ||
ocv_list_filterout(opencv_hdrs "modules/cuda.*") | ||
ocv_list_filterout(opencv_hdrs "modules/cudev") | ||
ocv_list_filterout(opencv_hdrs "modules/core/.*/hal/") | ||
ocv_list_filterout(opencv_hdrs "modules/.*/detection_based_tracker.hpp") # Conditional compilation | ||
ocv_list_filterout(opencv_hdrs "modules/core/include/opencv2/core/utils/.*") | ||
|
||
ocv_update_file("${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs}") | ||
|
||
set(bindings_cpp "${OPENCV_JS_BINDINGS_DIR}/gen/bindings.cpp") | ||
|
||
set(scripts_hdr_parser "${JS_SOURCE_DIR}/../python/src2/hdr_parser.py") | ||
|
||
if(DEFINED ENV{OPENCV_JS_WHITELIST}) | ||
set(OPENCV_JS_WHITELIST_FILE "$ENV{OPENCV_JS_WHITELIST}") | ||
else() | ||
set(OPENCV_JS_WHITELIST_FILE "${OpenCV_SOURCE_DIR}/platforms/js/opencv_js.config.py") | ||
endif() | ||
|
||
add_custom_command( | ||
OUTPUT ${bindings_cpp} "${OPENCV_DEPHELPER}/gen_opencv_js_source" | ||
COMMAND | ||
${PYTHON_DEFAULT_EXECUTABLE} | ||
"${CMAKE_CURRENT_SOURCE_DIR}/embindgen.py" | ||
"${scripts_hdr_parser}" | ||
"${bindings_cpp}" | ||
"${CMAKE_CURRENT_BINARY_DIR}/headers.txt" | ||
"${JS_SOURCE_DIR}/src/core_bindings.cpp" | ||
"${OPENCV_JS_WHITELIST_FILE}" | ||
COMMAND | ||
${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/gen_opencv_js_source" | ||
WORKING_DIRECTORY | ||
"${CMAKE_CURRENT_BINARY_DIR}/gen" | ||
DEPENDS | ||
${JS_SOURCE_DIR}/src/core_bindings.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/embindgen.py | ||
${CMAKE_CURRENT_SOURCE_DIR}/templates.py | ||
${scripts_hdr_parser} | ||
#(not needed - generated by CMake) ${CMAKE_CURRENT_BINARY_DIR}/headers.txt | ||
${opencv_hdrs} | ||
COMMENT "Generate source files for JavaScript bindings" | ||
) | ||
|
||
add_custom_target(gen_opencv_js_source | ||
# excluded from all: ALL | ||
DEPENDS ${bindings_cpp} "${OPENCV_DEPHELPER}/gen_opencv_js_source" | ||
SOURCES | ||
${JS_SOURCE_DIR}/src/core_bindings.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/embindgen.py | ||
${CMAKE_CURRENT_SOURCE_DIR}/templates.py | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters