Commit 29b6df0a authored by Jozef Legeny's avatar Jozef Legeny

openvibe-documentation:

* changed the way how the plugin inspector is called, now everything is compiled in a single run of the CMake/make install
openvibe-applications/plugin-inspector:
+ added parameters to plugin inspector, it can now load plugins from arbitrary folders and dump folders can be specified from the command line

git-svn-id: svn://scm.gforge.inria.fr/svn/openvibe@3568 c330d7e9-fc0c-0410-a5b3-fd85c6f5aa8f
parent 2a34da15
......@@ -99,6 +99,7 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules")
# a list of all project which will be filled by the directory traversal. This is needed to generate the documentation.
SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS "")
SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR "")
# Used by the various Find* scripts to locate OpenViBE modules
SET(OV_BASE_DIR ${CMAKE_SOURCE_DIR})
......@@ -115,6 +116,7 @@ INCLUDE("OvInstallLaunchScript")
# Setup knowledge of GNU-style install path variables
INCLUDE("GNUInstallDirs")
SET(CMAKE_INSTALL_FULL_DOCDIR "${CMAKE_INSTALL_FULL_BINDIR}/../doc/html")
# Add directories that OpenViBE will use to look for its components runtime, unless overridden by environment variables in the launch scripts.
# These defines should only be used in "ov_directories.h".
......@@ -134,6 +136,10 @@ ADD_SUBDIRECTORY("openvibe-applications/")
ADD_SUBDIRECTORY("openvibe-externals/")
ADD_SUBDIRECTORY("openvibe-documentation/") # needs to be the last since it uses the list of collected projects
#add dependency to plugin inspector to the documentation
IF(openvibe-documentation)
ADD_DEPENDENCIES(openvibe-documentation openvibe-plugin-inspector-dynamic)
ENDIF(openvibe-documentation)
# make a copy of the dependency script, this is done so we can use the same launch scripts both in win install and win devel situations.
IF(WIN32)
INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/win32-dependencies.cmd DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} RENAME "openvibe-set-env.cmd")
......
......@@ -14,6 +14,9 @@ FUNCTION(OV_ADD_PROJECTS CURRENT_BRANCH_PREFIX)
FOREACH(FULLPATH ${FILENAMES})
IF(IS_DIRECTORY ${FULLPATH} AND NOT ${FULLPATH} MATCHES ".*\\.svn")
GET_FILENAME_COMPONENT(DIRNAME ${FULLPATH} NAME)
SET(OV_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DIRNAME}")
STRING(TOUPPER ${DIRNAME} DIRNAMEUPPER)
SET(BRANCH_VARIABLE_NAME "${CURRENT_BRANCH_PREFIX}_${DIRNAMEUPPER}")
SET(SUBDIR "SUBDIR-NOTFOUND")
......@@ -25,10 +28,10 @@ FUNCTION(OV_ADD_PROJECTS CURRENT_BRANCH_PREFIX)
IF("${BRANCH}" STREQUAL "__SKIPME")
MESSAGE(STATUS "Note: ${BRANCH_VARIABLE_NAME} has been disabled by setting it to __SKIPME")
ELSE("${BRANCH}" STREQUAL "__SKIPME")
SET(SUBDIR ${FULLPATH}/${BRANCH})
SET(SUBDIR ${BRANCH})
ENDIF("${BRANCH}" STREQUAL "__SKIPME")
ELSE(${BRANCH_VARIABLE_NAME})
SET(SUBDIR ${FULLPATH}/${OV_TRUNK})
SET(SUBDIR ${OV_TRUNK})
ENDIF(${BRANCH_VARIABLE_NAME})
IF(SUBDIR)
......@@ -36,10 +39,16 @@ FUNCTION(OV_ADD_PROJECTS CURRENT_BRANCH_PREFIX)
# Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir
GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
SET(OV_TMP "${OV_TMP};${SUBDIR}")
SET(OV_TMP "${OV_TMP};${FULLPATH}/${SUBDIR}")
SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
add_subdirectory(${SUBDIR})
# MESSAGE(STATUS "BDIR ${OV_CURRENT_BINARY_DIR}/${SUBDIR}")
GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR)
SET(OV_TMP "${OV_TMP};${OV_CURRENT_BINARY_DIR}/${SUBDIR}")
SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR ${OV_TMP})
add_subdirectory(${FULLPATH}/${SUBDIR})
ENDIF(SUBDIR)
ENDIF(IS_DIRECTORY ${FULLPATH} AND NOT ${FULLPATH} MATCHES ".*\\.svn")
......
......@@ -24,11 +24,11 @@ FUNCTION(OV_ADD_SINGLE_PROJECT CURRENT_BRANCH_PREFIX)
IF("${BRANCH}" STREQUAL "__SKIPME")
MESSAGE(STATUS "Note: ${BRANCH_VARIABLE_NAME} has been disabled by setting it to __SKIPME")
ELSE("${BRANCH}" STREQUAL "__SKIPME")
SET(SUBDIR "${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH}")
SET(SUBDIR "${BRANCH}")
ENDIF("${BRANCH}" STREQUAL "__SKIPME")
ELSE(${BRANCH_VARIABLE_NAME})
# MESSAGE(STATUS "Going for trunk...")
SET(SUBDIR "${CMAKE_CURRENT_SOURCE_DIR}/${OV_TRUNK}")
SET(SUBDIR "${OV_TRUNK}")
ENDIF(${BRANCH_VARIABLE_NAME})
IF(SUBDIR)
......@@ -36,10 +36,16 @@ FUNCTION(OV_ADD_SINGLE_PROJECT CURRENT_BRANCH_PREFIX)
# Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir.
GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
SET(OV_TMP "${OV_TMP};${SUBDIR}")
SET(OV_TMP "${OV_TMP};${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
ADD_SUBDIRECTORY(${SUBDIR})
# MESSAGE(STATUS "BDIR ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}")
GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR)
SET(OV_TMP "${OV_TMP};${CMAKE_CURRENT_BINARY_DIR}/${SUBDIR}")
SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR ${OV_TMP})
ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR})
ENDIF(SUBDIR)
......
......@@ -3,30 +3,153 @@
#include "ovpiCPluginObjectDescEnumAlgorithmSnapshotGenerator.h"
#include <iostream>
#include <sstream>
#include <string>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;
using namespace std;
typedef struct _SConfiguration
{
_SConfiguration(void) :
m_bKernelPathOverload(false),
m_bLoadPluginsFromPaths(false),
m_bDumpPathOverload(false),
m_bConfigPathOverload(false)
{}
bool m_bKernelPathOverload;
bool m_bLoadPluginsFromPaths;
bool m_bDumpPathOverload;
bool m_bConfigPathOverload;
std::string m_sKernelPath;
std::string m_sDumpPath;
std::string m_sConfigPath;
std::vector<std::string> m_vPluginPaths;
} SConfiguration;
boolean parse_arguments(int argc, char** argv, SConfiguration& rConfiguration)
{
int i;
std::vector < std::string > l_vArgValue;
std::vector < std::string >::const_iterator it;
for(i=1; i<argc; i++)
{
l_vArgValue.push_back(argv[i]);
}
for(it=l_vArgValue.begin(); it!=l_vArgValue.end(); it++)
{
if (*it=="-h" || *it=="--help")
{
std::cout << "Usage: " << argv[0] << " [-p <dir1:dir2...>] [-d <dump_path>]" << std::endl;
return true;
}
// get a list of folders to load plugins from
else if (*it=="-p")
{
if (it + 1 != l_vArgValue.end())
{
std::string l_sPluginDirectories = *++it;
// split the argument to separate paths, the delimiter is ":"
std::stringstream ss(l_sPluginDirectories);
std::string item;
while(std::getline(ss, item, ';'))
{
rConfiguration.m_vPluginPaths.push_back(item);
}
rConfiguration.m_bLoadPluginsFromPaths = true;
}
else
{
return false;
}
}
// Configuration path
else if (*it=="-c")
{
if (it + 1 != l_vArgValue.end())
{
rConfiguration.m_bConfigPathOverload = true;
rConfiguration.m_sConfigPath = *++it;
}
else
{
return false;
}
}
// Kernel path
else if (*it=="-k")
{
if (it + 1 != l_vArgValue.end())
{
rConfiguration.m_bKernelPathOverload = true;
rConfiguration.m_sKernelPath = *++it;
}
else
{
return false;
}
}
// Dump path
else if (*it=="-d")
{
if (it + 1 != l_vArgValue.end())
{
rConfiguration.m_bDumpPathOverload = true;
rConfiguration.m_sDumpPath = *++it;
}
else
{
return false;
}
}
}
return true;
}
int main(int argc, char ** argv)
{
//___________________________________________________________________//
// //
SConfiguration l_oConfiguration;
if (!parse_arguments(argc, argv, l_oConfiguration))
{
std::cout << "Error parsing arguments" << std::endl;
}
CKernelLoader l_oKernelLoader;
cout<<"[ INF ] Created kernel loader, trying to load kernel module"<<endl;
CString l_sError;
#if defined OVPI_OS_Windows
CString l_sKernelFile = OpenViBE::Directories::getLibDir() + "/openvibe-kernel.dll";
CString l_sKernelFile = "/openvibe-kernel.dll";
#else
CString l_sKernelFile = OpenViBE::Directories::getLibDir() + "/libopenvibe-kernel.so";
CString l_sKernelFile = "/libopenvibe-kernel.so";
#endif
if (l_oConfiguration.m_bKernelPathOverload)
{
l_sKernelFile = CString(l_oConfiguration.m_sKernelPath.c_str()) + l_sKernelFile;
}
else
{
l_sKernelFile = OpenViBE::Directories::getLibDir() + l_sKernelFile;
}
if(!l_oKernelLoader.load(l_sKernelFile, &l_sError))
{
cout<<"[ FAILED ] Error loading kernel ("<<l_sError<<")" << " from [" << l_sKernelFile << "]\n";
cout<<"[ FAILED ] Error loading kernel ("<<l_sError<<")" << " from [" << l_sKernelFile << "]\n";
}
else
{
......@@ -42,7 +165,13 @@ int main(int argc, char ** argv)
else
{
cout<<"[ INF ] Got kernel descriptor, trying to create kernel"<<endl;
l_pKernelContext=l_pKernelDesc->createKernel("plugin-inspector", OpenViBE::Directories::getDataDir() + "/openvibe.conf" );
CString l_sConfigPath = OpenViBE::Directories::getDataDir() + "/openvibe.conf";
if (l_oConfiguration.m_bConfigPathOverload)
{
l_sConfigPath = CString(l_oConfiguration.m_sConfigPath.c_str());
}
l_pKernelContext=l_pKernelDesc->createKernel("plugin-inspector", l_sConfigPath );
if(!l_pKernelContext)
{
cout<<"[ FAILED ] No kernel created by kernel descriptor"<<endl;
......@@ -53,7 +182,31 @@ int main(int argc, char ** argv)
IConfigurationManager& l_rConfigurationManager=l_pKernelContext->getConfigurationManager();
l_pKernelContext->getPluginManager().addPluginsFromFiles(l_rConfigurationManager.expand("${Kernel_Plugins}"));
if (l_oConfiguration.m_bLoadPluginsFromPaths)
{
l_pKernelContext->getLogManager() << LogLevel_Info << "Loading plugins from specified folders\n";
std::string l_sPluginPattern;
// Choose the right pattern for libraries to load depending on the OS
#if defined TARGET_OS_Windows
l_sPluginPattern = "openvibe-plugins-*.dll";
#elif defined TARGET_OS_Linux
l_sPluginPattern = "libopenvibe-plugins-*.so";
#endif
typedef std::vector<std::string>::iterator stringVectorIt;
for (stringVectorIt it = l_oConfiguration.m_vPluginPaths.begin(); it != l_oConfiguration.m_vPluginPaths.end(); ++it)
{
std::string l_sPluginPath = *it + "/" + l_sPluginPattern;
std::cout << l_sPluginPath << std::endl;
l_pKernelContext->getPluginManager().addPluginsFromFiles(CString(l_sPluginPath.c_str()));
}
}
else
{
l_pKernelContext->getLogManager() << LogLevel_Info << "Loading plugins as specified by kernel\n";
l_pKernelContext->getPluginManager().addPluginsFromFiles(l_rConfigurationManager.expand("${Kernel_Plugins}"));
}
//initialise Gtk before 3D context
gtk_init(&argc, &argv);
......@@ -61,14 +214,34 @@ int main(int argc, char ** argv)
if(l_rConfigurationManager.expandAsBoolean("${Kernel_3DVisualisationEnabled}"))
{
l_pKernelContext->getVisualisationManager().initialize3DContext();
// l_pKernelContext->getVisualisationManager().initialize3DContext();
}
CString l_sGlobalDefinesDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpGlobalDefinesDirectory}");
CString l_sAlgorithmSnapshotDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpAlgorithmSnapshotDirectory}");
CString l_sAlgorithmDocTemplateDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpAlgorithmDocTemplateDirectory}");
CString l_sBoxAlgorithmSnapshotDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpBoxAlgorithmSnapshotDirectory}");
CString l_sBoxAlgorithmDocTemplateDirectory=l_rConfigurationManager.expand("${PluginInspector_DumpBoxAlgorithmDocTemplateDirectory}");
CString l_sGlobalDefinesDirectory = "";
CString l_sAlgorithmSnapshotDirectory = "";
CString l_sAlgorithmDocTemplateDirectory = "";
CString l_sBoxAlgorithmSnapshotDirectory = "";
CString l_sBoxAlgorithmDocTemplateDirectory = "";
if (l_oConfiguration.m_bDumpPathOverload)
{
l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping stuff to [" << l_oConfiguration.m_sDumpPath.c_str() << "]\n";
l_sAlgorithmSnapshotDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/algorithm-snapshots";
l_sAlgorithmDocTemplateDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/algorithm-doc";
l_sBoxAlgorithmSnapshotDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/box-algorithm-snapshots";
l_sBoxAlgorithmDocTemplateDirectory = CString(l_oConfiguration.m_sDumpPath.c_str()) + "/box-algorithm-doc";
l_sGlobalDefinesDirectory = CString(l_oConfiguration.m_sDumpPath.c_str());
}
else
{
l_pKernelContext->getLogManager() << LogLevel_Info << "Loading paths from Kernel configuration\n";
l_sAlgorithmSnapshotDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpAlgorithmSnapshotDirectory}");
l_sAlgorithmDocTemplateDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpAlgorithmDocTemplateDirectory}");
l_sBoxAlgorithmSnapshotDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpBoxAlgorithmSnapshotDirectory}");
l_sBoxAlgorithmDocTemplateDirectory=l_rConfigurationManager.expand("${PluginInspector_DumpBoxAlgorithmDocTemplateDirectory}");
l_sGlobalDefinesDirectory =l_rConfigurationManager.expand("${PluginInspector_DumpGlobalDefinesDirectory}");
}
l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping global defines...\n";
if(l_sGlobalDefinesDirectory!=CString(""))
......@@ -81,7 +254,7 @@ int main(int argc, char ** argv)
l_pKernelContext->getLogManager() << LogLevel_Info << "Skipped, related PluginInspector tokens are empty in openvibe.conf\n";
}
l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping algorithm snapshots...\n";
l_pKernelContext->getLogManager() << LogLevel_Info << "Dumping algorithm snapshots... to [" << l_sAlgorithmSnapshotDirectory << "]\n";
if(l_sAlgorithmSnapshotDirectory!=CString("") && l_sAlgorithmDocTemplateDirectory!=CString(""))
{
CPluginObjectDescEnumAlgorithmSnapshotGenerator l_oAlgorithmSnapshotGenerator(*l_pKernelContext, l_sAlgorithmSnapshotDirectory, l_sAlgorithmDocTemplateDirectory);
......
......@@ -14,6 +14,7 @@ FIND_PROGRAM(doxygen_bin "doxygen" PATHS ${OV_CUSTOM_DEPENDENCIES_PATH}/bin NO_D
FIND_PROGRAM(doxygen_bin "doxygen" PATHS ${OV_CUSTOM_DEPENDENCIES_PATH}/bin "C:/Program Files/doxygen/bin")
IF(doxygen_bin)
MESSAGE(STATUS " Found doxygen...")
# intializes the variable that will be used in the doxyfile for input
......@@ -24,6 +25,7 @@ IF(doxygen_bin)
# copy to the target directory
SET(resource_files "")
SET(DOX_PART_FILES "")
# iterates on each project we have
#
# for each project, we look at its resources and store them in a list
......@@ -38,7 +40,7 @@ IF(doxygen_bin)
# updates the doxyfile variable for input directories
SET(ov_doxy_input "${ov_doxy_input} \"${current_project_src}\"")
MESSAGE(STATUS " [ OK ] Candidate doc directory found ${current_project_src}")
#MESSAGE(STATUS " [ OK ] Candidate doc directory found ${current_project_src}")
# looks for resources and stores them in a list
FILE(GLOB_RECURSE resource_files_tmp "${current_project_src}/*.png" "${current_project_src}/*.svg" "${current_project_src}/*.css" "${current_project_src}/*.php")
......@@ -46,162 +48,63 @@ IF(doxygen_bin)
# looks for partial hand written documentation
FILE(GLOB_RECURSE doxs "${current_project_src}/*.dox-part")
FOREACH(dox ${doxs})
GET_FILENAME_COMPONENT(dox_filename ${dox} NAME_WE)
# MESSAGE(STATUS " Documentation part found ${dox}")
SET(dox_tag_name NOTFOUND)
# iterates on each line of the file to look after begin/end tags
# "dox_tag_name" stores the name of the variable
# to use to configure the skeleton file. It is computed from the
# begin tag.
FILE(READ ${dox} dox_lines)
# replaces empty cariage returns with semi colons to be compliant
# with CMake lists. note the space before and after the semi
# colon, this is for CMake not to skip empty lines
STRING(REPLACE "\n" " ; " dox_lines " ${dox_lines} ")
FOREACH(dox_line ${dox_lines})
# this regex removes the spaces we added before the loop
STRING(REGEX REPLACE "^ (.*) $" "\\1" dox_line ${dox_line})
# we initialize several variables that will be used in
# this loop
SET(dox_line_processed FALSE)
SET(dox_tag_begin NOTFOUND)
SET(dox_tag_end NOTFOUND)
SET(dox_tag NOTFOUND)
# and look for a new tag in this line
STRING(REGEX MATCH "\\|[a-zA-Z0-9_]*\\|" dox_tag "${dox_line}")
IF(dox_tag)
# a tag is found, so we want to know if it is a
# OVP_DocBegin* or OVP_DocEnd* tag
STRING(REGEX MATCH "\\|OVP_DocBegin_[a-zA-Z0-9_]*\\|" dox_tag_begin "${dox_line}")
STRING(REGEX MATCH "\\|OVP_DocEnd_[a-zA-Z0-9_]*\\|" dox_tag_end "${dox_line}")
# in case we already have something in
# dox_tag_name, it means that begin tag has
# already been processed, so either we terminate with end
# tag, either we continue with come content to add in the
# variable
IF(dox_tag_name AND dox_tag_end)
# in case we find end tag, we just terminate cleaning
# the tag and what follows. We then terminate and
# create a new CMake variable with the content of this
# begin/end tagged things.
STRING(REGEX REPLACE ".*\\|OVP_DocEnd_([a-zA-Z0-9_]*)\\|.*" "\\1" dox_tag_name_check ${dox_line})
STRING(REGEX REPLACE "\\|OVP_DocEnd_([a-zA-Z0-9_]*)\\|.*" "" dox_line "${dox_line}")
# MESSAGE(STATUS " - Completed tag pair |${dox_tag_name}|")
SET(dox_tag_name_value "${dox_tag_name_value}\n${dox_line}")
SET("Doc_${dox_tag_name}_Content" ${dox_tag_name_value})
SET(dox_tag_name NOTFOUND)
SET(dox_line_processed TRUE)
ENDIF(dox_tag_name AND dox_tag_end)
# in case dox_tag_name is empty, it means
# that begin tag has not yet been found, so we just look at it
# or skip to next line
IF(NOT dox_tag_name AND dox_tag_begin)
# in case we find begin tag, we just start saving the
# CMake variable name, and clean the tag and what
# comes before. We then intialize the content of the
# begin/end tagged thing with what comes after begin
# tag.
STRING(REGEX REPLACE ".*\\|OVP_DocBegin_([a-zA-Z0-9_]*)\\|.*" "\\1" dox_tag_name ${dox_line})
STRING(REGEX REPLACE ".*\\|OVP_DocBegin_([a-zA-Z0-9_]*)\\|" "" dox_line "${dox_line}")
SET(dox_tag_name_value "${dox_line}")
SET(dox_line_processed TRUE)
ENDIF(NOT dox_tag_name AND dox_tag_begin)
# in case dox tag is not OVP_DocBegin* or OVP_DocEnd*
# just print a warning and continue
IF(NOT dox_line_processed)
MESSAGE(STATUS " - Unexpected tag ${dox_tag} in ${dox} will be ignored")
ENDIF(NOT dox_line_processed)
ENDIF(dox_tag)
# in case this line was not processed, either because it does
# not have any tag, either because the tag was unexpected, we
# just append the whole line to the content of the current
# variable
IF(dox_tag_name AND NOT dox_line_processed)
# in case we don't find the end tag, just append this
# new line to the current content
SET(dox_tag_name_value "${dox_tag_name_value}\n${dox_line}")
ENDIF(dox_tag_name AND NOT dox_line_processed)
ENDFOREACH(dox_line)
ENDFOREACH(dox)
SET(DOX_PART_FILES "${DOX_PART_FILES};${doxs}")
ENDFOREACH(current_project)
# now we have stored all the begin/end tagged things in variable, we just
# have to configure the skeleton configuration files with those variables.
# note that the skeleton files should be prepared to receive the CMake
# variables with @CMakeVariableName@ anywhere it is needed.
#
# in order to do so, we look after all the (.dox-skeleton) files and call
# the configure command to build the final documentation (.dox) file.
FILE(GLOB_RECURSE dox_skeletons "${PROJECT_SOURCE_DIR}/src/*.dox-skeleton")
FOREACH(dox_skeleton ${dox_skeletons})
GET_FILENAME_COMPONENT(dox_skeleton_filename ${dox_skeleton} NAME_WE)
CONFIGURE_FILE(
"${dox_skeleton}"
"${CMAKE_CURRENT_BINARY_DIR}/${dox_skeleton_filename}.dox"
@ONLY)
MESSAGE(STATUS " [ OK ] Configured skeleton ${dox_skeleton}")
ENDFOREACH(dox_skeleton)
# look for box snapshots generated by the plugin inspector
FILE(GLOB_RECURSE resource_files_tmp "${CMAKE_CURRENT_BINARY_DIR}/*.png")
SET(resource_files ${resource_files} ${resource_files_tmp})
IF(resource_files)
INSTALL(FILES ${resource_files} DESTINATION "doc/openvibe/html")
INSTALL(FILES ${resource_files} DESTINATION "${CMAKE_INSTALL_FULL_DOCDIR}")
ENDIF(resource_files)
# the final doxyfile filename is generated, platform compliantly
SET(ov_doxy_final "${CMAKE_CURRENT_BINARY_DIR}/doxyfile")
IF(WIN32)
STRING(REPLACE "/" "\\" ov_doxy_final ${ov_doxy_final})
STRING(REPLACE "/" "\\\\" ov_doxy_final ${ov_doxy_final})
ENDIF(WIN32)
# these two lines configure the variables used to configure the doxyfile
SET(ov_doxy_input "${ov_doxy_input} \"${CMAKE_CURRENT_BINARY_DIR}\"")
SET(ov_doxy_strip_from_path ${ov_doxy_input})
SET(ov_doxy_version ${PROJECT_VERSION})
# then the doxyfile is configured
GET_PROPERTY(CURRENT_PROJECTS GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR)
FOREACH(current_project ${CURRENT_PROJECTS})
# MESSAGE(STATUS "DUH ${current_project}")
STRING(REGEX REPLACE " +$" "" current_project ${current_project})
SET(current_project_src "${current_project}/src")
# updates the doxyfile variable for input directories
SET(ov_plugin_inspector_load_path "${ov_plugin_inspector_load_path}:${current_project}")
ENDFOREACH(current_project)
# create folder to put the output from doxygen to
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../doc")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../doc/html")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/algorithm-doc")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/algorithm-snapshots")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/box-algorithm-doc")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/box-algorithm-snapshots")
# then the doxyfile is configured
CONFIGURE_FILE(
doxyfile-skeleton
${ov_doxy_final}
CreateDoxygen.cmake-skeleton
CreateDoxygen.cmake
@ONLY)
# and a post-build command is added in order to run doxygen
ADD_CUSTOM_COMMAND(
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND "${doxygen_bin}" "${ov_doxy_final}"
POST_BUILD
COMMAND cmake -P CreateDoxygen.cmake
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT " ---> Running doxygen..."
VERBATIM)
# 'patch' the docs, this takes some time, is it worth doing it?
# original linux-build directive:
# find $target_dist/doc -name *.html -exec sed -i -e "s/\xC2\?\xA7OpenViBE\xC2\?\xA7/OpenViBE/g" "{}" \;
# \xC2\?\xA7 is the § character that has been put everywhere to clearly make the distinction between the project and the software
INSTALL(CODE "
MESSAGE(STATUS \"Patching special characters in HTML docs ...\")
FILE(GLOB_RECURSE HTML_DOCS \"\${CMAKE_CURRENT_BINARY_DIR}/../doc/html/\" \"*.html\")
# MESSAGE(STATUS \"got \${HTML_DOCS}\")
FOREACH(HTML_DOC \${HTML_DOCS})
# MESSAGE(STATUS \"Processing \${HTML_DOC}\")
FILE(READ \${HTML_DOC} ORIG_FILE)
STRING(REPLACE \"§OpenViBE§\" \"OpenViBE\" TRANSLATED_FILE \${ORIG_FILE})
FILE(WRITE \${HTML_DOC} \${TRANSLATED_FILE})
ENDFOREACH(HTML_DOC)
")
# doxygen will generate files in the first directory, install from there
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../doc/html DESTINATION "./doc/openvibe" REGEX ".*\\.svn|.*\\.tmp" EXCLUDE)
)
INSTALL(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../doc/html/" DESTINATION ${CMAKE_INSTALL_FULL_DOCDIR} PATTERN ".svn" EXCLUDE)
ELSE(doxygen_bin)
MESSAGE(STATUS " FAILED to find doxygen...")
......
# Author Yann Renard / INRIA
# Date 2008-10-15
#
# this CMake script iterates over several source documentation directories in
# order to compile it with doxygen. It has the ability to configure the
# doxyfile depending on some variables and to build documentation sources from
# computer generated templates (.dox-skeleton) and hand written documentation
# parts (.dox-part)
MESSAGE(STATUS "Launching Create Doxygen CMake script")
SET(resource_files "@resource_files@")
SET(ov_doxy_final "@ov_doxy_final@")
SET(ov_doxy_version "@ov_doxy_version@")
SET(CURRENT_PROJECTS "@CURRENT_PROJECTS@")
SET(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
FOREACH(current_project ${CURRENT_PROJECTS})
STRING(REGEX REPLACE " +$" "" current_project ${current_project})
SET(current_project_src "${current_project}/src")
# updates the doxyfile variable for input directories
SET(ov_plugin_inspector_load_path "${ov_plugin_inspector_load_path};${current_project}")
ENDFOREACH(current_project)
MESSAGE(STATUS "Running plugin inspector")
IF(UNIX)
EXECUTE_PROCESS(
COMMAND @CMAKE_CURRENT_BINARY_DIR@/../../../openvibe-applications/plugin-inspector/trunc/openvibe-plugin-inspector
-d "@CMAKE_CURRENT_BINARY_DIR@" -p ${ov_plugin_inspector_load_path}
-k "@CMAKE_CURRENT_BINARY_DIR@/../../../openvibe-kernel-omk/trunc"
-c "@CMAKE_SOURCE_DIR@/openvibe-kernel-omk/trunc/share/openvibe.conf"
WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/../../../openvibe-applications/plugin-inspector/trunc"
)
ELSEIF(WIN32)
EXECUTE_PROCESS(
COMMAND @CMAKE_CURRENT_SOURCE_DIR@/openvibe-plugin-inspector.cmd @CMAKE_SOURCE_DIR@ @CMAKE_CURRENT_BINARY_DIR@/../../..
-d "@CMAKE_CURRENT_BINARY_DIR@" -p ${ov_plugin_inspector_load_path}
-k "@CMAKE_CURRENT_BINARY_DIR@/../../../openvibe-kernel-omk/trunc"
-c "@CMAKE_SOURCE_DIR@/openvibe-kernel-omk/trunc/share/openvibe.conf"
WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/../../../openvibe-applications/plugin-inspector/trunc"
)
ENDIF(UNIX)
#go through all of the .dox-part files we have found previously and extract information
FOREACH(dox @DOX_PART_FILES@)
GET_FILENAME_COMPONENT(dox_filename ${dox} NAME_WE)
MESSAGE(STATUS " Documentation part found ${dox}")
SET(dox_tag_name NOTFOUND)
# iterates on each line of the file to look after begin/end tags
# "dox_tag_name" stores the name of the variable
# to use to configure the skeleton file. It is computed from the
# begin tag.
FILE(READ ${dox} dox_lines)
# replaces empty cariage returns with semi colons to be compliant
# with CMake lists. note the space before and after the semi
# colon, this is for CMake not to skip empty lines
STRING(REPLACE "\n" " ; " dox_lines " ${dox_lines} ")
FOREACH(dox_line ${dox_lines})
# this regex removes the spaces we added before the loop
STRING(REGEX REPLACE "^ (.*) $" "\\1" dox_line ${dox_line})
# we initialize several variables that will be used in
# this loop
SET(dox_line_processed FALSE)
SET(dox_tag_begin NOTFOUND)
SET(dox_tag_end NOTFOUND)
SET(dox_tag NOTFOUND)
# and look for a new tag in this line
STRING(REGEX MATCH "\\|[a-zA-Z0-9_]*\\|" dox_tag "${dox_line}")
IF(dox_tag)
# a tag is found, so we want to know if it is a
# OVP_DocBegin* or OVP_DocEnd* tag
STRING(REGEX MATCH "\\|OVP_DocBegin_[a-zA-Z0-9_]*\\|" dox_tag_begin "${dox_line}")
STRING(REGEX MATCH "\\|OVP_DocEnd_[a-zA-Z0-9_]*\\|" dox_tag_end "${dox_line}")
# in case we already have something in
# dox_tag_name, it means that begin tag has
# already been processed, so either we terminate with end
# tag, either we continue with come content to add in the
# variable
IF(dox_tag_name AND dox_tag_end)
# in case we find end tag, we just terminate cleaning
# the tag and what follows. We then terminate and
# create a new CMake variable with the content of this
# begin/end tagged things.
STRING(REGEX REPLACE ".*\\|OVP_DocEnd_([a-zA-Z0-9_]*)\\|.*" "\\1" dox_tag_name_check ${dox_line})
STRING(REGEX REPLACE "\\|OVP_DocEnd_([a-zA-Z0-9_]*)\\|.*" "" dox_line "${dox_line}")
# MESSAGE(STATUS " - Completed tag pair |${dox_tag_name}|")
SET(dox_tag_name_value "${dox_tag_name_value}\n${dox_line}")
SET("Doc_${dox_tag_name}_Content" ${dox_tag_name_value})
SET(dox_tag_name NOTFOUND)
SET(dox_line_processed TRUE)
ENDIF(dox_tag_name AND dox_tag_end)
# in case dox_tag_name is empty, it means
# that begin tag has not yet been found, so we just look at it
# or skip to next line
IF(NOT dox_tag_name AND dox_tag_begin)
# in case we find begin tag, we just start saving the
# CMake variable name, and clean the tag and what
# comes before. We then intialize the content of the
# begin/end tagged thing with what comes after begin
# tag.
STRING(REGEX REPLACE ".*\\|OVP_DocBegin_([a-zA-Z0-9_]*)\\|.*" "\\1" dox_tag_name ${dox_line})
STRING(REGEX REPLACE ".*\\|OVP_DocBegin_([a-zA-Z0-9_]*)\\|" "" dox_line "${dox_line}")
SET(dox_tag_name_value "${dox_line}")
SET(dox_line_processed TRUE)
ENDIF(NOT dox_tag_name AND dox_tag_begin)
# in case dox tag is not OVP_DocBegin* or OVP_DocEnd*
# just print a warning and continue
IF(NOT dox_line_processed)
MESSAGE(STATUS " - Unexpected tag ${dox_tag} in ${dox} will be ignored")
ENDIF(NOT dox_line_processed)
ENDIF(dox_tag)
# in case this line was not processed, either because it does
# not have any tag, either because the tag was unexpected, we
# just append the whole line to the content of the current
# variable