[Buildroot] [PATCH 1/2] meson: add entry for libgcrypt-config in cross file

Arnout Vandecappelle arnout at mind.be
Fri May 24 08:18:11 UTC 2019



On 24/05/2019 00:51, Jörg Krause wrote:
> Hi all,
> 
> thank you all for your ideas. Please take a look at my proposal
> below...
> 
> On Thu, 2019-05-02 at 14:17 +0200, Arnout Vandecappelle wrote:
>>
>> On 01/05/2019 21:04, Peter Seiderer wrote:
>>> Hello Arnout,
>>>
>>> On Wed, 1 May 2019 13:13:03 +0200, Arnout Vandecappelle <arnout at mind.be> wrote:
>>>
>>>> On 30/04/2019 13:04, Jörg Krause wrote:
>>>>> Hello Peter,
>>>>>
>>>>> On Tue, 2019-04-30 at 10:27 +0200, Peter Seiderer wrote:  
>>>> [snip]
>>>>>> Would have expected the trick/non-trivial thing to add more than one
>>>>>> binary entry (to get the newlines for the entries right)...  
>>>>>
>>>>> That's indeed a difficult case to solve. I didn't managed to get
>>>>> multpile binary entries added to the [binaries] field, e.g.
>>>>>
>>>>> PKG_TARGET_BINARIES = \
>>>>> 	libgcrypt-config = '...' \
>>>>> 	llvm-config = '...'
>>>>>
>>>>> .. will not work.
>>>>>
>>>>> I spent some time to find a magic rule which splits the Makefile
>>>>> variable into a proper newline seperated string which can be used by
>>>>> sed, but I failed.
>>>>>
>>>>> Maybe you have an idea?  
>>>>
>>>>  Instead of sed, use the PRINTF macro and append to the file:
>>>>
>>>> 	$Q$$(if $$($$(PKG)_TARGET_BINARIES),\
>>>> 		$$(call PRINTF,$$($$(PKG)_TARGET_BINARIES)) \
>>>> 		>> $$($$(PKG)_SRCDIR)/build/cross-compilation.conf  
>>>
>>> Simple appending will not work, the extra binaries must be under the '[binaries]'
>>> section (maybe reordering the sections in the cross-compilation.conf.in template
>>> will work)
>>
>>  It should work if the [binaries] part is at the end, right? And if binaries is
>> empty, that's OK, no?
>>
>>  Alternatively, the [binaries] part could be included in the _TARGET_BINARIES
>> (which would then have to be renamed to _CROSS_COMPILATION_CONF). So for a
>> package that needs libgcrypt-config, it would be
>>
>> define FOO_CROSS_COMPILATION_CONF
>> [binaries]
>> libgcrypt-config = '$(STAGING_DIR)/usr/bin/libgcrypt-config'
>> endef

 Is there any reason why this proposal doesn't work? AFAIU, it should be no
problem to repeat the '[binaries]' part several times, right?

 I'm insisting on this since I expect that we'll need to override something else
at some point as well.

>>> , does the printf approach fix the newline problem for more than one
>>> entry?
>>
>>  It does, but you can't use _CROSS_COMPILATION_CONF = ..., you have to use
>> define, because the actual newlines have to be in the variable itself. Actually,
>> you can still use = assignment, but then you need to use $(sep), i.e.:
>>
>> FOO_CROSS_COMPILATION_CONF = [binaries]$(sep)libgcrypt-config =
>> '$(STAGING_DIR)/usr/bin/libgcrypt-config'$(sep)
>>
>> (which is ugly so don't do that :-)
> 
> The package using the meson infrastructure defines:
> 
>    define libfoo_MESON_CROSS_CONF_BINARIES
>    libgcrypt-config = '$(STAGING_DIR)/usr/bin/libgcrypt-config'
>    llvm-config = '$(STAGING_DIR)/usr/bin/llvm-config'
>    endef
> 
> pkg-meson.mk is using PRINTF to a temporary file and sed is using this
> file as input for appending to the [binaries section]:
> 
>    $Q$$(if $$($$(PKG)_MESON_CROSS_CONF_BINARIES), \
>    	$$(call PRINTF,$$($$(PKG)_MESON_CROSS_CONF_BINARIES))) \
>    	> $$($$(PKG)_SRCDIR)/build/cross-binaries.tmp
>    sed -i "s/^[ \t]*//" $$($$(PKG)_SRCDIR)/build/cross-binaries.tmp

 I would rather have the PRINTF macro to be fixed not to insert these tabs. It's
just an artefact of how make works, and can be fairly easily fixed, either by
reordering the newlines in the PRINTF definition, or by putting a $(strip)
around it (although the latter has potential side effect since it also replaces
all internal whitespace with a single space).


>    sed -e "s%@TARGET_CROSS@%$$(TARGET_CROSS)%g" \
>        ...
>        -e  "/\[binaries\]/r $$($$(PKG)_SRCDIR)/build/cross-binaries.tmp" \

 Not many people understand the r command which makes this hard to read, but
it's acceptable for me.

>        package/meson/cross-compilation.conf.in \
>        > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
>    rm -f $$($$(PKG)_SRCDIR)/build/cross-binaries.tmp


 Maybe, however, we should drop the cross-compilation.conf.in and generate
everything with PRINTF (assuming that PRINTF gets fixed first, of course):

define meson_cross_compilation_conf_template
# Note: Buildroot's and Meson's terminologies differ about the meaning
# of 'build', 'host' and 'target':
# - Buildroot's 'host' is Meson's 'build'
# - Buildroot's 'target' is Meson's 'host'

[binaries]
c = '$(TARGET_CROSS)gcc'
cpp = '$(TARGET_CROSS)g++'
ar = '$(TARGET_CROSS)ar'
strip = '$(TARGET_CROSS)strip'
pkgconfig = '$(HOST_DIR)/usr/bin/pkg-config'
$($(PKG)_MESON_CROSS_CONF_BINARIES)

[properties]
needs_exe_wrapper = true
...
endef


	$(call PRINTF,$(meson_cross_compilation_conf_template)) \
		> $$($$(PKG)_SRCDIR)/build/cross-compilation.conf


(Note: even with the above, I would prefer to have a $($(PKG)_MESON_CROSS_CONF)
that gets appended at the end and that has the [binaries] embedded in it; the
above is assuming that that doesn't work for some reason.)


 Regards,
 Arnout


More information about the buildroot mailing list