office-gobmx/solenv/bin/install-gdb-printers

178 lines
6.1 KiB
Text
Raw Normal View History

2011-08-23 06:38:43 -05:00
#!/usr/bin/env bash
2011-09-06 00:50:12 -05:00
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# Copyright (C) 2010 Red Hat, Inc., David Tardon <dtardon@redhat.com>
# (initial developer)
#
# All Rights Reserved.
2011-09-06 00:50:12 -05:00
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
2011-08-09 03:35:19 -05:00
GDBDIR="${SOLARENV}/gdb"
SOLVERLIBDIR="${SOLARVER}/${INPATH}/lib"
2011-09-06 00:56:14 -05:00
INSTALLDIR="${SOLARVER}/${INPATH}/installation/opt"
DYLIB=so
if [ "$(uname)" = Darwin ]; then
INSTALLDIR=$INSTALLDIR/LibreOffice.app/Contents
DYLIB=dylib
fi
2011-08-09 03:35:19 -05:00
die() {
echo "$1" >&2
exit 1
}
2011-09-18 05:01:13 -05:00
usage() {
cat <<EOT
Install gdb pretty printers and autoloaders for them.
Usage:
install-gdb-printers [ -a dir ] [ -i dir ] [ -p dir ] [ -c ] [ -L ]
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.
-L Create symlinks to autoloaders already present in the build tree.
Only makes sense for dev. installation.
-p dir The dir where pretty printers are placed.
Env. variables:
DESTDIR If set, it is prepended to all dir arguments.
Examples:
1) Make pretty printers usable in your dev. installation (this is
already done as part of make dev-install, but it would not have been
run if smoketest failed):
install-gdb-printers -L
2) 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
}
2011-08-09 03:35:19 -05:00
make_autoload() {
local dir="${DESTDIR}${autoloaddir}"
${flat} || dir="${dir}/$2"
local lib="${dir}/$3"
if ! ${flat}; then
local resolved="$(readlink "${DESTDIR}${installdir}/$2/$3")"
[ -n "$resolved" ] && lib=$resolved
dir="${lib%/*}"
fi
2011-08-09 03:35:19 -05:00
if ${create}; then
mkdir -p "${dir}" || die "cannot create dir '${dir}'"
fi
if ${link}; then
if [[ ${dir} != ${SOLVERLIBDIR} ]]; then
local gdbname="${lib##*/}-gdb.py"
[[ -f ${dir}/${gdbname} ]] && rm -f "${dir}/${gdbname}"
ln -s "${SOLVERLIBDIR}/${gdbname}" "${dir}/${gdbname}"
fi
else
[[ -f ${lib}-gdb.py ]] && rm -f "${lib}-gdb.py"
sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULE%!libreoffice.$1!" \
"${GDBDIR}/autoload.template" > "${lib}-gdb.py"
fi
2011-08-09 03:35:19 -05:00
}
# 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=
2011-08-09 03:35:19 -05:00
# 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
# Create symlinks to existing autoloaders in solver. This only makes
# sense for dev-install.
link=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
2011-08-09 03:35:19 -05:00
2011-09-18 05:01:13 -05:00
# b de g jklmno qrstuvwxyzABCDEFGHIJK MNOPQRSTUVWXYZ0123456789
while getopts :a:cfhi:p:L opt; do
2011-08-09 03:35:19 -05:00
case ${opt} in
a) autoloaddir="${OPTARG}" ;;
c) create=true ;;
f) flat=true ;;
2011-09-18 05:01:13 -05:00
h) usage; exit ;;
i) installdir="${OPTARG}" ;;
2011-08-09 03:35:19 -05:00
p) pythondir="${OPTARG}" ;;
L) link=true ;;
2011-08-09 03:35:19 -05:00
*) die "unknown option ${OPTARG}" ;;
esac
done
2011-09-06 00:56:14 -05:00
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
${create} && ${link} && die "-c and -L cannot be used together"
2011-08-09 03:35:19 -05:00
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"
2011-08-09 03:35:19 -05:00
[[ ! -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}"
2011-08-09 03:35:19 -05:00
fi
make_autoload cppu ure-link/lib libuno_cppu."$DYLIB".3
make_autoload sal ure-link/lib libuno_sal."$DYLIB".3
make_autoload svl program libsvllo."$DYLIB"
make_autoload sw program libswlo."$DYLIB"
make_autoload tl program libtllo."$DYLIB"
2011-08-09 03:35:19 -05:00
# vim:set shiftwidth=4 softtabstop=4 expandtab: