doc: update Vala documentation
[automake.git] / t / vala-vapi.sh
blob9983710195ba8d6fc3d8274f887024d8ea7580f5
1 #! /bin/sh
2 # Copyright (C) 2012-2024 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Test that vapi files are correctly handled by Vala support.
19 required='pkg-config valac cc GNUmake'
20 . test-init.sh
22 cat >> configure.ac <<'END'
23 AC_PROG_CC
24 AM_PROG_VALAC([0.7.3])
25 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
26 AC_OUTPUT
27 END
29 cat > Makefile.am <<'END'
30 bin_PROGRAMS = zardoz
31 AM_CFLAGS = $(GOBJECT_CFLAGS)
32 LDADD = $(GOBJECT_LIBS)
33 zardoz_SOURCES = zardoz.vala foo.vapi foo.h
34 END
36 cat > zardoz.vala <<'END'
37 using GLib;
38 public class Zardoz {
39 public static void main () {
40 stdout.printf (BARBAR);
43 END
45 # Use printf, not echo, to avoid '\n' being considered an escape
46 # sequence and printed as a newline in 'foo.h'.
47 printf '%s\n' '#define BARBAR "Zardoz!\n"' > foo.h
49 cat > foo.vapi <<'END'
50 [CCode (cprefix="", lower_case_cprefix="", cheader_filename="foo.h")]
51 public const string BARBAR;
52 END
54 if ! cross_compiling; then
55 unindent >> Makefile.am <<'END'
56 check-local: test2
57 .PHONY: test1 test2
58 test1:
59 ./zardoz
60 ./zardoz | grep 'Zardoz!'
61 test2:
62 ./zardoz
63 ./zardoz | grep 'Quux!'
64 END
67 $ACLOCAL
68 $AUTOMAKE -a
69 $AUTOCONF
71 ./configure --enable-dependency-tracking
73 $MAKE
74 ls -l # For debugging.
75 cat zardoz.c # Likewise.
76 grep 'BARBAR' zardoz.c
77 cross_compiling || $MAKE test1 || exit 1
79 # Simple check on remake rules.
80 $sleep
81 # Use printf, not echo, to avoid '\n' being considered an escape
82 # sequence and printed as a newline in 'foo.h'.
83 printf '%s\n' '#define BAZBAZ "Quux!\n"' > foo.h
84 sed 's/BARBAR/BAZBAZ/' zardoz.vala > t && mv -f t zardoz.vala || exit 99
85 $MAKE && exit 1
86 sed 's/BARBAR/BAZBAZ/' foo.vapi > t && mv -f t foo.vapi || exit 99
87 $MAKE
88 cat zardoz.c # For debugging.
89 grep 'BAZBAZ' zardoz.c
90 cross_compiling || $MAKE test2 || exit 1
92 # Check the distribution.
93 $MAKE distcheck