]> git.lyx.org Git - features.git/commitdiff
Adapt tex2lyx roundtrip to cmake build.
authorKornel Benko <kornel@lyx.org>
Mon, 30 Jul 2012 07:30:16 +0000 (09:30 +0200)
committerKornel Benko <kornel@lyx.org>
Mon, 30 Jul 2012 07:30:16 +0000 (09:30 +0200)
Use build tree only.

CMakeLists.txt
lib/examples/CMakeLists.txt [new file with mode: 0644]
src/tex2lyx/CMakeLists.txt
src/tex2lyx/test/CMakeLists.txt [new file with mode: 0644]
src/tex2lyx/test/runtests.py

index 2766fcd7297558e77e88a19322692cc32fbb1b3e..e3dfa48f7e20f4e956b90f6538eadc26b6e39f5e 100644 (file)
@@ -668,6 +668,7 @@ endif()
 add_subdirectory(src "${TOP_BINARY_DIR}/src")
 add_subdirectory(lib/lyx2lyx "${TOP_BINARY_DIR}/lyx2lyx")
 add_subdirectory(lib/scripts "${TOP_BINARY_DIR}/scripts")
+add_subdirectory(lib/examples "${TOP_BINARY_DIR}/lib/examples")
 
 
 if(LYX_INSTALL)
diff --git a/lib/examples/CMakeLists.txt b/lib/examples/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5e78b27
--- /dev/null
@@ -0,0 +1,11 @@
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# Copyright (c) 2012 Kornel Benko, <kornel@lyx.org>
+#
+
+project(test)
+
+foreach(_arg longsheet.gnumeric iecc05.fen beamer-icsi-logo.pdf)
+  configure_file(${_arg} "${CMAKE_CURRENT_BINARY_DIR}/${_arg}" COPYONLY)
+endforeach(_arg)
index 00a577f323af8759124cf86076343a64bd8df662..f032d4d36b6d9ab4faff971e8818d00e5e8a770c 100644 (file)
@@ -63,6 +63,8 @@ endif()
 
 project_source_group("${GROUP_CODE}" tex2lyx_sources tex2lyx_headers)
 
+add_subdirectory(test)
+
 if(LYX_BUNDLE)
        install(TARGETS ${_tex2lyx}
                RUNTIME DESTINATION bin
diff --git a/src/tex2lyx/test/CMakeLists.txt b/src/tex2lyx/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..19abf65
--- /dev/null
@@ -0,0 +1,35 @@
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# Copyright (c) 2012 Kornel Benko, <kornel@lyx.org>
+#
+
+project(test)
+
+set(_test_depend "${TOP_SRC_DIR}/src/tex2lyx/test/test.ltx")
+set(_test_output "${TOP_SRC_DIR}/src/tex2lyx/test/test.lyx.tex")
+foreach(_arg runtests.py DummyDocument.tex test.ltx foo.eps foo.png)
+  configure_file("${TOP_SRC_DIR}/src/tex2lyx/test/${_arg}" "${CMAKE_CURRENT_BINARY_DIR}/${_arg}" COPYONLY)
+endforeach(_arg)
+
+foreach(_arg test-structure test-insets box-color-size-space-align CJK XeTeX-polyglossia)
+  add_custom_command(
+    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.tex"
+    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/src/tex2lyx/test/${_arg}.tex" "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.tex"
+    DEPENDS "${TOP_SRC_DIR}/src/tex2lyx/test/${_arg}.tex"
+    )
+  list(APPEND _test_depend "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.tex")
+  list(APPEND _test_output "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.lyx.tex")
+  list(APPEND _test_output "${CMAKE_CURRENT_BINARY_DIR}/${_arg}.lyx.lyx")
+endforeach(_arg)
+
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${_test_output}
+  COMMAND ${LYX_PYTHON_EXECUTABLE}
+  ARGS "${CMAKE_CURRENT_BINARY_DIR}/runtests.py" "${TOP_BINARY_DIR}/bin/${_tex2lyx}" "${TOP_SRC_DIR}/lib/scripts"
+  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+  DEPENDS ${_tex2lyx} ${_test_depend}
+)
+
+ADD_CUSTOM_TARGET(test DEPENDS ${_tex2lyx} ${_test_output})
+
index 2478e9c920a4bd4fa170e7a9f18fb952e958d581..084e8e1258593369015239aaa17f6eafdc091dde 100755 (executable)
@@ -15,17 +15,21 @@ import os, string, sys
 
 
 def usage(prog_name):
-    return "Usage: %s [<tex2lyx binary>]" % prog_name
+  return "Usage: %s [<tex2lyx binary> [<script dir>]]" % prog_name
 
 
 def main(argv):
     # Parse and manipulate the command line arguments.
-    sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../../../lib/scripts'))
+    if len(argv) == 3:
+       sys.path.append(os.path.join(sys.argv[2]))
+    else:
+       sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../../../lib/scripts'))
+
     from lyxpreview_tools import error
 
-    if len(argv) == 1:
+    if len(argv) < 2:
         tex2lyx = './tex2lyx'
-    elif len(argv) == 2:
+    elif len(argv) <= 3:
         tex2lyx = argv[1]
     else:
         error(usage(argv[0]))