Debian Codegraph @

debian/tests/build

raw
1 #!/bin/sh -eu
2
3 workdir=$(mktemp -d)
4 cleanup() {
5 rm -fr "$workdir"
6 }
7 trap cleanup 0 INT QUIT ABRT PIPE TERM
8 cd "$workdir"
9
10 out=out
11
12 <<-\EOF g++ -x c++ - -o "$out" $(pkg-config --cflags --libs cairomm-1.16)
13 // From cairographics.org/documentation/cairomm/reference/toy-text_8cc-example.html
14 #include <cairomm/cairomm.h>
15 const double HEIGHT = 200.0;
16 const double WIDTH = 400.0;
17 const double FONT_SIZE = 64.0;
18 const double TEXT_ORIGIN_Y = (HEIGHT / 2.0) + (FONT_SIZE / 2.0);
19 const double TEXT_ORIGIN_X = 50.0; // arbitrary
20 int main(int, char**)
21 {
22 auto surface =
23 Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, WIDTH, HEIGHT);
24 auto cr = Cairo::Context::create(surface);
25 // fill background in white
26 cr->set_source_rgb(1.0, 1.0, 1.0);
27 cr->paint();
28 // draw a little dot at the point where text will be drawn
29 cr->arc(TEXT_ORIGIN_X, TEXT_ORIGIN_Y, FONT_SIZE / 4.0, 0, 2*M_PI);
30 cr->set_source_rgba(0.0, 1.0, 0.0, 0.5);
31 cr->fill();
32 // draw the text
33 cr->move_to(TEXT_ORIGIN_X, TEXT_ORIGIN_Y);
34 cr->set_source_rgb(0.8, 0.2, 0.2);
35 auto font =
36 Cairo::ToyFontFace::create("Bitstream Charter",
37 Cairo::ToyFontFace::Slant::ITALIC,
38 Cairo::ToyFontFace::Weight::BOLD);
39 cr->set_font_face(font);
40 cr->set_font_size(FONT_SIZE);
41 cr->show_text("cairomm!");
42 surface->write_to_png("toy-text.png");
43 return 0;
44 }
45 EOF
46
47 echo "build: OK"
48 ./"$out"
49 echo "run: OK"