Does meson has a general function to print out any type variables's value?
Asked Answered
M

3

12

I've encountered some projects which uses meson to organize their building system. But when I want to debug their building system, I found it's difficult. The most important task is observing the building system's variable during its running. I could use message() function to show the variables of types, e.g.

integer
string
lists (of string/integer/lists)

But if the variable is dictionary type, the message() will refuse to display any information in the variable.

Does meson have a general function to display any type's variable just like python's print() function? If not, do we have any solution to do this?

Thanks in advance.

Mutilate answered 10/3, 2021 at 6:55 Comment(5)
It's painful to learn and try those new building systems, since they are designed by different engieers and have different style, So this kind of general solutions could help us saving time and accelerate our working process. Unfortunately, they don't always exist.Mutilate
Did you solve this problem?Britska
@ElvisOric no. But it seems we could print out any types variable just like what python could do. So maybe, we could answer this question as: No. Let's still wait for a little longer time for some real expert from meson building system to come provide solid answer.Mutilate
What build system support this kind of stuff? I tried with dictionary type and message print the value.Britska
@ElvisOric I could use $(info ) function in makefile to output value of variables, but because meson is a newer building system which I'm not familiar, so I wish it could support python style print() function then it could be very easy for use to debug and learnMutilate
B
5

It is probably hard for the maintainers of meson to print out every object that is available in the meson.build script.

deps = []

# add some dependencies to the deps list or obtain the deps elsewhere

message('the depencies are: ')
foreach dep : deps
    message(' - ', dep.name())
endforeach

For me this results in:

Message: the depencies are: 
Message:  -  glib-2.0
Message:  -  gobject-2.0
Message:  -  gtk4
Message:  -  epoxy

You can't print/message a dependency, but you can print the name of the dependency :-)

Brainwash answered 12/7, 2023 at 13:5 Comment(0)
A
1

You can print any object with:

message('@0@'.format(f))

Source: https://github.com/mesonbuild/meson/issues/9575#issuecomment-969053569

Aideaidedecamp answered 2/6 at 22:36 Comment(0)
E
0

Maybe this function will help you and This function prints its argument to stdout

void message(text,more_text,...)

Eagan answered 16/6, 2022 at 8:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.