From cf52bab93394aac4544fffdeb51ae24a0f438db7 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Fri, 20 May 2011 06:40:04 +0000 Subject: [PATCH] Remove the need for perl if creating doc git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38791 a592a061-630c-0410-9148-cb99ea01b6c8 --- CMakeLists.txt | 6 ++-- development/cmake/doc/CMakeLists.txt | 4 +-- development/cmake/doc/ReplaceValues.py | 45 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100755 development/cmake/doc/ReplaceValues.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d900702e5..b5005157d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -561,9 +561,9 @@ add_subdirectory(lib/scripts "${TOP_BINARY_DIR}/scripts") if(LYX_INSTALL) - FIND_PROGRAM(LYX_PERL_EXECUTABLE perl) - if(${LYX_PERL_EXECUTABLE} MATCHES "-NOTFOUND") - message(STATUS "Perl required to create doc!") + #FIND_PROGRAM(LYX_PERL_EXECUTABLE perl) + if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND") + message(STATUS "Python required to create doc!") else() add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man") add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc") diff --git a/development/cmake/doc/CMakeLists.txt b/development/cmake/doc/CMakeLists.txt index 73d2fb144e..82db821d3f 100644 --- a/development/cmake/doc/CMakeLists.txt +++ b/development/cmake/doc/CMakeLists.txt @@ -29,8 +29,8 @@ foreach(_rel_doc ${_rel_lyx_docs}) SET_SOURCE_FILES_PROPERTIES(${_created_doc} GENERATED) add_custom_command( OUTPUT "${_created_doc}" - COMMAND perl "${TOP_SRC_DIR}/development/cmake/doc/ReplaceValues.pl" "LYX_USERDIR_VER=${LYX_USERDIR_VER}" "LYX_DIR_VER=${LYX_DIR_VER}" "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}" - DEPENDS "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" + COMMAND ${LYX_PYTHON_EXECUTABLE} "${TOP_SRC_DIR}/development/cmake/doc/ReplaceValues.py" "LYX_USERDIR_VER=${LYX_USERDIR_VER}" "LYX_DIR_VER=${LYX_DIR_VER}" "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" > "${_created_doc}" + DEPENDS "${TOP_SRC_DIR}/lib/doc/${_rel_doc}" "${TOP_SRC_DIR}/development/cmake/doc/ReplaceValues.py" ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_rel_doc}" DESTINATION "${LYX_DATA_SUBDIR}doc/${_rel_dir_part}") LIST(APPEND _docs "${_created_doc}") diff --git a/development/cmake/doc/ReplaceValues.py b/development/cmake/doc/ReplaceValues.py new file mode 100755 index 0000000000..1dcb8f2a4c --- /dev/null +++ b/development/cmake/doc/ReplaceValues.py @@ -0,0 +1,45 @@ +#! /usr/bin/env python +import sys +import re + +Subst = {} # map of desired substitutions +prog = re.compile("") + +def createProg(): + matchingS = "\\b|\\b".join(Subst.keys()) + pattern = "".join(["(.*)(\\b", matchingS, "\\b)(.*)"]) + return re.compile(pattern) + +def SubstituteDataInLine(line): + result = line + m = prog.match(result) + if m: + return "".join([SubstituteDataInLine(m.group(1)), + Subst[m.group(2)], + SubstituteDataInLine(m.group(3))]) + return line + + +def SubstituteDataInFile(InFile): + for line in open(InFile): + print SubstituteDataInLine(line[:-1]) + +########################################## + + +args = sys.argv + +del args[0] # we don't need the name ot this script +while len(args) > 0: + arg = args[0] + entry = args[0].split("=",1) + if len(entry) == 2: + key=entry[0] + val=entry[1] + if len(key) > 0: + Subst[key] = val + else: + prog = createProg() + SubstituteDataInFile(args[0]) + del args[0] +