Subject: bug#70557: Fix compilation of Vala files conditionally added to _SOURCES

From: Reuben Thomas <[email-masked]>
Date: Mon, 29 Apr 2024 00:06:31 +0200

On Sat, 27 Apr 2024 at 20:36, Reuben Thomas <[email-masked]> wrote:

> On Sat, 27 Apr 2024 at 00:53, Karl Berry <[email-masked]> wrote:
>
>> Reuben, any chance you can whomp up a test for this patch?
>>
>
> No problem, I will do this when I can find a moment. Since I don't
> actually need this fix after all, it may not be quick!
>

I found a moment, but not a fix. In fact, a fix is not in general possible
(or at least, not without a considerable amount of messing around). The
problem is that the Vala compiler needs to be able to see all the symbols
in the program, so you have to give it all the source files at once, so you
can't give it source files that contain alternative (duplicate) definitions
of the same symbol.

Hence, having conditionally-added sources like this is not compatible with
shipping all C sources in the tarball, or to put it another way, with
making the Vala compiler optional. But I think this is a great feature of
Automake's Vala support! (Certainly, I believe it is unique.)

So if Automake had in future a mode where it shipped only Vala sources,
then in that mode it would make sense to conditionally-include Vala
sources, and that would work.

As a consolation, I attach another patch that fixes some English in
comments in one of the Vala tests.

I guess it is worth documenting this limitation of the current Vala
support. If you agree with my reasoning above, then I will prepare a
documentation patch based on it.

-- 
https://rrt.sc3d.org
From 1224a4ef1d9a983cd45de42b466bda8d919446be Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 28 Apr 2024 20:42:20 +0200
Subject: [PATCH 2/3] vala: fix some English in test comments

---
 t/vala-vapi.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/vala-vapi.sh b/t/vala-vapi.sh
index dfdb0a8e5..998371019 100644
--- a/t/vala-vapi.sh
+++ b/t/vala-vapi.sh
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-# Test and that vapi files are correctly handled by Vala support.
+# Test that vapi files are correctly handled by Vala support.
 
 required='pkg-config valac cc GNUmake'
 . test-init.sh
@@ -42,7 +42,7 @@ public class Zardoz {
 }
 END
 
-# Use printf, not echo, to avoid '\n' being considered and escape
+# Use printf, not echo, to avoid '\n' being considered an escape
 # sequence and printed as a newline in 'foo.h'.
 printf '%s\n' '#define BARBAR "Zardoz!\n"' > foo.h
 
@@ -78,7 +78,7 @@ cross_compiling || $MAKE test1 || exit 1
 
 # Simple check on remake rules.
 $sleep
-# Use printf, not echo, to avoid '\n' being considered and escape
+# Use printf, not echo, to avoid '\n' being considered an escape
 # sequence and printed as a newline in 'foo.h'.
 printf '%s\n' '#define BAZBAZ "Quux!\n"' > foo.h
 sed 's/BARBAR/BAZBAZ/' zardoz.vala > t && mv -f t zardoz.vala || exit 99
-- 
2.34.1