office-gobmx/solenv/bin/install-gdb-printers
Michael Stahl bc5069ac40 remove SOLARENV variable
It is constant and can just be replaced by $(SRCDIR)/solenv.

Use BUILD_TYPE where it was used to check if config_*.mk is sourced.

Change-Id: Ib9d480c57194b6340093aa47776f8768df69b7d1
2013-11-02 22:07:53 +01:00

157 lines
5.2 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
GDBDIR="${SRCDIR}/solenv/gdb"
INSTALLDIR="${TESTINSTALLDIR}"
DYLIB=so
if [ "$(uname)" = Darwin ]; then
INSTALLDIR=$INSTALLDIR/LibreOffice.app/Contents
DYLIB=dylib
fi
die() {
echo "$1" >&2
exit 1
}
usage() {
cat <<EOT
Install gdb pretty printers and autoloaders for them.
Usage:
install-gdb-printers [ -a dir ] [ -i dir ] [ -p dir ] [ -c ]
install-gdb-printers -h
Options:
-a dir The dir where autoloaders will be placed. Defaults to whatever -i
is.
-c Create the autoloader's dir if it does not exist. This option only
makes sense if both -a and -i are used.
-f Do not create subdirs in the autoloader's dir. This option is only
used during build.
-h Show this help text.
-i dir The dir where libreoffice is installed. Defaults to whatever -a is.
-p dir The dir where pretty printers are placed.
Env. variables:
DESTDIR If set, it is prepended to all dir arguments.
Examples:
1) Install pretty printers into /usr/share/libreoffice/gdb, with
autoloaders in /usr/share/gdb/auto-load (run
"info gdb 'Extending GDB' Python Auto-loading" to learn more) and
installation in /usr/lib64/libreoffice (this is what Fedora does):
install-gdb-printers -a /usr/share/gdb/auto-load/usr/lib64/libreoffice -c \\
-i /usr/lib64/libreoffice -p /usr/share/libreoffice/gdb
EOT
}
make_autoload() {
local dir="${DESTDIR}${autoloaddir}"
${flat} || dir="${dir}/$2"
local lib="${dir}/$3"
local merged="$4"
if ! ${flat}; then
local resolved="$(readlink "${DESTDIR}${installdir}/$2/$3")"
[ -n "$resolved" ] && lib=$resolved
dir="${lib%/*}"
fi
if ${create}; then
mkdir -p "${dir}" || die "cannot create dir '${dir}'"
fi
[[ -f ${lib}-gdb.py ]] && rm -f "${lib}-gdb.py"
if [[ -n "${merged}" ]]; then
sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULES%!${*:5}!" \
"${GDBDIR}/autoload.template" > "${lib}-gdb.py"
else
sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULES%!$1!" \
"${GDBDIR}/autoload.template" > "${lib}-gdb.py"
fi
}
# dir where the autoloaders will be placed
autoloaddir=
# The installation dir. If only one of these is set, the other is set to
# the same value.
installdir=
# dir where the pretty printers will be placed
pythondir="${GDBDIR}"
# Create autoload dir if it does not exist. This only makes sense when
# installing into system gdb dir, so $autoloaddir must be absolute path.
create=false
# This option is only here to enable using the script during build of
# solenv/gdb . We must (or, better, want to :) avoid using the
# installation subpaths (like ure-link), because all libs in solver
# are in the same dir.
flat=false
# b de g jklmno qrstuvwxyzABCDEFGHIJK MNOPQRSTUVWXYZ0123456789
while getopts :a:cfhi:p:L opt; do
case ${opt} in
a) autoloaddir="${OPTARG}" ;;
c) create=true ;;
f) flat=true ;;
h) usage; exit ;;
i) installdir="${OPTARG}" ;;
p) pythondir="${OPTARG}" ;;
*) die "unknown option ${OPTARG}" ;;
esac
done
if [[ -z ${autoloaddir} && -z ${installdir} ]]; then
autoloaddir="${INSTALLDIR}"
installdir="${INSTALLDIR}"
elif [[ -n ${autoloaddir} && -z ${installdir} ]]; then
installdir="${autoloaddir}"
elif [[ -z ${autoloaddir} && -n ${installdir} ]]; then
autoloaddir="${installdir}"
fi
if [[ -n ${DESTDIR} ]]; then
[[ ${autoloaddir:0:1} = / ]] || die 'the arg to -a must be an absolute path'
[[ ${pythondir:0:1} = / ]] || die 'the arg to -p must be an absolute path'
fi
if ${create}; then
[[ ${autoloaddir:0:1} = / ]] || die 'the arg to -a must be an absolute path'
else
[[ ! -d ${DESTDIR}${autoloaddir} ]] && die "directory '${DESTDIR}${autoloaddir}' does not exist"
fi
[[ ! -d ${DESTDIR}${installdir} ]] && die "directory '${DESTDIR}${installdir}' does not exist"
[[ ! -d ${GDBDIR} ]] && die "directory '${GDBDIR}' does not exist"
if [[ ${DESTDIR}${pythondir} != ${GDBDIR} ]]; then
mkdir -p "${DESTDIR}${pythondir}" || die "cannot create dir '${DESTDIR}${pythondir}'"
cp -pr "${GDBDIR}/libreoffice" "${DESTDIR}${pythondir}"
fi
# keep in sync with solenv/Package_gdb.mk
if [[ -n "${MERGELIBS}" ]]; then
make_autoload merged program libmergedlo."$DYLIB" merge svl tl basegfx `[[ ${MERGELIBS} == "ALL" ]] && echo sw`
if [[ ${MERGELIBS} == "ALL" ]]; then
make_autoload urelibs ure/lib liburelibs."$DYLIB" merge cppu sal
else
make_autoload cppu ure/lib libuno_cppu."$DYLIB".3
make_autoload sal ure/lib libuno_sal."$DYLIB".3
make_autoload sw program libswlo."$DYLIB"
fi
else
make_autoload basegfx program libbasegfxlo."$DYLIB"
make_autoload cppu ure/lib libuno_cppu."$DYLIB".3
make_autoload sal ure/lib libuno_sal."$DYLIB".3
make_autoload svl program libsvllo."$DYLIB"
make_autoload sw program libswlo."$DYLIB"
make_autoload tl program libtllo."$DYLIB"
fi
make_autoload writerfilter program libwriterfilterlo."$DYLIB"
# vim:set shiftwidth=4 softtabstop=4 expandtab: