Commit 059d63cc authored by hbristow's avatar hbristow

Added diagnostic/build information function

parent f7050203
...@@ -52,11 +52,12 @@ endif() ...@@ -52,11 +52,12 @@ endif()
# If the user built OpenCV as X-bit, but they have a Y-bit version of Matlab, # If the user built OpenCV as X-bit, but they have a Y-bit version of Matlab,
# attempting to link to OpenCV during binding generation will fail, since # attempting to link to OpenCV during binding generation will fail, since
# mixed precision pointers are not allowed. Disable the bindings. # mixed precision pointers are not allowed. Disable the bindings.
if (${CMAKE_SIZEOF_VOID_P} EQUAL 4 AND ${MATLAB_ARCH} MATCHES "64") math(EXPR ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
if (${ARCH} EQUAL 32 AND ${MATLAB_ARCH} MATCHES "64")
warn_mixed_precision("32" "64") warn_mixed_precision("32" "64")
ocv_module_disable(matlab) ocv_module_disable(matlab)
return() return()
elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8 AND NOT ${MATLAB_ARCH} MATCHES "64") elseif (${ARCH} EQUAL 64 AND NOT ${MATLAB_ARCH} MATCHES "64")
warn_mixed_precision("64" "32") warn_mixed_precision("64" "32")
ocv_module_disable(matlab) ocv_module_disable(matlab)
return() return()
...@@ -73,6 +74,10 @@ ocv_add_module(matlab BINDINGS ...@@ -73,6 +74,10 @@ ocv_add_module(matlab BINDINGS
opencv_nonfree opencv_nonfree
) )
# get the commit information
execute_process(COMMAND git log -1 --pretty=%H OUTPUT_VARIABLE GIT_COMMIT ERROR_QUIET)
string(REGEX REPLACE "(\r?\n)+$" "" GIT_COMMIT ${GIT_COMMIT})
# set the path to the C++ header and doc parser # set the path to the C++ header and doc parser
set(HDR_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/python/src2) set(HDR_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/python/src2)
set(RST_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/java/generator) set(RST_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/java/generator)
...@@ -80,7 +85,7 @@ set(RST_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/java/generator) ...@@ -80,7 +85,7 @@ set(RST_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/java/generator)
# set mex compiler options # set mex compiler options
prepend("-I" MEX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) prepend("-I" MEX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
prepend("-L" MEX_LIB_DIR ${LIBRARY_OUTPUT_PATH}/$(Configuration)) prepend("-L" MEX_LIB_DIR ${LIBRARY_OUTPUT_PATH}/$(Configuration))
set(MEX_OPTS -largeArrayDims) set(MEX_OPTS "-largeArrayDims")
if (BUILD_TESTS) if (BUILD_TESTS)
add_subdirectory(test) add_subdirectory(test)
...@@ -108,7 +113,8 @@ list(APPEND opencv_extra_hdrs "core:${OPENCV_MODULE_opencv_core_LOCATION}/includ ...@@ -108,7 +113,8 @@ list(APPEND opencv_extra_hdrs "core:${OPENCV_MODULE_opencv_core_LOCATION}/includ
# pass the OPENCV_CXX_EXTRA_FLAGS through to the mex compiler # pass the OPENCV_CXX_EXTRA_FLAGS through to the mex compiler
# remove the visibility modifiers, so the mex gateway is visible # remove the visibility modifiers, so the mex gateway is visible
string(REGEX REPLACE "[^\ ]*visibility[^\ ]*" "" MEX_CXX_FLAGS "${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}") # TODO: get mex working without warnings
#string(REGEX REPLACE "[^\ ]*visibility[^\ ]*" "" MEX_CXXFLAGS "${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
# Configure checks # Configure checks
# Check to see whether the generator and the mex compiler are working. # Check to see whether the generator and the mex compiler are working.
...@@ -189,6 +195,20 @@ add_custom_command( ...@@ -189,6 +195,20 @@ add_custom_command(
--modules ${opencv_modules} --modules ${opencv_modules}
--extra ${opencv_extra_hdrs} --extra ${opencv_extra_hdrs}
--outdir ${CMAKE_CURRENT_BINARY_DIR} --outdir ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/generator/build_info.py
--os ${CMAKE_SYSTEM}
--arch ${ARCH} ${CMAKE_SYSTEM_PROCESSOR}
--compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}
--mex_arch ${MATLAB_ARCH}
--mex_script ${MATLAB_MEX_SCRIPT}
--cxx_flags ${MEX_CXXFLAGS}
--opencv_version ${OPENCV_VERSION}
--commit ${GIT_COMMIT}
--modules ${opencv_modules}
--configuration "$(Configuration)" ${CMAKE_BUILD_TYPE}
--outdir ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test/help.m ${CMAKE_CURRENT_BINARY_DIR}/+cv
COMMAND ${CMAKE_COMMAND} -E touch ${GENERATE_PROXY} COMMAND ${CMAKE_COMMAND} -E touch ${GENERATE_PROXY}
COMMENT "Generating Matlab source files" COMMENT "Generating Matlab source files"
) )
......
#/usr/bin/env python
def substitute(build, output_dir):
# setup the template engine
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jtemplate = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True)
# add the filters
jtemplate.filters['csv'] = csv
jtemplate.filters['stripExtraSpaces'] = stripExtraSpaces
# load the template
template = jtemplate.get_template('template_build_info.m')
# create the build directory
output_dir = output_dir+'/+cv'
if not os.path.isdir(output_dir):
os.mkdir(output_dir)
# populate templates
populated = template.render(build=build)
with open(os.path.join(output_dir, 'buildInformation.m'), 'wb') as f:
f.write(populated)
if __name__ == "__main__":
# parse the input options
import sys, re, os
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('--os')
parser.add_argument('--arch', nargs=2)
parser.add_argument('--compiler', nargs='+')
parser.add_argument('--mex_arch')
parser.add_argument('--mex_script')
parser.add_argument('--mex_opts', default=['-largeArrayDims'], nargs='*')
parser.add_argument('--cxx_flags', default=[], nargs='*')
parser.add_argument('--opencv_version', default='', nargs='?')
parser.add_argument('--commit', default='Not in working git tree', nargs='?')
parser.add_argument('--modules', nargs='+')
parser.add_argument('--configuration')
parser.add_argument('--outdir')
build = parser.parse_args()
from filters import *
from jinja2 import Environment, FileSystemLoader
# populate the build info template
substitute(build, build.outdir)
...@@ -98,6 +98,12 @@ def slugify(text): ...@@ -98,6 +98,12 @@ def slugify(text):
def filename(fullpath): def filename(fullpath):
return os.path.splitext(os.path.basename(fullpath))[0] return os.path.splitext(os.path.basename(fullpath))[0]
def csv(items, sep=', '):
return sep.join(item for item in items)
def stripExtraSpaces(text):
return ' '.join(text.split())
def comment(text, wrap=80, escape='% ', escape_first='', escape_last=''): def comment(text, wrap=80, escape='% ', escape_first='', escape_last=''):
'''comment filter '''comment filter
......
function buildInformation()
%CV.BUILDINFORMATION display OpenCV Toolbox build information
%
% Call CV.BUILDINFORMATION() to get a printout of diagonstic information
% pertaining to your particular build of the OpenCV Toolbox. If you ever
% run into issues with the Toolbox, it is useful to submit this
% information alongside a bug report to the OpenCV team.
%
info = {
' ------------------------------------------------------------------------'
' <strong>OpenCV Toolbox</strong>'
' Build and diagnostic information'
' ------------------------------------------------------------------------'
''
' <strong>Platform</strong>'
' OS: {{ build.os }}'
' Architecture: {{ build.arch[0] }}-bit {{ build.arch[1] }}'
' Compiler: {{ build.compiler | csv(' ') }}'
''
' <strong>Matlab</strong>'
[' Version: ' version()]
[' Mex extension: ' mexext()]
' Architecture: {{ build.mex_arch }}'
' Mex path: {{ build.mex_script }}'
' Mex flags: {{ build.mex_opts | csv(' ') }}'
' CXX flags: {{ build.cxx_flags | csv(' ') | stripExtraSpaces | wordwrap(60, True, '\'\n\' ') }}'
''
' <strong>OpenCV</strong>'
' Version: {{ build.opencv_version }}'
' Commit: {{ build.commit }}'
' Configuration: {{ build.configuration }}'
' Modules: {{ build.modules | csv | wordwrap(60, True, '\'\n\' ') }}'
''
};
info = cellfun(@(x) [x '\n'], info, 'UniformOutput', false);
info = horzcat(info{:});
fprintf(info);
end
% ------------------------------------------------------------------------ % ------------------------------------------------------------------------
% OpenCV Toolbox % <strong>OpenCV Toolbox</strong>
% Matlab bindings for the OpenCV library % Matlab bindings for the OpenCV library
% ------------------------------------------------------------------------ % ------------------------------------------------------------------------
% %
% The OpenCV Toolbox allows you to make calls to native OpenCV methods % The OpenCV Toolbox allows you to make calls to native OpenCV methods
% and classes directly from within Matlab. % and classes directly from within Matlab.
% %
% PATHS % <strong>PATHS</strong>
% To call OpenCV methods from anywhere in your workspace, add the % To call OpenCV methods from anywhere in your workspace, add the
% directory containing this file to the path: % directory containing this file to the path:
% %
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
% cv.m - This file, containing OpenCV enums % cv.m - This file, containing OpenCV enums
% +cv/ - The directory containing the OpenCV methods and classes % +cv/ - The directory containing the OpenCV methods and classes
% %
% CALLING SYNTAX % <strong>CALLING SYNTAX</strong>
% To call an OpenCV method, class or enum, it must be prefixed with the % To call an OpenCV method, class or enum, it must be prefixed with the
% 'cv' qualifier. For example: % 'cv' qualifier. For example:
% %
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
% camera = cv.VideoCapture(); % camera = cv.VideoCapture();
% camera.open('/path/to/file'); % camera.open('/path/to/file');
% %
% HELP % <strong>HELP</strong>
% Each method has its own help file containing information about the % Each method has its own help file containing information about the
% arguments, return values, and what operation the method performs. % arguments, return values, and what operation the method performs.
% You can access this help information by typing: % You can access this help information by typing:
...@@ -38,17 +38,19 @@ ...@@ -38,17 +38,19 @@
% directory. Note that the methods available to you will depend % directory. Note that the methods available to you will depend
% on which modules you configured OpenCV to build. % on which modules you configured OpenCV to build.
% %
% DIAGNOSTICS % <strong>DIAGNOSTICS</strong>
% If you are having problems with the OpenCV Toolbox and need to send a % If you are having problems with the OpenCV Toolbox and need to send a
% bug report to the OpenCV team, you can get a printout of diagnostic % bug report to the OpenCV team, you can get a printout of diagnostic
% information to submit along with your report by typing: % information to submit along with your report by typing:
% %
% cv.buildInformation(); % cv.buildInformation();
% %
% OTHER RESOURCES % <strong>OTHER RESOURCES</strong>
% OpenCV documentation online: http://docs.opencv.org % OpenCV documentation online: <a href="matlab: web('http://docs.opencv.org', '-browser')">http://docs.opencv.org</a>
% OpenCV issue tracker: http://code.opencv.org % OpenCV issue tracker: <a href="matlab: web('http://code.opencv.org', '-browser')">http://code.opencv.org</a>
% OpenCV Q&A: http://answers.opencv.org % OpenCV Q&A: <a href="matlab: web('http://answers.opencv.org', '-browser')">http://answers.opencv.org</a>
%
% See also: cv.help, cv.buildInformation
% %
% Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation % Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation
% %
......
function help()
%CV.HELP display help information for the OpenCV Toolbox
%
% Calling:
% >> cv.help();
%
% is equivalent to calling:
% >> help cv;
%
% It displays high-level usage information about the OpenCV toolbox
% along with resources to find out more information.
%
% See also: cv.buildInformation
help('cv');
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment