Split out non-recursive gir-to-swift.sh

This commit is contained in:
Rene Hexel 2016-06-17 06:58:27 +10:00
parent 177bdd8806
commit 8465c21efc
2 changed files with 28 additions and 21 deletions

View File

@ -1,28 +1,11 @@
#!/bin/sh
#
# Swift code wrapper generator for gobject-introspection (.gir) files.
# This needs an installed `gir2swift' executable (github.com/rhx/gir2swift)
# Recursive swift code wrapper generator for gobject-introspection (.gir) files.
# This calls the non-recursive gir-to-swift.sh to do the heavy lifting.
#
. ./config.sh
./package.sh fetch
mkdir -p Sources
GOBJECT_LIBDIR=`pkg-config --libs-only-L gobject-introspection-1.0 2>/dev/null | tr ' ' '\n' | grep gobject-introspection | tail -n1 | cut -c3-`
GOBJECT_DIR=`dirname "${GOBJECT_LIBDIR}"`
for prefix in $PREFIX GOBJECT_DIR /usr/local /usr ; do
gir_dir=${prefix}/share/gir-1.0
gir=${gir_dir}/${Module}.gir
if [ -e "${gir}" ] ; then
export GIR=${gir}
export GIR_DIR=${gir_dir}
fi
done
if [ ! -e "${GIR}" ] ; then
echo "*** ${GIR} does not exist!"
echo "Make sure libgirepository1.0-dev is installed"
echo "and can be found in /usr /usr/local or by pkg-config!"
exit 1
fi
for gen in Packages/*/generate-wrapper.sh ; do
for gen in Packages/*/gir-to-swift.sh ; do
( cd `dirname $gen` && ./`basename $gen` )
done
gir2swift -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}" | sed -f ${Module}.sed > Sources/${Module}.swift
. ./gir-to-swift.sh "$@"

24
gir-to-swift.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
#
# Swift code wrapper generator for gobject-introspection (.gir) files.
# This needs an installed `gir2swift' executable (github.com/rhx/gir2swift)
#
. ./config.sh
mkdir -p Sources
GOBJECT_LIBDIR=`pkg-config --libs-only-L gobject-introspection-1.0 2>/dev/null | tr ' ' '\n' | grep gobject-introspection | tail -n1 | cut -c3-`
GOBJECT_DIR=`dirname "${GOBJECT_LIBDIR}"`
for prefix in $PREFIX GOBJECT_DIR /usr/local /usr ; do
gir_dir=${prefix}/share/gir-1.0
gir=${gir_dir}/${Module}.gir
if [ -e "${gir}" ] ; then
export GIR=${gir}
export GIR_DIR=${gir_dir}
fi
done
if [ ! -e "${GIR}" ] ; then
echo "*** ${GIR} does not exist!"
echo "Make sure libgirepository1.0-dev is installed"
echo "and can be found in /usr /usr/local or by pkg-config!"
exit 1
fi
gir2swift -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}" | sed -f ${Module}.sed > Sources/${Module}.swift