1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#!/bin/sh
# autopkgtest check: Build and run a program against pygobject, to verify that
# the headers and pkg-config file are installed correctly
# (C) 2012 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
set -e
WORKDIR=$(mktemp -d)
trap 'rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM
cd "$WORKDIR"
if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
else
CROSS_COMPILE=
fi
cat <<EOF > pytest.c
#include <Python.h>
#include <pygobject.h>
#include <assert.h>
int main()
{
PyObject *gobject;
Py_InitializeEx (FALSE);
gobject = pygobject_init (-1, -1, -1);
assert (gobject != NULL);
return 0;
}
EOF
if python3 -c 'import sys; sys.exit(tuple(sys.version_info) < (3, 8))'; then
embed=python3-embed
else
embed=python3
fi
# Deliberately word-splitting, that's how pkg-config works:
# shellcheck disable=SC2046
"${CROSS_COMPILE}gcc" -o pytest pytest.c $("${CROSS_COMPILE}pkg-config" --cflags --libs "$embed" pygobject-3.0)
echo "build: OK"
[ -x pytest ]
./pytest
echo "run: OK"
|