doc_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome"
head_source = "${CMAKE_CURRENT_SOURCE_DIR}/images/head.png"
if mod == 'kernel':
- copytree_src = "${CMAKE_SOURCE_DIR}/salome_adm/cmake_files"
+ prepare_generating_doc_src = "${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/prepare_generating_doc.py"
else:
- copytree_src = "$ENV{KERNEL_ROOT_DIR}/salome_adm/cmake_files"
- str = "import re \nimport sys \noutfile = open(sys.argv[1], 'wb') \nfor line in open(sys.argv[2], 'rb').readlines():"
- str += "\n if re.match('class '+sys.argv[3]+'DC', line): \n continue \n line = re.sub(r'^\\\\s+\#', '#', line) \n line = re.sub(r'^\\\\s+def', 'def', line) \n line = re.sub(sys.argv[3]+'DC', sys.argv[3], line)"
- str += "\n outfile.write(line) \noutfile.close()"
-
+ prepare_generating_doc_src = "$ENV{KERNEL_ROOT_DIR}/bin/salome/prepare_generating_doc.py"
if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'):
if mod == 'med':
doc_source = "${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html"
doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
input = ""
newlines.append("""\t ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} %s
- COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')"
+ COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')"
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )"""%(input, copytree_src, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination))
+ )"""%(input, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination))
from os import path
if mod in ['geom', 'smesh', 'visu'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc'):
- ign = r"""'tempfile', '*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'"""
+ ign = r"""'*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'"""
if mod in ['geom', 'smesh']:
if mod == 'geom':
tmp = 'geompy'
tmp = 'smesh'
input = ''
newlines.append(r"""
- FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tempfile "%s")
- ADD_CUSTOM_TARGET(usr_docs ${PYTHON_EXECUTABLE} tempfile %s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
+ IF(WINDOWS)
+ STRING(REPLACE "/" "\\" f "%s")
+ ENDIF(WINDOWS)
+ ADD_CUSTOM_TARGET(usr_docs ${PYTHON_EXECUTABLE} ${f} %s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
%sCOMMAND ${DOXYGEN_EXECUTABLE} doxyfile_py
COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''%s.py''')"
- COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''', r'''%s''', ignore=copytree1.ignore_patterns(%s)); shutil.copy(r'''%s''', r'''%s''')"
+ COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''', r'''%s''', ignore=shutil.ignore_patterns(%s)); shutil.copy(r'''%s''', r'''%s''')"
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )"""%(str, tmp, upmod, tmp, tmp, input, tmp, copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
+ )"""%(prepare_generating_doc_src, tmp, upmod, tmp, tmp, input, tmp, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
else:
newlines.append("""\t ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} doxyfile_idl
COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
- COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''',True); import copytree1; copytree1.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''',r'''%s''', ignore=copytree1.ignore_patterns(%s)); shutil.copy(r'''%s''',r'''%s''')"
+ COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''',True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''',r'''%s''', ignore=shutil.ignore_patterns(%s)); shutil.copy(r'''%s''',r'''%s''')"
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )"""%(copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
+ )"""%(doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination))
elif mod == 'yacs' and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'):
from sys import platform
params = '';
tmp1=""
doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
newlines.append(tmp + """
- COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" """%(copytree_src, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination) + tmp1 + """
+ COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" """%(doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination) + tmp1 + """
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)""")
tmp = 'geompy'
doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod)
newlines.append(r"""
- FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tempfile "%s")
- ADD_CUSTOM_TARGET(dev_docs ${PYTHON_EXECUTABLE} tempfile ${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
+ IF(WINDOWS)
+ STRING(REPLACE "/" "\\" f "%s")
+ ENDIF(WINDOWS)
+ ADD_CUSTOM_TARGET(dev_docs ${PYTHON_EXECUTABLE} ${f} ${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s
COMMAND ${DOXYGEN_EXECUTABLE} doxyfile
COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py''')"
- COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/geomscreen.png''', r'''%s''')"
+ COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/geomscreen.png''', r'''%s''')"
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )"""%(str, upmod, tmp, upmod, tmp, tmp, upmod, tmp, copytree_src, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination, doc_tui_destination))
+ )"""%(prepare_generating_doc_src, upmod, tmp, upmod, tmp, tmp, upmod, tmp, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination, doc_tui_destination))
# --
# convert the SUBDIRS in cmake grammar
ELSE(f STREQUAL SALOME_ContainerPy.py)
IF(f STREQUAL am2cmake.py)
ELSE(f STREQUAL am2cmake.py)
- IF(f STREQUAL copytree1.py)
- ELSE(f STREQUAL copytree1.py)
INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake)
- ENDIF(f STREQUAL copytree1.py)
ENDIF(f STREQUAL am2cmake.py)
ENDIF(f STREQUAL SALOME_ContainerPy.py)
''')
+++ /dev/null
-import os
-import sys
-import stat
-from os.path import abspath
-import fnmatch
-
-import shutil
-
-class Error(EnvironmentError):
- pass
-try:
- WindowsError
-except NameError:
- WindowsError = None
-
-def ignore_patterns(*patterns):
- """Function that can be used as copytree() ignore parameter.
-
- Patterns is a sequence of glob-style patterns
- that are used to exclude files"""
- def _ignore_patterns(path, names):
- ignored_names = []
- for pattern in patterns:
- ignored_names.extend(fnmatch.filter(names, pattern))
- return set(ignored_names)
- return _ignore_patterns
-
-def copytree(src, dst, symlinks=False, ignore=None):
- """Recursively copy a directory tree using shutil.copy2().
-
- The destination directory must not already exist.
- If exception(s) occur, an Error is raised with a list of reasons.
-
- If the optional symlinks flag is true, symbolic links in the
- source tree result in symbolic links in the destination tree; if
- it is false, the contents of the files pointed to by symbolic
- links are copied.
-
- The optional ignore argument is a callable. If given, it
- is called with the `src` parameter, which is the directory
- being visited by copytree(), and `names` which is the list of
- `src` contents, as returned by os.listdir():
-
- callable(src, names) -> ignored_names
-
- Since copytree() is called recursively, the callable will be
- called once for each directory that is copied. It returns a
- list of names relative to the `src` directory that should
- not be copied.
-
- XXX Consider this example code rather than the ultimate tool.
-
- """
- names = os.listdir(src)
- if ignore is not None:
- ignored_names = ignore(src, names)
- else:
- ignored_names = set()
-
- os.makedirs(dst)
- errors = []
- for name in names:
- if name in ignored_names:
- continue
- srcname = os.path.join(src, name)
- dstname = os.path.join(dst, name)
- try:
- if symlinks and os.path.islink(srcname):
- linkto = os.readlink(srcname)
- os.symlink(linkto, dstname)
- elif os.path.isdir(srcname):
- copytree(srcname, dstname, symlinks, ignore)
- else:
- shutil.copy2(srcname, dstname)
- # XXX What about devices, sockets etc.?
- except (IOError, os.error), why:
- errors.append((srcname, dstname, str(why)))
- # catch the Error from the recursive copytree so that we can
- # continue with other files
- except Error, err:
- errors.extend(err.args[0])
- try:
- shutil.copystat(src, dst)
- except OSError, why:
- if WindowsError is not None and isinstance(why, WindowsError):
- # Copying file access times may fail on Windows
- pass
- else:
- errors.extend((src, dst, str(why)))
- if errors:
- raise Error, errors