File: build

package info (click to toggle)
cairo 1.18.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 72,788 kB
  • sloc: ansic: 217,451; cpp: 2,108; cs: 1,763; xml: 1,280; sh: 990; python: 433; javascript: 347; awk: 89; makefile: 87
file content (56 lines) | stat: -rwxr-xr-x 1,567 bytes parent folder | download | duplicates (4)
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
48
49
50
51
52
53
54
55
56
#!/bin/sh
# autopkgtest check: Builds a small application against libcairo2-dev, checking
# if it compiles, links and runs successfully.
# Author: Rafał Cieślak <rafalcieslak256@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 > build_test.c
/*
   The source code I used here is the actual cairo's
   HelloWorld from it's FAQ on cairographics.org.
   It should generate a .png file with some text inside. 
*/

#include <cairo.h>
int
main (int argc, char *argv[])
{
        cairo_surface_t *surface =
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
        cairo_t *cr =
            cairo_create (surface);

        cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
        cairo_set_font_size (cr, 32.0);
        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
        cairo_move_to (cr, 10.0, 50.0);
        cairo_show_text (cr, "Hello, world");

        cairo_destroy (cr);
        cairo_surface_write_to_png (surface, "hello.png");
        cairo_surface_destroy (surface);
        return 0;
}
EOF

# Deliberately word-splitting, that's how pkg-config works:
# shellcheck disable=SC2046
"${CROSS_COMPILE}gcc" -o build_test build_test.c $("${CROSS_COMPILE}pkg-config" --cflags --libs cairo)
echo "build: OK"
[ -x build_test ]
./build_test
# Also checking if the generated image is actually present
[ -e hello.png ]
echo "run: OK"