bug-gnulib
[Top][All Lists]
Advanced

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

Re: maint.mk: improve the release procedure


From: Jim Meyering
Subject: Re: maint.mk: improve the release procedure
Date: Sun, 23 Sep 2012 16:19:21 +0200

Akim Demaille wrote:
> Le 22 sept. 2012 à 17:02, Jim Meyering a écrit :
>
>> How about something like this?
>>
>> release-type =                                                               
>> \
>>  $(subst :, ,                                                                
>> \
>>    $(if $(RELEASE_TYPE),                                             \
>>      $(or $(findstring :$(RELEASE_TYPE):,:alpha:beta:stable:),               
>> \
>>       $(error invalid RELEASE_TYPE: $(RELEASE_TYPE))),               \
>>      $(error RELEASE_TYPE undefined)))
>>
>> That's not quite right because it fails to reject RELEASE_TYPE=alpha:beta.
>> Adding one more "if" just for that case should do the job:
>>
>> release-type =                                                               
>> \
>>  $(subst :, ,                                                                
>> \
>>    $(if $(RELEASE_TYPE),                                             \
>>      $(if $(findstring :,$(RELEASE_TYPE)),                           \
>>      $(error invalid RELEASE_TYPE: $(RELEASE_TYPE)),                 \
>>      $(or $(findstring :$(RELEASE_TYPE):,:alpha:beta:stable:),       \
>>        $(error invalid RELEASE_TYPE: $(RELEASE_TYPE)))),             \
>>      $(error RELEASE_TYPE undefined)))
>
> Nice!  Further improvement: use " " instead of
> ":" as separator, as it is a more natural separator in Make,
> which removes the need to add and strip these ":", and you
> get something which is more generic:
>
> _null := # Null character.
> _sp := $(_null) # White space.
>
> RELEASE_TYPES = alpha beta stable
>
> # member-check VARIABLE,VALID-VALUES
> member-check =                                                        \
>   $(if $($(1)),                                                       \
>     $(if $(findstring $(_sp),$($(1))),                                \
>         $(error invalid $(1): '$($(1))', expected $(2)),      \
>         $(or $(findstring $(_sp)$($(1))$(_sp),$(_sp)$(2)(_sp)),       \
>           $(error invalid $(1): '$($(1))', expected $(2)))),  \
>     $(error $(1) undefined))
>
> $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES))

I like the function.
For this application, where no valid value contains a space, your use of
SPACE as a delimiter is fine.  However, in general you might want to use
a byte that is less likely to be included in one of the expected values.

> I couldn't find a means to factor elegantly the checks to
> have a single $(error invalid $(1)).

I tried too.  Oh well.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]