vala-vapi.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #! /bin/sh
  2. # Copyright (C) 2012-2017 Free Software Foundation, Inc.
  3. #
  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.
  8. #
  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.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test and that vapi files are correctly handled by Vala support.
  17. required='pkg-config valac cc GNUmake'
  18. . test-init.sh
  19. cat >> configure.ac <<'END'
  20. AC_PROG_CC
  21. AM_PROG_VALAC([0.7.3])
  22. PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am <<'END'
  26. bin_PROGRAMS = zardoz
  27. AM_CFLAGS = $(GOBJECT_CFLAGS)
  28. LDADD = $(GOBJECT_LIBS)
  29. zardoz_SOURCES = zardoz.vala foo.vapi foo.h
  30. END
  31. cat > zardoz.vala <<'END'
  32. using GLib;
  33. public class Zardoz {
  34. public static void main () {
  35. stdout.printf (BARBAR);
  36. }
  37. }
  38. END
  39. # Use printf, not echo, to avoid '\n' being considered and escape
  40. # sequence and printed as a newline in 'foo.h'.
  41. printf '%s\n' '#define BARBAR "Zardoz!\n"' > foo.h
  42. cat > foo.vapi <<'END'
  43. [CCode (cprefix="", lower_case_cprefix="", cheader_filename="foo.h")]
  44. public const string BARBAR;
  45. END
  46. if ! cross_compiling; then
  47. unindent >> Makefile.am <<'END'
  48. check-local: test2
  49. .PHONY: test1 test2
  50. test1:
  51. ./zardoz
  52. ./zardoz | grep 'Zardoz!'
  53. test2:
  54. ./zardoz
  55. ./zardoz | grep 'Quux!'
  56. END
  57. fi
  58. $ACLOCAL
  59. $AUTOMAKE -a
  60. $AUTOCONF
  61. ./configure --enable-dependency-tracking
  62. $MAKE
  63. ls -l # For debugging.
  64. cat zardoz.c # Likewise.
  65. grep 'BARBAR' zardoz.c
  66. cross_compiling || $MAKE test1 || exit 1
  67. # Simple check on remake rules.
  68. $sleep
  69. # Use printf, not echo, to avoid '\n' being considered and escape
  70. # sequence and printed as a newline in 'foo.h'.
  71. printf '%s\n' '#define BAZBAZ "Quux!\n"' > foo.h
  72. sed 's/BARBAR/BAZBAZ/' zardoz.vala > t && mv -f t zardoz.vala || exit 99
  73. $MAKE && exit 1
  74. sed 's/BARBAR/BAZBAZ/' foo.vapi > t && mv -f t foo.vapi || exit 99
  75. $MAKE
  76. cat zardoz.c # For debugging.
  77. grep 'BAZBAZ' zardoz.c
  78. cross_compiling || $MAKE test2 || exit 1
  79. # Check the distribution.
  80. $MAKE distcheck
  81. :