gobject-introspection: Build introspection data

This commit is contained in:
Tee KOBAYASHI 2022-10-20 01:24:37 +09:00 committed by xtkoba
parent 24ed311d5c
commit eae4194b00
7 changed files with 143 additions and 24 deletions

View File

@ -74,6 +74,10 @@ source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_cabal.sh"
# shellcheck source=scripts/build/setup/termux_setup_jailbreak_cabal.sh
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_jailbreak_cabal.sh"
# Utility function for setting up GObject Introspection cross environment.
# shellcheck source=scripts/build/setup/termux_setup_gir.sh
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_gir.sh"
# Utility function for setting up GN toolchain.
# shellcheck source=scripts/build/setup/termux_setup_gn.sh
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_gn.sh"

View File

@ -4,14 +4,28 @@ TERMUX_PKG_LICENSE="LGPL-2.0, GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
_MAJOR_VERSION=1.74
TERMUX_PKG_VERSION=${_MAJOR_VERSION}.0
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://download.gnome.org/sources/gobject-introspection/${_MAJOR_VERSION}/gobject-introspection-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=347b3a719e68ba4c69ff2d57ee2689233ea8c07fc492205e573386779e42d653
TERMUX_PKG_BUILD_DEPENDS="glib, python"
TERMUX_PKG_DEPENDS="glib, libffi"
TERMUX_PKG_SUGGESTS="g-ir-scanner"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dcairo_libname=libcairo-gobject.so
-Dpython=python
-Dbuild_introspection_data=true
"
termux_step_pre_configure() {
termux_setup_gir
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+="
-Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=$GI_CROSS_LAUNCHER
-Dgi_cross_ldd_wrapper=$(command -v ldd)
"
unset GI_CROSS_LAUNCHER
fi
_PYTHON_VERSION=$(. $TERMUX_SCRIPTDIR/packages/python/build.sh; echo $_MAJOR_VERSION)
termux_setup_python_crossenv
@ -23,9 +37,9 @@ termux_step_pre_configure() {
popd
. ${_CROSSENV_PREFIX}/bin/activate
echo "Applying meson.diff"
echo "Applying meson-python.diff"
sed "s%@PYTHON_VERSION@%$_PYTHON_VERSION%g" \
$TERMUX_PKG_BUILDER_DIR/meson.diff | patch --silent -p1
$TERMUX_PKG_BUILDER_DIR/meson-python.diff | patch --silent -p1
CPPFLAGS+="
-I$TERMUX_PREFIX/include/python${_PYTHON_VERSION}

View File

@ -0,0 +1,9 @@
TERMUX_SUBPKG_INCLUDE="
bin/g-ir-scanner
lib/gobject-introspection/giscanner/
share/man/man1/g-ir-scanner.1.gz
"
TERMUX_SUBPKG_DESCRIPTION="A tool which generates GIR XML files"
TERMUX_SUBPKG_DEPENDS="ldd, python"
TERMUX_SUBPKG_BREAKS="gobject-introspection (<< 1.74.0-1)"
TERMUX_SUBPKG_REPLACES="gobject-introspection (<< 1.74.0-1)"

View File

@ -0,0 +1,42 @@
#!/bin/sh
PRE_GENERATED_DUMP_DIR="$TERMUX_PKG_GIR_PRE_GENERATED_DUMP_DIR"
G_IR_COMPILER="${TERMUX_G_IR_COMPILER:-g-ir-compiler}"
ERROR_HEADER="gi-cross-launcher: ERROR:"
#logfile="$(readlink -f "$(dirname "$0")")/../gi-cross-launcher.log"
#echo "$@" >> "$logfile"
cmd="$1"
case "$cmd" in
*/g-ir-compiler | g-ir-compiler )
shift
for a in "$@"; do
case "$a" in
--shared-library=* | --shared-library )
echo "$ERROR_HEADER This script does not support --shared-library option for g-ir-compiler." >&2
echo "$ERROR_HEADER Command: $cmd $@" >&2
exit 1
;;
esac
done
exec "$G_IR_COMPILER" "$@"
;;
esac
arg="$2"
case "$arg" in
--introspect-dump=*,* ) ;;
* ) echo "$ERROR_HEADER Unsupported command: $@" >&2 ;;
esac
cmd_base="$(basename "$cmd")"
pre_gen="$PRE_GENERATED_DUMP_DIR/${cmd_base}.xml"
if [ ! -e "$pre_gen" ]; then
echo "$ERROR_HEADER Pre-generated dump for $cmd_base not found." >&2
echo "$ERROR_HEADER Expected file: $pre_gen" >&2
exit 1
fi
dest_xml="${arg##*,}"
cp "$pre_gen" "$dest_xml" || exit 1

View File

@ -49,24 +49,3 @@ diff -uNr gobject-introspection/meson.build gobject-introspection.mod/meson.buil
# cairo
cairo_option = get_option('cairo')
if cc.get_id() == 'msvc'
diff -uNr gobject-introspection/meson_options.txt gobject-introspection.mod/meson_options.txt
--- gobject-introspection/meson_options.txt 2021-06-03 13:43:38.062569940 +0000
+++ gobject-introspection.mod/meson_options.txt 2021-06-03 13:59:44.285204579 +0000
@@ -26,7 +26,7 @@
description: 'Intermediate prefix for gir installation under ${prefix}'
)
-option('gi_cross_use_prebuilt_gi', type: 'boolean', value : false,
+option('gi_cross_use_prebuilt_gi', type: 'boolean', value : true,
description: 'Use gobject introspection tools installed in the build system (useful when cross-compiling)'
)
@@ -38,7 +38,7 @@
description: 'Use a ldd wrapper instead of system ldd command in giscanner (useful when cross-compiling)'
)
-option('build_introspection_data', type: 'boolean', value : true,
+option('build_introspection_data', type: 'boolean', value : false,
description: 'Build introspection data (.gir and .typelib files) in addition to library and tools'
)

View File

@ -0,0 +1,15 @@
--- a/meson.build
+++ b/meson.build
@@ -251,9 +249,9 @@
pkgconfig_variables = [
'datadir=' + '${prefix}' / get_option('datadir'),
'bindir=' + '${prefix}' / get_option('bindir'),
- 'g_ir_scanner=${bindir}/g-ir-scanner',
- 'g_ir_compiler=${bindir}/g-ir-compiler@0@'.format(exe_ext),
- 'g_ir_generate=${bindir}/g-ir-generate@0@'.format(exe_ext),
+ 'g_ir_scanner=g-ir-scanner',
+ 'g_ir_compiler=g-ir-compiler@0@'.format(exe_ext),
+ 'g_ir_generate=g-ir-generate@0@'.format(exe_ext),
'gidatadir=${datadir}/gobject-introspection-1.0',
'girdir=' + gir_dir_pc_prefix / 'gir-1.0',
'typelibdir=${libdir}/girepository-1.0',

View File

@ -0,0 +1,56 @@
termux_setup_gir() {
if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then
return
fi
local _GIR_CROSS_FOLDER="$TERMUX_COMMON_CACHEDIR/gir-cross"
local bin="$_GIR_CROSS_FOLDER/bin"
export GI_CROSS_LAUNCHER="$bin/gi-cross-launcher"
local scanner="$bin/g-ir-scanner"
local compiler="$bin/g-ir-compiler"
local ldd="$bin/ldd"
if [ ! -d "$_GIR_CROSS_FOLDER" ]; then
install -Dm700 -T \
"$TERMUX_SCRIPTDIR/packages/gobject-introspection/gi-cross-launcher.sh" \
"$GI_CROSS_LAUNCHER"
cat > "$scanner" <<-EOF
#!$(command -v sh)
export XDG_DATA_DIRS="$TERMUX_PREFIX/share"
exec /usr/bin/g-ir-scanner "\$@"
EOF
chmod 0700 "$scanner"
cat > "$compiler" <<-EOF
#!$(command -v sh)
exec /usr/bin/g-ir-compiler "\$@" \
--includedir "$TERMUX_PREFIX/share/gir-1.0"
EOF
chmod 0700 "$compiler"
cat > "$ldd" <<-EOF
#!/bin/bash-static
unset LD_LIBRARY_PATH
EOF
sed 1d "$TERMUX_SCRIPTDIR/packages/ldd/ldd.in" >> "$ldd"
chmod 0700 "$ldd"
fi
local env
for env in CC CXX; do
local cmd="$(eval echo \${$env})"
local w="$bin/$(basename "$cmd")"
if [ ! -e "$w" ]; then
cat > "$w" <<-EOF
#!/bin/bash-static
unset LD_LIBRARY_PATH
exec "$(command -v "$cmd")" "\$@"
EOF
chmod 0700 "$w"
fi
done
export PATH="$bin:$PATH"
# For convenience:
export TERMUX_PKG_GIR_PRE_GENERATED_DUMP_DIR="$TERMUX_PKG_BUILDER_DIR/gir/${TERMUX_PKG_VERSION##*:}"
export TERMUX_G_IR_COMPILER="$compiler"
}