]> git.lyx.org Git - features.git/commitdiff
Remove the need for perl if creating doc
authorKornel Benko <kornel@lyx.org>
Fri, 20 May 2011 06:40:04 +0000 (06:40 +0000)
committerKornel Benko <kornel@lyx.org>
Fri, 20 May 2011 06:40:04 +0000 (06:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38791 a592a061-630c-0410-9148-cb99ea01b6c8

CMakeLists.txt
development/cmake/doc/CMakeLists.txt
development/cmake/doc/ReplaceValues.py [new file with mode: 0755]

index 3d900702e5cf543e1b66fde59af49fc7282ead41..b5005157d2f71ee522d116dcaf6fb3e2491cc645 100644 (file)
@@ -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")
index 73d2fb144ec0645e540476a1e266720dc19b9f42..82db821d3fe0baa6b633e37311a7487ba1a6466b 100644 (file)
@@ -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 (executable)
index 0000000..1dcb8f2
--- /dev/null
@@ -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]
+