Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / desktop / scripts / soffice.sh
blob8866a2cc8cf1debccee3c5248377c4589eaae83e
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # use POSIX locale for well-defined tool output
21 LO_SAVE_LC_ALL="$LC_ALL"
22 LC_ALL=C
23 export LC_ALL
26 # STAR_PROFILE_LOCKING_DISABLED=1
27 # export STAR_PROFILE_LOCKING_DISABLED
30 # file locking now enabled by default
31 SAL_ENABLE_FILE_LOCKING=1
32 export SAL_ENABLE_FILE_LOCKING
34 # uncomment line below to disable anti aliasing of fonts
35 # SAL_ANTIALIAS_DISABLE=true; export SAL_ANTIALIAS_DISABLE
37 # uncomment line below if you encounter problems starting soffice on your system
38 # SAL_NO_XINITTHREADS=true; export SAL_NO_XINITTHREADS
40 #@JITC_PROCESSOR_TYPE_EXPORT@
42 # resolve installation directory
43 sd_cwd=$(pwd)
44 sd_res="$0"
45 while [ -h "$sd_res" ] ; do
46 sd_dirname=$(dirname "$sd_res")
47 cd "$sd_dirname" || exit $?
48 sd_basename=$(basename "$sd_res")
49 sd_res=$(ls -l "$sd_basename" | sed "s/.*$sd_basename -> //g")
50 done
51 sd_dirname=$(dirname "$sd_res")
52 cd "$sd_dirname" || exit $?
53 sd_prog=$(pwd)
54 cd "$sd_cwd" || exit $?
56 # linked build needs additional settings
57 if [ -e "${sd_prog}/ooenv" ] ; then
58 # shellcheck source=../../instsetoo_native/ooenv
59 . "${sd_prog}/ooenv"
62 # try to get some debug output?
63 GDBTRACECHECK=
64 STRACECHECK=
65 VALGRINDCHECK=
66 RRCHECK=
68 # count number of selected checks; only one is allowed
69 checks=
70 EXTRAOPT=
71 # force the --valgrind option if the VALGRIND variable is set
72 test -n "$VALGRIND" && EXTRAOPT="--valgrind"
74 # force the --record option if the RR variable is set
75 test -n "$RR" && EXTRAOPT="--record"
77 for arg in "$@" $EXTRAOPT ; do
78 case "$arg" in
79 --record)
80 if which rr >/dev/null 2>&1 ; then
81 # smoketest may already be recorded => ignore nested
82 RRCHECK="rr record --nested=ignore"
83 checks="c$checks"
84 else
85 echo "Error: Can't find the tool \"rr\", --record option will be ignored."
86 exit 1
89 --backtrace)
90 if which gdb >/dev/null 2>&1 ; then
91 GDBTRACECHECK="gdb -nx --command=$sd_prog/gdbtrace --args"
92 checks="c$checks"
93 else
94 echo "Error: Can't find the tool \"gdb\", --backtrace option will be ignored."
95 exit 1
98 --strace)
99 if which strace >/dev/null 2>&1 ; then
100 STRACECHECK="strace -o strace.log -f -tt -s 256"
101 checks="c$checks"
102 else
103 echo "Error: Can't find the tool \"strace\", --strace option will be ignored."
104 exit 1;
107 --valgrind)
108 test -n "$VALGRINDCHECK" && continue;
109 if which valgrind >/dev/null 2>&1 ; then
110 # another valgrind tool might be forced via the environment variable
111 test -z "$VALGRIND" && VALGRIND="memcheck"
112 # --trace-children-skip is pretty useful but supported only with valgrind >= 3.6.0
113 valgrind_ver=$(valgrind --version | sed -e "s/valgrind-//")
114 valgrind_ver_maj=$(echo "$valgrind_ver" | awk -F. '{ print $1 }')
115 valgrind_ver_min=$(echo "$valgrind_ver" | awk -F. '{ print $2 }')
116 valgrind_skip=
117 if [ "$valgrind_ver_maj" -gt 3 ] || ( [ "$valgrind_ver_maj" -eq 3 ] && [ "$valgrind_ver_min" -ge 6 ] ) ; then
118 valgrind_skip='--trace-children-skip=*/java,*/gij'
120 # finally set the valgrind check
121 VALGRINDCHECK="valgrind --tool=$VALGRIND --trace-children=yes $valgrind_skip --num-callers=50 --error-limit=no"
122 echo "use kill -SIGUSR2 pid to dump traces of active allocations"
123 checks="c$checks"
124 case "$VALGRIND" in
125 helgrind|memcheck|massif|exp-dhat)
126 export G_SLICE=always-malloc
127 export GLIBCXX_FORCE_NEW=1
129 callgrind)
130 unset MALLOC_CHECK_ MALLOC_PERTURB_ G_SLICE
131 export SAL_DISABLE_FLOATGRAB=1
132 export OOO_DISABLE_RECOVERY=1
133 export SAL_DISABLE_WATCHDOG=1
134 export LD_BIND_NOW=1
136 esac
137 else
138 echo "Error: Can't find the tool \"valgrind\", --valgrind option will be ignored"
139 exit 1
142 esac
143 done
145 if echo "$checks" | grep -q "cc" ; then
146 echo "Error: The debug options --record, --backtrace, --strace, and --valgrind cannot be used together."
147 echo " Please, use them one by one."
148 exit 1;
151 case "$(uname -s)" in
152 OpenBSD)
153 # this is a temporary hack until we can live with the default search paths
154 LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
155 JAVA_HOME=$(javaPathHelper -h libreoffice-java 2> /dev/null)
156 export LD_LIBRARY_PATH
157 if [ -n "${JAVA_HOME}" ]; then
158 export JAVA_HOME
161 NetBSD|DragonFly)
162 # this is a temporary hack until we can live with the default search paths
163 LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
164 export LD_LIBRARY_PATH
166 esac
168 # restore locale setting, avoiding to export empty LC_ALL, s. tdf#130080
169 if [ -n "$LO_SAVE_LC_ALL" ]; then
170 LC_ALL="$LO_SAVE_LC_ALL"
171 else
172 unset LC_ALL
175 # run soffice.bin directly when you want to get the backtrace
176 if [ -n "$GDBTRACECHECK" ] ; then
177 exec $GDBTRACECHECK "$sd_prog/soffice.bin" "$@"
180 # valgrind --log-file=valgrind.log does not work well with --trace-children=yes
181 if [ -n "$VALGRINDCHECK" ] && [ -z "$VALGRIND" ] ; then
182 echo "redirecting the standard and the error output to valgrind.log"
183 exec > valgrind.log 2>&1
186 # oosplash does the rest: forcing pages in, javaldx etc. are
187 exec $RRCHECK $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@"