bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / install-gdb-printers
blobe55e305226e8a3b56fdab55708c61975f3740486
1 #!/usr/bin/env bash
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/.
10 GDBDIR="${SOLARENV}/gdb"
11 SOLVERLIBDIR="${SOLARVER}/${INPATH}/lib"
12 INSTALLDIR="${DEVINSTALLDIR}/opt"
13 DYLIB=so
14 if [ "$(uname)" = Darwin ]; then
15 INSTALLDIR=$INSTALLDIR/LibreOffice.app/Contents
16 DYLIB=dylib
19 die() {
20 echo "$1" >&2
21 exit 1
24 usage() {
25 cat <<EOT
26 Install gdb pretty printers and autoloaders for them.
28 Usage:
29 install-gdb-printers [ -a dir ] [ -i dir ] [ -p dir ] [ -c ] [ -L ]
30 install-gdb-printers -h
32 Options:
33 -a dir The dir where autoloaders will be placed. Defaults to whatever -i
34 is.
35 -c Create the autoloader's dir if it does not exist. This option only
36 makes sense if both -a and -i are used.
37 -f Do not create subdirs in the autoloader's dir. This option is only
38 used during build.
39 -h Show this help text.
40 -i dir The dir where libreoffice is installed. Defaults to whatever -a is.
41 -L Create symlinks to autoloaders already present in the build tree.
42 Only makes sense for dev. installation.
43 -p dir The dir where pretty printers are placed.
45 Env. variables:
46 DESTDIR If set, it is prepended to all dir arguments.
48 Examples:
49 1) Make pretty printers usable in your dev. installation (this is
50 already done as part of make dev-install, but it would not have been
51 run if smoketest failed):
53 install-gdb-printers -L
55 2) Install pretty printers into /usr/share/libreoffice/gdb, with
56 autoloaders in /usr/share/gdb/auto-load (run
57 "info gdb 'Extending GDB' Python Auto-loading" to learn more) and
58 installation in /usr/lib64/libreoffice (this is what Fedora does):
60 install-gdb-printers -a /usr/share/gdb/auto-load/usr/lib64/libreoffice -c \\
61 -i /usr/lib64/libreoffice -p /usr/share/libreoffice/gdb
62 EOT
65 make_autoload() {
66 local dir="${DESTDIR}${autoloaddir}"
67 ${flat} || dir="${dir}/$2"
68 local lib="${dir}/$3"
69 local merged="$4"
71 if ! ${flat}; then
72 local resolved="$(readlink "${DESTDIR}${installdir}/$2/$3")"
73 [ -n "$resolved" ] && lib=$resolved
74 dir="${lib%/*}"
77 if ${create}; then
78 mkdir -p "${dir}" || die "cannot create dir '${dir}'"
81 if ${link}; then
82 if [[ ${dir} != ${SOLVERLIBDIR} ]]; then
83 local gdbname="${lib##*/}-gdb.py"
84 [[ -f ${dir}/${gdbname} ]] && rm -f "${dir}/${gdbname}"
85 ln -s "${SOLVERLIBDIR}/${gdbname}" "${dir}/${gdbname}"
87 else
88 [[ -f ${lib}-gdb.py ]] && rm -f "${lib}-gdb.py"
89 if [[ -n "${merged}" ]]; then
90 sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULES%!${*:5}!" \
91 "${GDBDIR}/autoload.template" > "${lib}-gdb.py"
92 else
93 sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULES%!$1!" \
94 "${GDBDIR}/autoload.template" > "${lib}-gdb.py"
99 # dir where the autoloaders will be placed
100 autoloaddir=
101 # The installation dir. If only one of these is set, the other is set to
102 # the same value.
103 installdir=
104 # dir where the pretty printers will be placed
105 pythondir="${GDBDIR}"
106 # Create autoload dir if it does not exist. This only makes sense when
107 # installing into system gdb dir, so $autoloaddir must be absolute path.
108 create=false
109 # Create symlinks to existing autoloaders in solver. This only makes
110 # sense for dev-install.
111 link=false
112 # This option is only here to enable using the script during build of
113 # solenv/gdb . We must (or, better, want to :) avoid using the
114 # installation subpaths (like ure-link), because all libs in solver
115 # are in the same dir.
116 flat=false
118 # b de g jklmno qrstuvwxyzABCDEFGHIJK MNOPQRSTUVWXYZ0123456789
119 while getopts :a:cfhi:p:L opt; do
120 case ${opt} in
121 a) autoloaddir="${OPTARG}" ;;
122 c) create=true ;;
123 f) flat=true ;;
124 h) usage; exit ;;
125 i) installdir="${OPTARG}" ;;
126 p) pythondir="${OPTARG}" ;;
127 L) link=true ;;
128 *) die "unknown option ${OPTARG}" ;;
129 esac
130 done
132 if [[ -z ${autoloaddir} && -z ${installdir} ]]; then
133 autoloaddir="${INSTALLDIR}"
134 installdir="${INSTALLDIR}"
135 elif [[ -n ${autoloaddir} && -z ${installdir} ]]; then
136 installdir="${autoloaddir}"
137 elif [[ -z ${autoloaddir} && -n ${installdir} ]]; then
138 autoloaddir="${installdir}"
141 ${create} && ${link} && die "-c and -L cannot be used together"
142 if [[ -n ${DESTDIR} ]]; then
143 [[ ${autoloaddir:0:1} = / ]] || die 'the arg to -a must be an absolute path'
144 [[ ${pythondir:0:1} = / ]] || die 'the arg to -p must be an absolute path'
146 if ${create}; then
147 [[ ${autoloaddir:0:1} = / ]] || die 'the arg to -a must be an absolute path'
148 else
149 [[ ! -d ${DESTDIR}${autoloaddir} ]] && die "directory '${DESTDIR}${autoloaddir}' does not exist"
151 [[ ! -d ${DESTDIR}${installdir} ]] && die "directory '${DESTDIR}${installdir}' does not exist"
152 [[ ! -d ${GDBDIR} ]] && die "directory '${GDBDIR}' does not exist"
154 if [[ ${DESTDIR}${pythondir} != ${GDBDIR} ]]; then
155 mkdir -p "${DESTDIR}${pythondir}" || die "cannot create dir '${DESTDIR}${pythondir}'"
156 cp -pr "${GDBDIR}/libreoffice" "${DESTDIR}${pythondir}"
159 if [[ -n "${MERGELIBS}" ]]; then
160 make_autoload merged program libmergedlo."$DYLIB" merge svl tl `[[ ${MERGELIBS} == "ALL" ]] && echo sw`
161 if [[ ${MERGELIBS} == "ALL" ]]; then
162 make_autoload urelibs ure-link/lib liburelibs."$DYLIB" merge cppu sal
163 else
164 make_autoload cppu ure-link/lib libuno_cppu."$DYLIB".3
165 make_autoload sal ure-link/lib libuno_sal."$DYLIB".3
166 make_autoload sw program libswlo."$DYLIB"
168 else
169 make_autoload cppu ure-link/lib libuno_cppu."$DYLIB".3
170 make_autoload sal ure-link/lib libuno_sal."$DYLIB".3
171 make_autoload svl program libsvllo."$DYLIB"
172 make_autoload tl program libtllo."$DYLIB"
173 make_autoload sw program libswlo."$DYLIB"
176 # vim:set shiftwidth=4 softtabstop=4 expandtab: