Debian Codegraph @

debian/tests/build3

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