[LyX master] Cmake build: autotests Adapt to use local .gmo files

2012-12-12 Thread Kornel Benko
The branch, master, has been updated.

- Log -

commit b436a03b3468dd15b27ee1c35e09d79b49192996
Author: Kornel Benko kor...@lyx.org
Date:   Wed Dec 12 14:54:38 2012 +0100

Cmake build: autotests
Adapt to use local .gmo files

diff --git a/development/autotests/CMakeLists.txt 
b/development/autotests/CMakeLists.txt
index cf7bd9d..3a85964 100644
--- a/development/autotests/CMakeLists.txt
+++ b/development/autotests/CMakeLists.txt
@@ -27,10 +27,13 @@ if(UNIX)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
COMMAND ${CMAKE_COMMAND}
 -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
+-DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
 -DKEYTEST_INFILE=${_tf}
 -DBINDIR=${TOP_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
 -DKEYTEST_OUTFILE=${_t}-out.txt
+-DPACKAGE=${PACKAGE}
+-DLOCALE_DIR=${LOCALE_DIR}
 -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
 endforeach()
 add_test(NAME lyx_export
diff --git a/development/autotests/keytest.py b/development/autotests/keytest.py
index d5a..82f316c 100755
--- a/development/autotests/keytest.py
+++ b/development/autotests/keytest.py
@@ -250,6 +250,14 @@ max_loops = os.environ.get('MAX_LOOPS')
 if max_loops is None:
 max_loops = 3
 
+PACKAGE = os.environ.get('PACKAGE')
+if not PACKAGE is None:
+  print PACKAGE =  + PACKAGE + \n
+
+PO_BUILD_DIR = os.environ.get('PO_BUILD_DIR')
+if not PO_BUILD_DIR is None:
+  print PO_BUILD_DIR =  + PO_BUILD_DIR + \n
+
 lyx_exe = os.environ.get('LYX_EXE')
 if lyx_exe is None:
 lyx_exe = lyx
@@ -415,17 +423,27 @@ while not failed:
 else:
 short_code = ccode
 lyx_dir = os.popen(dirname \ + lyx_exe + \).read().rstrip()
-# on cmake-build there is no Makefile in this directory
-if os.path.exists(lyx_dir + /Makefile):
-  print Executing: grep 'PACKAGE ='  + lyx_dir + /Makefile | sed -e 
's/PACKAGE = \(.*\)/\\1/'
-  lyx_name = os.popen(grep 'PACKAGE ='  + lyx_dir + /Makefile | sed 
-e 's/PACKAGE = \(.*\)/\\1/').read().rstrip()
-  intr_system(mkdir -p  + locale_dir + / + ccode + /LC_MESSAGES)
-  if lyx_dir[0:3] == ../:
-  rel_dir = ../../ + lyx_dir
+if PACKAGE is None:
+  # on cmake-build there is no Makefile in this directory
+  # so PACKAGE has to be provided
+  if os.path.exists(lyx_dir + /Makefile):
+print Executing: grep 'PACKAGE ='  + lyx_dir + /Makefile | sed 
-e 's/PACKAGE = \(.*\)/\\1/'
+lyx_name = os.popen(grep 'PACKAGE ='  + lyx_dir + /Makefile | 
sed -e 's/PACKAGE = \(.*\)/\\1/').read().rstrip()
   else:
-  rel_dir = lyx_dir
-  intr_system(rm -f  + locale_dir + / + ccode + /LC_MESSAGES/ + 
lyx_name + .mo)
-  intr_system(ln -s  + rel_dir + /../po/ + short_code + .gmo  + 
locale_dir + / + ccode + /LC_MESSAGES/ + lyx_name + .mo)
+print 'Could not determine PACKAGE name needed for translations\n'
+failed = True
+else:
+  lyx_name = PACKAGE
+intr_system(mkdir -p  + locale_dir + / + ccode + /LC_MESSAGES)
+intr_system(rm -f  + locale_dir + / + ccode + /LC_MESSAGES/ + 
lyx_name + .mo)
+if PO_BUILD_DIR is None:
+if lyx_dir[0:3] == ../:
+rel_dir = ../../ + lyx_dir
+else:
+rel_dir = lyx_dir
+intr_system(ln -s  + rel_dir + /../po/ + short_code + .gmo  
+ locale_dir + / + ccode + /LC_MESSAGES/ + lyx_name + .mo)
+else:
+intr_system(ln -s  + PO_BUILD_DIR + / + short_code + .gmo  + 
locale_dir + / + ccode + /LC_MESSAGES/ + lyx_name + .mo)
 else:
 print Unrecognised Command ' + c + '\n
 failed = True
diff --git a/development/autotests/single-test.cmake 
b/development/autotests/single-test.cmake
index 5da1c99..f9e9a28 100755
--- a/development/autotests/single-test.cmake
+++ b/development/autotests/single-test.cmake
@@ -6,18 +6,23 @@
 # KEYTEST_OUTFILE = xxx-out.txt
 # BINDIR  = ${BUILD_DIR}/bin
 # WORKDIR = ${BUILD_DIR}/autotests/out-home
+# LOCALE_DIR  = ${BUILD_DIR}/autotests/locale
+# PO_BUILD_DIR= ${BUILD_DIR}/po
+# PACKAGE = lyx2.1
 #
 # Script should be called like:
 # cmake -DAUTOTEST_ROOT= \
 #   -DKEYTEST_INFILE= \
 #   -DKEYTEST_OUTFILE=xxx \
 #   -DBINDIR=xxx \
-#   -WWORKDIR=xxx \
+#   -DWORKDIR=xxx \
+#   -DLOCALE_DIR=xxx \
+#   -DPO_BUILD_DIR=xxx \
+#   -DPACKAGE=xxx \
 #   -P ${AUTOTEST_ROOT}/single-test.cmake
 
 set(KEYTEST ${AUTOTEST_ROOT}/keytest.py)
 
-set(MAX_DROP 0)
 execute_process(COMMAND pidof lyx OUTPUT_VARIABLE LYX_PID RESULT_VARIABLE 
pidstat OUTPUT_VARIABLE pidres)
 message(STATUS pidres = ${pidres})
 if (NOT pidstat)
@@ -43,6 +48,9 @@ set(LYX_EXE ${BINDIR}/lyx)
 set(XVKBD_EXE 

[LyX master] Cmake build: autotests Adapt to use local .gmo files

2012-12-12 Thread Kornel Benko
The branch, master, has been updated.

- Log -

commit b436a03b3468dd15b27ee1c35e09d79b49192996
Author: Kornel Benko 
Date:   Wed Dec 12 14:54:38 2012 +0100

Cmake build: autotests
Adapt to use local .gmo files

diff --git a/development/autotests/CMakeLists.txt 
b/development/autotests/CMakeLists.txt
index cf7bd9d..3a85964 100644
--- a/development/autotests/CMakeLists.txt
+++ b/development/autotests/CMakeLists.txt
@@ -27,10 +27,13 @@ if(UNIX)
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}"
COMMAND ${CMAKE_COMMAND}
 -DAUTOTEST_ROOT=${TOP_SRC_DIR}/development/autotests
+-DPO_BUILD_DIR=${TOP_BINARY_DIR}/po
 -DKEYTEST_INFILE=${_tf}
 -DBINDIR=${TOP_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}
-DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}
 -DKEYTEST_OUTFILE=${_t}-out.txt
+-DPACKAGE=${PACKAGE}
+-DLOCALE_DIR=${LOCALE_DIR}
 -P ${TOP_SRC_DIR}/development/autotests/single-test.cmake)
 endforeach()
 add_test(NAME lyx_export
diff --git a/development/autotests/keytest.py b/development/autotests/keytest.py
index d5a..82f316c 100755
--- a/development/autotests/keytest.py
+++ b/development/autotests/keytest.py
@@ -250,6 +250,14 @@ max_loops = os.environ.get('MAX_LOOPS')
 if max_loops is None:
 max_loops = 3
 
+PACKAGE = os.environ.get('PACKAGE')
+if not PACKAGE is None:
+  print "PACKAGE = " + PACKAGE + "\n"
+
+PO_BUILD_DIR = os.environ.get('PO_BUILD_DIR')
+if not PO_BUILD_DIR is None:
+  print "PO_BUILD_DIR = " + PO_BUILD_DIR + "\n"
+
 lyx_exe = os.environ.get('LYX_EXE')
 if lyx_exe is None:
 lyx_exe = "lyx"
@@ -415,17 +423,27 @@ while not failed:
 else:
 short_code = ccode
 lyx_dir = os.popen("dirname \"" + lyx_exe + "\"").read().rstrip()
-# on cmake-build there is no Makefile in this directory
-if os.path.exists(lyx_dir + "/Makefile"):
-  print "Executing: grep 'PACKAGE =' " + lyx_dir + "/Makefile | sed -e 
's/PACKAGE = \(.*\)/\\1/'"
-  lyx_name = os.popen("grep 'PACKAGE =' " + lyx_dir + "/Makefile | sed 
-e 's/PACKAGE = \(.*\)/\\1/'").read().rstrip()
-  intr_system("mkdir -p " + locale_dir + "/" + ccode + "/LC_MESSAGES")
-  if lyx_dir[0:3] == "../":
-  rel_dir = "../../" + lyx_dir
+if PACKAGE is None:
+  # on cmake-build there is no Makefile in this directory
+  # so PACKAGE has to be provided
+  if os.path.exists(lyx_dir + "/Makefile"):
+print "Executing: grep 'PACKAGE =' " + lyx_dir + "/Makefile | sed 
-e 's/PACKAGE = \(.*\)/\\1/'"
+lyx_name = os.popen("grep 'PACKAGE =' " + lyx_dir + "/Makefile | 
sed -e 's/PACKAGE = \(.*\)/\\1/'").read().rstrip()
   else:
-  rel_dir = lyx_dir
-  intr_system("rm -f " + locale_dir + "/" + ccode + "/LC_MESSAGES/" + 
lyx_name + ".mo")
-  intr_system("ln -s " + rel_dir + "/../po/" + short_code + ".gmo " + 
locale_dir + "/" + ccode + "/LC_MESSAGES/" + lyx_name + ".mo")
+print 'Could not determine PACKAGE name needed for translations\n'
+failed = True
+else:
+  lyx_name = PACKAGE
+intr_system("mkdir -p " + locale_dir + "/" + ccode + "/LC_MESSAGES")
+intr_system("rm -f " + locale_dir + "/" + ccode + "/LC_MESSAGES/" + 
lyx_name + ".mo")
+if PO_BUILD_DIR is None:
+if lyx_dir[0:3] == "../":
+rel_dir = "../../" + lyx_dir
+else:
+rel_dir = lyx_dir
+intr_system("ln -s " + rel_dir + "/../po/" + short_code + ".gmo " 
+ locale_dir + "/" + ccode + "/LC_MESSAGES/" + lyx_name + ".mo")
+else:
+intr_system("ln -s " + PO_BUILD_DIR + "/" + short_code + ".gmo " + 
locale_dir + "/" + ccode + "/LC_MESSAGES/" + lyx_name + ".mo")
 else:
 print "Unrecognised Command '" + c + "'\n"
 failed = True
diff --git a/development/autotests/single-test.cmake 
b/development/autotests/single-test.cmake
index 5da1c99..f9e9a28 100755
--- a/development/autotests/single-test.cmake
+++ b/development/autotests/single-test.cmake
@@ -6,18 +6,23 @@
 # KEYTEST_OUTFILE = xxx-out.txt
 # BINDIR  = ${BUILD_DIR}/bin
 # WORKDIR = ${BUILD_DIR}/autotests/out-home
+# LOCALE_DIR  = ${BUILD_DIR}/autotests/locale
+# PO_BUILD_DIR= ${BUILD_DIR}/po
+# PACKAGE = lyx2.1
 #
 # Script should be called like:
 # cmake -DAUTOTEST_ROOT= \
 #   -DKEYTEST_INFILE= \
 #   -DKEYTEST_OUTFILE=xxx \
 #   -DBINDIR=xxx \
-#   -WWORKDIR=xxx \
+#   -DWORKDIR=xxx \
+#   -DLOCALE_DIR=xxx \
+#   -DPO_BUILD_DIR=xxx \
+#   -DPACKAGE=xxx \
 #   -P ${AUTOTEST_ROOT}/single-test.cmake
 
 set(KEYTEST "${AUTOTEST_ROOT}/keytest.py")
 
-set(MAX_DROP 0)
 execute_process(COMMAND pidof lyx OUTPUT_VARIABLE LYX_PID RESULT_VARIABLE 
pidstat OUTPUT_VARIABLE pidres)