Subject: bug#70557: closed (Re: bug#70557: Fix compilation of Vala files conditionally added to _SOURCES)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 06 May 2024 15:18:02 +0000

Your bug report

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

which was filed against the automake package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
70557: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70557
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#70557: Fix compilation of Vala files conditionally added to _SOURCES
From: Karl Berry <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 6 May 2024 09:17:01 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for the Vala doc patch, Reuben. Installed and closing. --best, karl.

Subject: Fix compilation of Vala files conditionally added to _SOURCES
From: Reuben Thomas <[email-masked]>
To: bug-automake <[email-masked]>
Date: Wed, 24 Apr 2024 22:57:17 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

I attach two patches. The first is a trivial documentation fix. The second
fixes a bug I ran into recently with Vala compilation.

I just needed to add some Vala source files to my program that are added to
the relevant _SOURCES variable conditionally:

if OS_WIN32
libenchant_la_SOURCES += api-windows.vala
else
libenchant_la_SOURCES += api-posix.vala
endif

(Motivation: the reason I have to add the files conditionally is two-fold:
first, api-windows.vala and api-posix.vala call APIs that are only
available on Windows and POSIX systems respectively. In itself, this does
not require conditional inclusion; I can use Vala preprocessor directives,
just as I would in C. But the Vala compiler generates C files, and I want
the user of my package not to need a Vala compiler. Therefore, the
generated C code must be independent of build-time configuration. Since the
Vala compiler does not generate C preprocessor directives, I have to do
conditional inclusion at build time some other way. So, I am doing it by
using automake conditionals.)

With current automake, something like the following Makefile line is
generated:

$(builddir)/libenchant_la_vala.stamp: api-windows.vala api-posix.vala…

With my patch, the following line is generated instead:

$(builddir)/libenchant_la_vala.stamp: $(libenchant_la_SOURCES)

Of course, $(libenchant_la_SOURCES) expands to the actual sources.

The patch is trivial, so hopefully it's obvious if there's a problem for
some reason! I hope I explained well enough what problem I'm trying to
solve.

-- 
https://rrt.sc3d.org
From 490777db71c2086cfbd3ec359fceca5fc853047d Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Wed, 24 Apr 2024 22:41:48 +0200
Subject: [PATCH 2/2] vala: do not build Vala sources excluded by automake
 conditionals
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* bin/automake.in: make the _vala.stamp file depend on the relevant _SOURCES
variable’s value, not the fully-expanded list of all possible sources. This
means that source files added conditionally to a _SOURCES variable will only
be added when the condition is true.
---
 bin/automake.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/automake.in b/bin/automake.in
index 112730269..95129c294 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -5887,7 +5887,7 @@ sub lang_vala_finish_target
   my $stampfile = "\$(builddir)/${derived}_vala.stamp";
 
   $output_rules .=
-    "\$(builddir)/${derived}_vala.stamp: @vala_sources\n".
+    "\$(builddir)/${derived}_vala.stamp: \$(${derived}_SOURCES)\n".
 # Since the C files generated from the vala sources depend on the
 # ${derived}_vala.stamp file, we must ensure its timestamp is older than
 # those of the C files generated by the valac invocation below (this is
-- 
2.34.1

From 32ad6da2af34725cbb771e8f3824370cd15a0540 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Wed, 24 Apr 2024 22:41:12 +0200
Subject: [PATCH 1/2] doc: add missing close parenthesis in comment.

* bin/automake.in: add missing close parenthesis.
---
 bin/automake.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/automake.in b/bin/automake.in
index 1dc40a00b..112730269 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -5809,7 +5809,7 @@ sub lang_vala_finish_target
           #
           # The -newer test here is checking "C file not older than Vala
           # file" (not "C file newer than Vala file"; see
-          # https://bugs.gnu.org/44772. The log message on the commit
+          # https://bugs.gnu.org/44772 ). The log message on the commit
           # misleadingly says "reversed".
           #
           $output_rules .= "$built_c_file: \$(builddir)/${derived}_vala.stamp\n"
-- 
2.34.1