Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't concatenate strings in cross-platform config #3878

Open
Hi-Angel opened this issue Jul 12, 2018 · 9 comments
Open

Can't concatenate strings in cross-platform config #3878

Hi-Angel opened this issue Jul 12, 2018 · 9 comments

Comments

@Hi-Angel
Copy link
Contributor

Steps to reproduce:

$ cat cross-compile.ini 
[binaries]
prefix = '/usr/bin/' 
cpp = prefix + 'i686-w64-mingw32-g++'
ar  = prefix + 'i686-w64-mingw32-g++'

[host_machine]
system = 'windows'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
$ touch meson.build
$ meson cross-build --cross-file cross-compile.ini

ERROR: Malformed value in cross file variable cpp.

A full log can be found at /home/constantine/Projects/meson-test/cross-build/meson-logs/meson-log.txt

The complaint means it can't concatenate prefix with 'i686-w64-mingw32-g++' in definition of cpp. Interestingly the following line of code:

cpp = '/usr/bin/' + 'i686-w64-mingw32-g++'

works fine.

meson version 0.47.0

@nirbheek
Copy link
Member

nirbheek commented Aug 7, 2018

The file format is ini-like, so it does not support the + operator. This is a good idea though, maybe we should implement it. What do you think @jpakkane?

@QuLogic
Copy link
Member

QuLogic commented Aug 7, 2018

There are ways to do interpolation on ini-like files.

@jpakkane
Copy link
Member

jpakkane commented Aug 8, 2018

The fact that interpolation works at all is a side effect of how I implemented it back when (I was lazy). For cross files I really prefer the explicitness of just writing it out. Cross files are written once and rarely change. The issue would be different if they were constantly in flux. But they're not.

@NickeZ
Copy link
Contributor

NickeZ commented Aug 8, 2018

It is supported in pkg-config with ${macro} syntax.

See section "Metadata File Syntax" in https://linux.die.net/man/1/pkg-config

@jpakkane
Copy link
Member

jpakkane commented Aug 8, 2018

No dollar sign variable expansions. Ever! Under any circumstances!

@NickeZ
Copy link
Contributor

NickeZ commented Aug 8, 2018

So I looked in the sources and since ConfigParser is used and interpolation isn't overridden I think @QuLogic's solution should work today (unless I missed something):

[binaries]
prefix = '/usr/bin/' 
cpp = '%(prefix)s/i686-w64-mingw32-g++'
ar  = '%(prefix)s/i686-w64-mingw32-g++'

Default OptionParser is:

class configparser.ConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configparser.DEFAULTSECT, interpolation=BasicInterpolation(), converters={})

@chewi
Copy link

chewi commented Jan 14, 2019

Related to this and rather weird is the situation with arrays:

Documented but doesn't work:

c_args = ['-O1']
c_args += ['-g']

Not documented but does work!!

c_args = ['-O1'] + ['-g']

I have tested this on 0.49.0 and tried to test on git master but cross-compiling seems totally broken at the moment, like it's almost entirely ignoring the cross file.

@skrap
Copy link

skrap commented Sep 22, 2020

The documentation says to do exactly this:

# cross.ini
[binaries]
c = arch + '-gcc'

So I suspect the docs should either be fixed, or this issue should be addressed? Or am I wildly misunderstanding something?

@xclaesse
Copy link
Member

That works only when you pass both aarch64.ini (where arch is defined) and cross.ini.

shenki added a commit to shenki/culvert that referenced this issue May 2, 2022
mesonbuild/meson#3878

Fixes errors such as:

 ERROR: Malformed value in cross file variable c.

Remove the pkg-config cross binary, as distros don't ship that AFAICT.

Signed-off-by: Joel Stanley <[email protected]>
shenki added a commit to shenki/culvert that referenced this issue May 2, 2022
mesonbuild/meson#3878

Fixes errors such as:

 ERROR: Malformed value in cross file variable c.

Remove the pkg-config cross binary, as distros don't ship that AFAICT.

Signed-off-by: Joel Stanley <[email protected]>
shenki added a commit to shenki/culvert that referenced this issue May 2, 2022
mesonbuild/meson#3878

Fixes errors such as:

 ERROR: Malformed value in cross file variable c.

Remove the pkg-config cross binary, as distros don't ship that AFAICT.

Signed-off-by: Joel Stanley <[email protected]>
shenki added a commit to shenki/culvert that referenced this issue May 2, 2022
mesonbuild/meson#3878

Fixes errors such as:

 ERROR: Malformed value in cross file variable c.

Remove the pkg-config cross binary, as distros don't ship that AFAICT.

Signed-off-by: Joel Stanley <[email protected]>
npes87184 added a commit to npes87184/scrcpy that referenced this issue Oct 22, 2022
rom1v pushed a commit to Genymobile/scrcpy that referenced this issue Oct 23, 2022
This feature is not supported on older meson versions:

    ERROR: Malformed value in cross file variable prebuilt_libusb.

Refs <mesonbuild/meson#3878>
PR #3546 <#3546>

Signed-off-by: Yu-Chen Lin <[email protected]>
Signed-off-by: Romain Vimont <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants