2012-12-12 17:23:25 +00:00
|
|
|
# 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
|
|
|
|
#
|
|
|
|
#
|
2013-07-23 19:42:44 +00:00
|
|
|
# LYX_ROOT = ${TOP_SRC_DIR}/lib/{doc,examples,templates}
|
2013-08-21 11:34:26 +00:00
|
|
|
# LYX_USERDIR_VER = Name of environment variable for the user directory
|
2014-01-05 09:02:29 +00:00
|
|
|
# lyx =
|
2015-12-25 09:28:40 +00:00
|
|
|
# format = lyx16x|lyx21x|xhtml
|
|
|
|
# extension = 16.lyx|21.lyx|xhtml
|
2012-12-13 11:38:38 +00:00
|
|
|
# file = xxx
|
2012-12-12 17:23:25 +00:00
|
|
|
#
|
|
|
|
# Script should be called like:
|
|
|
|
# cmake -DLYX_ROOT=xxx \
|
2013-08-25 09:41:10 +00:00
|
|
|
# -DLYX_TESTS_USERDIR=${LYX_TESTS_USERDIR} \
|
2013-08-21 11:34:26 +00:00
|
|
|
# -DWORKDIR=${BUILD_DIR}/autotests/out-home \
|
|
|
|
# -DLYX_USERDIR_VER=${LYX_USERDIR_VER} \
|
2012-12-12 17:23:25 +00:00
|
|
|
# -Dlyx=xxx \
|
2012-12-13 11:38:38 +00:00
|
|
|
# -Dformat=xxx \
|
2013-12-16 10:36:36 +00:00
|
|
|
# -Dfonttype=xxx \
|
2012-12-13 11:38:38 +00:00
|
|
|
# -Dextension=xxx \
|
|
|
|
# -Dfile=xxx \
|
2015-12-02 23:23:07 +00:00
|
|
|
# -Dinverted=[01] \
|
2013-11-17 22:17:27 +00:00
|
|
|
# -DTOP_SRC_DIR=${TOP_SRC_DIR}
|
|
|
|
# -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
|
2012-12-12 17:23:25 +00:00
|
|
|
# -P "${TOP_SRC_DIR}/development/autotests/export.cmake"
|
|
|
|
#
|
2012-12-11 14:17:04 +00:00
|
|
|
|
2013-11-17 22:17:27 +00:00
|
|
|
set(Perl_Script "${TOP_SRC_DIR}/development/autotests/useSystemFonts.pl")
|
2015-12-27 13:33:11 +00:00
|
|
|
set(Structure_Script "${TOP_SRC_DIR}/development/autotests/beginEndStructureCheck.pl")
|
2015-11-10 18:42:43 +00:00
|
|
|
set(LanguageFile "${TOP_SRC_DIR}/lib/languages")
|
2015-03-28 20:21:16 +00:00
|
|
|
set(GetTempDir "${TOP_SRC_DIR}/development/autotests/getTempDir.pl")
|
2013-12-16 10:36:36 +00:00
|
|
|
set(_ft ${fonttype})
|
2015-03-28 20:21:16 +00:00
|
|
|
execute_process(COMMAND ${PERL_EXECUTABLE} "${GetTempDir}" "${WORKDIR}" OUTPUT_VARIABLE TempDir)
|
2013-12-16 10:36:36 +00:00
|
|
|
message(STATUS "using fonttype = ${_ft}")
|
2015-11-29 15:11:10 +00:00
|
|
|
if(format MATCHES "dvi|pdf")
|
2013-11-17 22:17:27 +00:00
|
|
|
message(STATUS "LYX_TESTS_USERDIR = ${LYX_TESTS_USERDIR}")
|
|
|
|
message(STATUS "Converting with perl ${Perl_Script}")
|
2015-03-28 20:21:16 +00:00
|
|
|
set(LYX_SOURCE "${TempDir}/${file}_${format}_${_ft}.lyx")
|
2013-11-17 22:17:27 +00:00
|
|
|
message(STATUS "Using source \"${LYX_ROOT}/${file}.lyx\"")
|
|
|
|
message(STATUS "Using dest \"${LYX_SOURCE}\"")
|
2015-11-10 18:42:43 +00:00
|
|
|
execute_process(COMMAND ${PERL_EXECUTABLE} "${Perl_Script}" "${LYX_ROOT}/${file}.lyx" "${LYX_SOURCE}" ${format} ${_ft} ${LanguageFile}
|
2013-11-17 22:17:27 +00:00
|
|
|
RESULT_VARIABLE _err)
|
|
|
|
string(COMPARE EQUAL ${_err} 0 _erg)
|
|
|
|
if(NOT _erg)
|
|
|
|
message(FATAL_ERROR "Export failed while converting")
|
|
|
|
endif()
|
2015-12-25 18:02:06 +00:00
|
|
|
set(result_file_name ${file}_${_ft}.${extension})
|
2013-11-17 22:17:27 +00:00
|
|
|
else()
|
|
|
|
message(STATUS "Not converting")
|
|
|
|
set(LYX_SOURCE "${LYX_ROOT}/${file}.lyx")
|
2015-12-25 18:02:06 +00:00
|
|
|
# Font-type not relevant for lyx16/lyx21 exports
|
|
|
|
set(result_file_name ${file}.${extension})
|
2015-12-27 19:05:37 +00:00
|
|
|
set(result_file_name2 ${file}.${extension2})
|
2013-11-17 22:17:27 +00:00
|
|
|
endif()
|
|
|
|
|
2014-09-09 17:02:20 +00:00
|
|
|
message(STATUS "Executing ${lyx} -userdir \"${LYX_TESTS_USERDIR}\" -E ${format} ${result_file_name} \"${LYX_SOURCE}\"")
|
2013-08-25 09:41:10 +00:00
|
|
|
set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
|
2015-12-25 18:02:06 +00:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${result_file_name} ${result_file_name}.emergency)
|
2012-12-13 11:38:38 +00:00
|
|
|
execute_process(
|
2014-09-09 17:02:20 +00:00
|
|
|
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${result_file_name} "${LYX_SOURCE}"
|
2012-12-13 11:38:38 +00:00
|
|
|
RESULT_VARIABLE _err)
|
2014-09-09 17:02:20 +00:00
|
|
|
|
|
|
|
#check if result file created
|
|
|
|
if (NOT _err)
|
|
|
|
if (NOT EXISTS "${result_file_name}")
|
|
|
|
message(STATUS "Expected result file \"${result_file_name}\" does not exist")
|
|
|
|
set(_err -1)
|
|
|
|
else()
|
|
|
|
message(STATUS "Expected result file \"${result_file_name}\" exists")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-12-25 09:28:40 +00:00
|
|
|
include(${TOP_SRC_DIR}/development/autotests/CheckLoadErrors.cmake)
|
|
|
|
# If no error, and extension matches '\.lyx$', try to load the created lyx file
|
|
|
|
if (NOT _err)
|
|
|
|
if (result_file_name MATCHES "\\.lyx$")
|
|
|
|
set(ENV{${LYX_USERDIR_VER}} "${LYX_TESTS_USERDIR}")
|
|
|
|
set(ENV{LANG} "en") # to get all error-messages in english
|
2015-12-27 19:05:37 +00:00
|
|
|
message(STATUS "check structures of ${result_file_name}")
|
2015-12-25 09:28:40 +00:00
|
|
|
execute_process(
|
2015-12-27 13:33:11 +00:00
|
|
|
COMMAND ${PERL_EXECUTABLE} ${Structure_Script} "${WORKDIR}/${result_file_name}"
|
2015-12-25 09:28:40 +00:00
|
|
|
RESULT_VARIABLE _err
|
|
|
|
ERROR_VARIABLE lyxerr)
|
2015-12-27 13:33:11 +00:00
|
|
|
if (NOT _err)
|
2015-12-27 19:05:37 +00:00
|
|
|
message(STATUS "check load of ${result_file_name}")
|
2015-12-27 13:33:11 +00:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${lyx} -batch -userdir "${LYX_TESTS_USERDIR}" ${result_file_name}
|
|
|
|
RESULT_VARIABLE _err
|
|
|
|
ERROR_VARIABLE lyxerr)
|
2015-12-27 19:05:37 +00:00
|
|
|
if (NOT _err)
|
|
|
|
CheckLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err)
|
|
|
|
if (NOT _err)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${lyx} -userdir "${LYX_TESTS_USERDIR}" -E ${format} ${result_file_name2} ${result_file_name}
|
|
|
|
RESULT_VARIABLE _err
|
|
|
|
ERROR_VARIABLE lyxerr)
|
|
|
|
if (NOT _err)
|
|
|
|
message(STATUS "check load of ${result_file_name2}")
|
|
|
|
CheckLoadErrors(lyxerr "${TOP_SRC_DIR}/development/autotests" _err)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-12-25 09:28:40 +00:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(STATUS "\"${result_file_name}\" is not a lyx file, do not check load")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-12-02 23:23:07 +00:00
|
|
|
if(inverted)
|
2013-08-04 12:31:47 +00:00
|
|
|
string(COMPARE EQUAL ${_err} 0 _erg)
|
|
|
|
else()
|
|
|
|
string(COMPARE NOTEQUAL ${_err} 0 _erg)
|
|
|
|
endif()
|
2015-03-28 20:21:16 +00:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${TempDir}")
|
2013-01-21 01:36:42 +00:00
|
|
|
if(_erg)
|
2015-12-25 09:28:40 +00:00
|
|
|
message(STATUS "Exporting ${file}.lyx to ${format}")
|
2012-12-13 11:38:38 +00:00
|
|
|
message(FATAL_ERROR "Export failed")
|
|
|
|
endif()
|