Debian Codegraph @

distro/dev-tools/scripts/test-hime

raw
1 #!/bin/bash
2 # Copyright and license see bottom of this file
3
4 GTK_QUERY_IMMODULES_2==`whereis gtk-query-immodules-2.0 | cut -d ' ' -f 2`
5 if [ ! -x "$GTK_QUERY_IMMODULES_2" ]; then
6 GTK_QUERY_IMMODULES_2=/usr/lib/`ls /usr/lib | grep linux | grep $(uname -m)`/libgtk2.0-0/gtk-query-immodules-2.0
7 fi
8
9
10 GTK_QUERY_IMMODULES_3=/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0
11
12 if [ ! -x "$GTK_QUERY_IMMODULES_3" ]; then
13 GTK_QUERY_IMMODULES_3=/usr/lib/`ls /usr/lib | grep linux | grep $(uname -m)`/libgtk-2-0/gtk-query-immodules-3.0
14 fi
15
16 echo \#!/bin/sh > hime-test-shell-env
17 export HIME_OUTPUT_FILTER=$PWD/filter/nobopomofo
18 echo "export HIME_OUTPUT_FILTER=$PWD/filter/nobopomofo" >> hime-test-shell-env
19 UTF8_LOCALE=`locale -a | grep utf8 | tail -n 1`
20
21 XIM_NAME=`date +%N | tr -d 0`
22 GTK_2_TEMP_FILE=$PWD/gtk2
23 GTK_3_TEMP_FILE=$PWD/gtk3
24
25 [ ! -e distro/debian ] && exec echo Please execute '"distro/dev-tools/scripts/test-hime"' under hime directory, thanks.
26
27
28 export PATH=$PWD/src:$PATH
29 echo "export PATH=$PWD/src:$PATH" >> hime-test-shell-env
30
31 export HIME_TABLE_DIR=$PWD/data
32 echo "export HIME_TABLE_DIR=$PWD/data" >> hime-test-shell-env
33
34 export HIME_MODULE_DIR=$PWD/src/modules
35 echo "export HIME_MODULE_DIR=$PWD/src/modules" >> hime-test-shell-env
36
37 export XMODIFIERS=@im=$XIM_NAME
38 echo "export XMODIFIERS=@im=$XIM_NAME" >> hime-test-shell-env
39
40 unset LC_ALL
41 echo "unset LC_ALL" >> hime-test-shell-env
42
43 export LC_CTYPE=$UTF8_LOCALE
44 echo "export LC_CTYPE=$UTF8_LOCALE" >> hime-test-shell-env
45
46 $GTK_QUERY_IMMODULES_2 | grep -v hime > $GTK_2_TEMP_FILE
47 $GTK_QUERY_IMMODULES_3 | grep -v hime > $GTK_3_TEMP_FILE
48 LD_LIBRARY_PATH=$PWD/src/im-client/ $GTK_QUERY_IMMODULES_2 $PWD/src/gtk-im/im-hime.so >> $GTK_2_TEMP_FILE
49 LD_LIBRARY_PATH=$PWD/src/im-client/ $GTK_QUERY_IMMODULES_3 $PWD/src/gtk3-im/im-hime.so >> $GTK_3_TEMP_FILE
50
51 export LD_PRELOAD=$PWD/src/im-client/libhime-im-client.so
52 echo "export LD_PRELOAD=$PWD/src/im-client/libhime-im-client.so" >> hime-test-shell-env
53
54 export GTK_IM_MODULE=hime
55 echo "export GTK_IM_MODULE=hime" >> hime-test-shell-env
56
57 echo "PS1=\"\[\e]0;\u@\h: \w\a\]\u@\h:\w (hime-test-env)$ \"" >> hime-test-shell-env
58
59 if [ ! -x "$HIME_OUTPUT_FILTER" ]; then
60 echo Warning! Your filter is not executable. Filter has been turned off automatically.
61 unset HIME_OUTPUT_FILTER
62 fi
63 echo To activate the testing envronment, execute \". hime-test-shell-env\" under this directory
64
65 sh $PWD/scripts/hime-user-setup $PWD/data $PWD/src
66
67 echo
68 echo ">>>"
69 echo
70 echo "Depending on whether the application is using gtk2 or gtk3, set up the corresponding environmental variable before running target application in the testing environment"
71 echo
72 echo "gtk2: export GTK_IM_MODULE_FILE=$GTK_2_TEMP_FILE"
73 echo "gtk3: export GTK_IM_MODULE_FILE=$GTK_3_TEMP_FILE"
74 echo
75 echo ">>>"
76 echo
77
78 ##start hime
79 HIME_MODULE_DIR=$PWD/src/modules HIME_TABLE_DIR=data LD_LIBRARY_PATH=$PWD/src/im-client/:$PWD/src XMODIFIERS=@im=$XIM_NAME gdb src/hime
80
81
82 # TODO: get tempdir from TMPDIR, TMP, and TEMP
83 rm $GTK_2_TEMP_FILE $GTK_3_TEMP_FILE /tmp/.hime-$USER/socket-*-$XIM_NAME
84 rm hime-test-shell-env
85
86 # Copyright (C) 2007-2012 Wen-Yen Chuang <caleb AT calno DOT com>
87 #
88 # This library is free software; you can redistribute it and/or
89 # modify it under the terms of the GNU Lesser General Public
90 # License as published by the Free Software Foundation; either
91 # version 2.1 of the License, or (at your option) any later version.
92 #
93 # This library is distributed in the hope that it will be useful,
94 # but WITHOUT ANY WARRANTY; without even the implied warranty of
95 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
96 # Lesser General Public License for more details.
97 #
98 # You should have received a copy of the GNU Lesser General Public
99 # License along with this library; if not, write to the Free Software
100 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA