[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 4/4] Improve Vala support.



* automake.in: Update to Vala 0.7.0 semantics, recover from removal
of built sources, support silent-rules, drop _PKGNAME variables
* doc/automake.texi, NEWS: Update.
* lib/am/vala.am: Bump copyright years.
* m4/vala.m4: Likewise.
* tests/vala.test: Remove obsolete grep tests.
* tests/vala1.test: Likewise.
* tests/vala2.test: Test full build, distcheck, and distclean.
* tests/vala3.test: Likewise, also test with subdir-objects.
* tests/vala4.test: Bump copyright years.
* tests/vala5.test: New test for per-target flags, expected to fail.
* tests/Makefile.am: Update.
* THANKS: Update.

Signed-off-by: J=C3=BCrg Billeter <j bitron ch>
---
 ChangeLog         |   17 ++++++++++++
 THANKS            |    2 +
 automake.in       |   62 ++++++++++++++++++++++----------------------
 doc/automake.texi |   15 +++-------
 lib/am/vala.am    |    2 +-
 m4/vala.m4        |    2 +-
 tests/Makefile.am |    4 ++-
 tests/Makefile.in |    4 ++-
 tests/vala.test   |    7 +---
 tests/vala1.test  |    7 +---
 tests/vala2.test  |   55 ++++++++++++++++++++++++++++-----------
 tests/vala3.test  |   63 ++++++++++++++++++++++++++++++++++++--------
 tests/vala4.test  |    2 +-
 tests/vala5.test  |   74 +++++++++++++++++++++++++++++++++++++++++++++++++=
++++
 14 files changed, 232 insertions(+), 84 deletions(-)
 create mode 100755 tests/vala5.test

diff --git a/ChangeLog b/ChangeLog
index 3a7657e..207e2df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-04-05  J=C3=BCrg Billeter  <j bitron ch>
+
+	Improve Vala support.
+	* automake.in: Update to Vala 0.7.0 semantics, recover from removal
+	of built sources, support silent-rules, drop _PKGNAME variables
+	* doc/automake.texi, NEWS: Update.
+	* lib/am/vala.am: Bump copyright years.
+	* m4/vala.m4: Likewise.
+	* tests/vala.test: Remove obsolete grep tests.
+	* tests/vala1.test: Likewise.
+	* tests/vala2.test: Test full build, distcheck, and distclean.
+	* tests/vala3.test: Likewise, also test with subdir-objects.
+	* tests/vala4.test: Bump copyright years.
+	* tests/vala5.test: New test for per-target flags, expected to fail.
+	* tests/Makefile.am: Update.
+	* THANKS: Update.
+
 2008-10-10  Ralf Wildenhues  <Ralf Wildenhues gmx de>
=20
 	Minor fixups for Vala support.
diff --git a/THANKS b/THANKS
index 9f91c9c..6235436 100644
--- a/THANKS
+++ b/THANKS
@@ -164,6 +164,7 @@ Juergen A. Erhard	jae laden ilk de
 Juergen Keil		jk tools de
 Juergen Leising		juergen leising gmx de
 Julien Sopena		julien sopena lip6 fr
+J=C3=BCrg Billeter		j bitron ch
 Karl Berry		kb cs umb edu
 Karl Heuer		kwzh gnu org
 Kelley Cook		kcook gcc gnu org
@@ -202,6 +203,7 @@ Martin Frydl		martin idoox com
 Martin Waitz		tali admingilde org
 Mathias Doreille	doreille smr ch
 Mathias Froehlich	M Froehlich science-computing de
+Mathias Hasselmann	mathias hasselmann gmx de
 Matt Leach		mleach cygnus com
 Matthew D. Langston	langston SLAC Stanford EDU
 Matthias Andree		matthias andree gmx de
diff --git a/automake.in b/automake.in
index e2e5643..a756089 100755
--- a/automake.in
+++ b/automake.in
@@ -817,11 +817,11 @@ register_language ('name' =3D> 'vala',
 		   'config_vars' =3D> ['VALAC'],
 		   'flags' =3D> ['VALAFLAGS'],
 		   'compile' =3D> '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)',
+		   'ccer' =3D> 'VALAC',
 		   'compiler' =3D> 'VALACOMPILE',
 		   'extensions' =3D> ['.vala'],
-		   'output_extensions' =3D> sub { (my $ext1 =3D $_[0]) =3D~ s/vala$/c/;
-						(my $ext2 =3D $_[0]) =3D~ s/vala$/h/;
-						return ($ext1, $ext2) },
+		   'output_extensions' =3D> sub { (my $ext =3D $_[0]) =3D~ s/vala$/c/;
+						return ($ext,) },
 		   'rule_file' =3D> 'vala',
 		   '_finish' =3D> \&lang_vala_finish,
 		   '_target_hook' =3D> \&lang_vala_target_hook,
@@ -5907,9 +5907,9 @@ sub lang_c_finish
     }
 }
=20
-sub lang_vala_finish_target ($$$)
+sub lang_vala_finish_target ($$)
 {
-  my ($self, $name, $pkgname) =3D @_;
+  my ($self, $name) =3D @_;
=20
   my $derived =3D canonicalize ($name);
   my $varname =3D $derived . '_SOURCES';
@@ -5919,22 +5919,17 @@ sub lang_vala_finish_target ($$$)
     {
       foreach my $file ($var->value_as_list_recursive)
         {
-          $output_rules .=3D "$file: ${derived}_vala.stamp\n"
-            if ($file =3D~ s/(.*)\.vala$/$1.c $1.h/);
+          $output_rules .=3D "$file: ${derived}_vala.stamp\n".
+            "\t\ if test -f \$@; then :; else \\\n".
+            "\t  rm -f ${derived}_vala.stamp; \\\n".
+            "\t  \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n".
+            "\tfi\n"
+            if $file =3D~ s/(.*)\.vala$/$1.c/;
         }
     }
=20
   my $compile =3D $self->compile;
=20
-  if (defined ($pkgname))
-    {
-      $varname =3D $derived . '_PKGNAME';
-      $var =3D var ($varname);
-
-      $pkgname =3D $var->variable_value if $var;
-      $compile =3D~s/\$\(AM_VALAFLAGS\)/--library=3D$pkgname $&/;
-    }
-
   # Rewrite each occurrence of `AM_$flag' in the compile
   # rule into `${derived}_$flag' if it exists.
   for my $flag (@{$self->flags})
@@ -5946,42 +5941,47 @@ sub lang_vala_finish_target ($$$)
=20
   my $dirname =3D dirname ($name);
=20
-  $compile .=3D " -d $dirname" if $dirname ne '.';
+  # Only generate C code, do not run C compiler
+  $compile .=3D " -C";
+
+  my $verbose =3D verbose_flag ('VALAC');
+  my $silent =3D silent_flag ();
=20
   $output_rules .=3D
     "${derived}_vala.stamp: \$(${derived}_SOURCES)\n".
-    "\t${compile} \$^ && touch \$ \n";
+    "\t${verbose}${compile} \$(${derived}_SOURCES)\n".
+    "\t${silent}touch \$ \n";
+
+  push_dist_common ("${derived}_vala.stamp");
+
+  $clean_files{"${derived}_vala.stamp"} =3D MAINTAINER_CLEAN;
 }
=20
-# This is a vala helper which is called after all source file
-# processing is done.
+# Add output ruless to invoke valac and create stamp file as a witness
+# to handle multiple outputs. This function is called after all source
+# file processing is done.
 sub lang_vala_finish
 {
   my ($self) =3D @_;
=20
   foreach my $prog (keys %known_programs)
     {
-      lang_vala_finish_target ($self, $prog, 0);
+      lang_vala_finish_target ($self, $prog);
     }
=20
-  while (my ($name, $pkgname) =3D each %known_libraries)
+  while (my ($name) =3D each %known_libraries)
     {
-      lang_vala_finish_target ($self, $name, $pkgname);
+      lang_vala_finish_target ($self, $name);
     }
 }
=20
-# This is a vala helper which is called whenever we have decided to
-# compile a vala file.
+# The built .c files should be cleaned only on maintainer-clean
+# as the .c files are distributed. This function is called for each
+# .vala source file.
 sub lang_vala_target_hook
 {
   my ($self, $aggregate, $output, $input, %transform) =3D @_;
=20
-  (my $output_base =3D $output) =3D~ s/$KNOWN_EXTENSIONS_PATTERN$//;
-  my $header =3D $output_base . '.h';
-
-  &push_dist_common ($header);
-
-  $clean_files{$header} =3D MAINTAINER_CLEAN;
   $clean_files{$output} =3D MAINTAINER_CLEAN;
 }
=20
diff --git a/doc/automake.texi b/doc/automake.texi
index 05f2bfd..fc3c434 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -6603,15 +6603,16 @@ the @code{_LDFLAGS} variable for the program.
 @cindex Vala Support
 @cindex Support for Vala
=20
-Automake provides support for Vala compilation
-(@uref{http://live.gnome.org/@/Vala}).
+Automake provides support for Vala (@uref{http://www.vala-project.org/}).
+This requires valac version 0.7.0 or later.
=20
 @example
 foo_SOURCES =3D foo.vala bar.vala zardoc.c
 @end example
=20
 Any @file{.vala} file listed in a @code{_SOURCE} variable will be
-compiled into C code by the Vala compiler.
+compiled into C code by the Vala compiler. The generated @file{.c} files a=
re
+distributed. The end user does not need to have a Vala compiler installed.
=20
 Automake ships with an Autoconf macro called @code{AM_PROG_VALAC}
 that will locate the Vala compiler and optionally check its version
@@ -6623,7 +6624,7 @@ Try to find a Vala compiler in @env{PATH}. If it is f=
ound, the variable
 can be requested:
=20
 @example
-AM_PROG_VALAC([0.1.3])
+AM_PROG_VALAC([0.7.0])
 @end example
 @end defmac
=20
@@ -6639,14 +6640,8 @@ Additional arguments for the Vala compiler.
 @item AM_VALAFLAGS
 The maintainer's variant of @code{VALAFLAGS}.
=20
- item PKGNAME
-The pkg-config
-(@uref{http://www.freedesktop.org/@/software/@/pkgconfig/}) and VAPI
-(Vala API definition file) name to use when building Vala based library.
-
 @example
 lib_LTLIBRARIES =3D libfoo.la
-libfoo_la_PKGNAME =3D foo-2.0
 libfoo_la_SOURCES =3D foo.vala
 @end example
 @end vtable
diff --git a/lib/am/vala.am b/lib/am/vala.am
index fa2a23c..ed12dc5 100644
--- a/lib/am/vala.am
+++ b/lib/am/vala.am
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2008  Free Software Foundation, Inc.
+## Copyright (C) 2008, 2009  Free Software Foundation, Inc.
=20
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
diff --git a/m4/vala.m4 b/m4/vala.m4
index 5606296..d3f73a5 100644
--- a/m4/vala.m4
+++ b/m4/vala.m4
@@ -1,6 +1,6 @@
 # Autoconf support for the Vala compiler
=20
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 88619b4..7b17271 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,7 +4,8 @@ XFAIL_TESTS =3D					\
 all.test					\
 auxdir2.test					\
 cond17.test					\
-txinfo5.test
+txinfo5.test					\
+vala5.test
=20
 include $(srcdir)/parallel-tests.am
=20
@@ -695,6 +696,7 @@ vala1.test \
 vala2.test \
 vala3.test \
 vala4.test \
+vala5.test \
 vars.test \
 vars3.test \
 vartar.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 11a9f8e..d1c1ccb 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -228,7 +228,8 @@ XFAIL_TESTS =3D \
 all.test					\
 auxdir2.test					\
 cond17.test					\
-txinfo5.test
+txinfo5.test					\
+vala5.test
=20
 parallel_tests =3D \
 check-p.test \
@@ -927,6 +928,7 @@ vala1.test \
 vala2.test \
 vala3.test \
 vala4.test \
+vala5.test \
 vars.test \
 vars3.test \
 vartar.test \
diff --git a/tests/vala.test b/tests/vala.test
index c9b12af..a0e97ad 100755
--- a/tests/vala.test
+++ b/tests/vala.test
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006, 2008  Free Software Foundation,
-# Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -54,9 +54,6 @@ grep 'am_zardoz_OBJECTS' Makefile.in
 grep 'am_libzardoz_la_OBJECTS' Makefile.in
 grep 'zardoz_vala.stamp' Makefile.in
 grep 'libzardoz_la_vala.stamp' Makefile.in
-grep ' --library=3Dlibzardoz' Makefile.in
 grep 'zardoz\.c' Makefile.in
-grep 'zardoz\.h' Makefile.in
 grep 'zardoz-foo\.c' Makefile.in
-grep 'zardoz-foo\.h' Makefile.in
=20
diff --git a/tests/vala1.test b/tests/vala1.test
index 69edb15..158adcf 100755
--- a/tests/vala1.test
+++ b/tests/vala1.test
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006, 2008  Free Software Foundation,
-# Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -54,8 +54,5 @@ grep 'src_zardoz_OBJECTS' Makefile.in
 grep 'src_libzardoz_la_OBJECTS' Makefile.in
 grep 'src_zardoz_vala.stamp' Makefile.in
 grep 'src_libzardoz_la_vala.stamp' Makefile.in
-grep ' --library=3Dlibzardoz' Makefile.in
 grep 'zardoz\.c' Makefile.in
-grep 'zardoz\.h' Makefile.in
 grep 'src/zardoz-foo\.c' Makefile.in
-grep 'src/zardoz-foo\.h' Makefile.in
diff --git a/tests/vala2.test b/tests/vala2.test
index ce568d5..6209aa6 100755
--- a/tests/vala2.test
+++ b/tests/vala2.test
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006, 2008  Free Software Foundation,
-# Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -19,36 +19,59 @@
 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
=20
-# Test to make foo_PKGNAME variables are considered.
+# Test to make sure compiling Vala code really works with recursive make.
=20
-required=3D"libtool"
+required=3D"libtool libtoolize pkg-config valac gcc"
 . ./defs || Exit 1
=20
 set -e
=20
+mkdir src
+
 cat >> 'configure.in' << 'END'
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
 AM_PROG_VALAC
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >=3D 2.10])
+AC_CONFIG_FILES([src/Makefile])
 AC_OUTPUT
 END
=20
 cat > 'Makefile.am' <<'END'
-lib_LTLIBRARIES =3D src/libzardoz.la
-src_libzardoz_la_SOURCES =3D src/zardoz-foo.vala src/zardoz-bar.vala
-src_libzardoz_la_PKGNAME =3D zardoz+-3.0
+SUBDIRS =3D src
+END
+
+cat > 'src/Makefile.am' <<'END'
+bin_PROGRAMS =3D zardoz
+zardoz_CFLAGS =3D $(GOBJECT_CFLAGS)
+zardoz_LDADD =3D $(GOBJECT_LIBS)
+zardoz_SOURCES =3D zardoz.vala
 END
=20
-: > ltmain.sh
-: > config.sub
-: > config.guess
+cat > 'src/zardoz.vala' <<'END'
+using GLib;
+
+public class Zardoz {
+  public static void main () {
+    stdout.printf ("Zardoz!\n");
+  }
+}
+END
+
+libtoolize
=20
 $ACLOCAL
+$AUTOCONF
 $AUTOMAKE -a
=20
-grep 'VALAC' Makefile.in
-grep 'src_libzardoz_la_OBJECTS' Makefile.in
-grep 'src_libzardoz_la_vala.stamp' Makefile.in
-grep ' --library=3Dzardoz+-3.0' Makefile.in
-grep 'src/zardoz-foo\.c' Makefile.in
-grep 'src/zardoz-foo\.h' Makefile.in
+./configure
+$MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
diff --git a/tests/vala3.test b/tests/vala3.test
index 41b083d..7815393 100755
--- a/tests/vala3.test
+++ b/tests/vala3.test
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006  Free Software Foundation, Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -18,7 +19,7 @@
 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
=20
-# Test to make sure compiling Vala code really works.
+# Test to make sure compiling Vala code really works with non-recursive ma=
ke.
=20
 required=3D"libtool libtoolize pkg-config valac gcc"
 . ./defs || Exit 1
@@ -31,18 +32,11 @@ cat >> 'configure.in' << 'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
-AM_PROG_VALAC
-PKG_CHECK_MODULES(GOBJECT,gobject-2.0 >=3D 2.10)
+AM_PROG_VALAC([0.7.0])
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >=3D 2.10])
 AC_OUTPUT
 END
=20
-cat > 'Makefile.am' <<'END'
-bin_PROGRAMS =3D src/zardoz
-src_zardoz_CFLAGS =3D $(GOBJECT_CFLAGS)
-src_zardoz_LDADD =3D $(GOBJECT_LIBS)
-src_zardoz_SOURCES =3D src/zardoz.vala
-END
-
 cat > 'src/zardoz.vala' <<'END'
 using GLib;
=20
@@ -53,12 +47,57 @@ public class Zardoz {
 }
 END
=20
+cat > 'Makefile.am' <<'END'
+bin_PROGRAMS =3D src/zardoz
+src_zardoz_CFLAGS =3D $(GOBJECT_CFLAGS)
+src_zardoz_LDADD =3D $(GOBJECT_LIBS)
+src_zardoz_SOURCES =3D src/zardoz.vala
+END
+
 libtoolize
=20
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
=20
-./configure
+./configure || Exit 77
 $MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
+cd ..
+rm -rf build
+
+# Try again with subdir-objects.
+
+cat > 'Makefile.am' <<'END'
+AUTOMAKE_OPTIONS =3D subdir-objects
+
+bin_PROGRAMS =3D src/zardoz
+src_zardoz_CFLAGS =3D $(GOBJECT_CFLAGS)
+src_zardoz_LDADD =3D $(GOBJECT_LIBS)
+src_zardoz_SOURCES =3D src/zardoz.vala
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure || Exit 77
+$MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
=20
diff --git a/tests/vala4.test b/tests/vala4.test
index a2e8c96..1f9d2ca 100755
--- a/tests/vala4.test
+++ b/tests/vala4.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
diff --git a/tests/vala5.test b/tests/vala5.test
new file mode 100755
index 0000000..7369186
--- /dev/null
+++ b/tests/vala5.test
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test per-target flags, expected to fail.
+
+required=3D"libtool libtoolize pkg-config valac gcc"
+. ./defs || Exit 1
+
+set -e
+
+mkdir src
+
+cat >> 'configure.in' << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AM_PROG_VALAC
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >=3D 2.10])
+AC_CONFIG_FILES([src/Makefile])
+AC_OUTPUT
+END
+
+cat > 'Makefile.am' <<'END'
+SUBDIRS =3D src
+END
+
+cat > 'src/Makefile.am' <<'END'
+bin_PROGRAMS =3D foo bar
+foo_CFLAGS =3D $(GOBJECT_CFLAGS)
+foo_LDADD =3D $(GOBJECT_LIBS)
+foo_SOURCES =3D baz.vala
+bar_SOURCES =3D baz.vala
+bar_VALAFLAGS =3D -D BAR
+bar_CFLAGS =3D $(GOBJECT_CFLAGS)
+bar_LDADD =3D $(GOBJECT_LIBS)
+END
+
+cat > 'src/baz.vala' <<'END'
+void main () {
+#if BAR
+  stdout.printf ("bar\n");
+#else
+  stdout.printf ("foo\n");
+#endif
+}
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+
--=20
1.6.2


--=-APPv+E+8H4TC71lu6N1g--



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]