Re: meson: Allow disabling static libraries - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: meson: Allow disabling static libraries
Date
Msg-id ca252267-dae0-402c-b44c-030e6ee812b0@eisentraut.org
Whole thread Raw
In response to Re: meson: Allow disabling static libraries  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On 20.01.26 18:03, Andres Freund wrote:
>>   ###############################################################
>> @@ -3499,18 +3513,20 @@ endif
>>   installed_targets = [
>>     backend_targets,
>>     bin_targets,
>> -  libpq_st,
>>     pl_targets,
>>     contrib_targets,
>>     nls_mo_targets,
>>     ecpg_targets,
>>   ]
>> +if dep_static_lib.found()
>> +  installed_targets += [libpq_st]
>> +endif
> 
> Wonder if we ought to define installed_targets = [] earlier and allow
> different meson.build files to add themselves, instead of putting knowledge
> like this into a central spot.

Right.  See attached patch 0001.  This introduces a variable 
libpq_targets and populates it in the subdirectories.  This moves the 
knowledge away from the top-level meson.build.

> Separately, perhaps it'd be mildly nicer to have a boolean for static libs
> instead of using .found() everywhere.

Yeah, after playing with this a bit more, I'm not sure sure this 
disabler trick is really that good.  The idea would have been that you 
just need to add the disabler to the dependencies and everything else 
will magically work.  But the reason that you need stuff like

+if dep_static_lib.found()
+  installed_targets += [libpq_st]
+endif

is that the disabler sneaks up into other variables and dependencies and 
has weird effects.  For example, if you remove "if" around this and 
similar lines, then "meson test" breaks in highly confusing ways 
(probably because tmp_install depends on installed_targets).

So I think, since we have to have these conditionals, we might as well 
put them around the whole static_library() call.  And then we can use a 
straightforward Boolean variable, like you suggest.  See attached patch 
0003 (which is on top of 0002, so it would make more sense to view the 
diff 0001..0003).

This is also more robust because you get explicit errors for example if 
you use libpq_st or libpq_so when they are disabled, instead of 
sometimes silently doing nothing.


Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: display hot standby state in psql prompt
Next
From: vignesh C
Date:
Subject: Re: Skipping schema changes in publication