Meson: Detect when people try to run meson from a subdir in the source tree and print a friendly error

Created on 18 Apr 2018  路  4Comments  路  Source: mesonbuild/meson

I think it's hard to understand what "First statement must be a call to project" means. I question if the sentence is proper English, but I'm not a native speaker, so it would be nice if someone could confirm this.

Whom are you calling upon to project something, and what will you project? Or, if it's not in the context of calling upon someone or projecting something, which function are you calling? project is not a function and it's not obvious how project should be called.

Could the error message be reworded?

enhancement good first issue help wanted parseinterpreter

Most helpful comment

I was trying to compile just swaybar which is part of the Sway window manager.

Being new to Meson, I naively checked out the sway sources, entered the swaybar directory, typed in meson build and got:

ERROR: First statement must be a call to project

In the context of the commandline, there is no project function immediately available, so this was incomprehensible, to me.

I believe the real problem was that I needed to build the entire project (cd ..; meson build; ninja -C build) and not anything that had to do with the project function.

This issue may mainly be with me, since I'm new to meson, but perhaps another error message for this situation could also be helpful for others. Consider it a feature request in the pile of feature requests.

Thanks for developing meson, appart from the above issue I think it looks really promising and I believe it's an "up and coming" build system.

All 4 comments

project is not a function and it's not obvious how project should be called.

I don't understand what you mean. project is a function: http://mesonbuild.com/Reference-manual.html#project

We should definitely make the error message clearer though. Perhaps we should point to that link.

I was trying to compile just swaybar which is part of the Sway window manager.

Being new to Meson, I naively checked out the sway sources, entered the swaybar directory, typed in meson build and got:

ERROR: First statement must be a call to project

In the context of the commandline, there is no project function immediately available, so this was incomprehensible, to me.

I believe the real problem was that I needed to build the entire project (cd ..; meson build; ninja -C build) and not anything that had to do with the project function.

This issue may mainly be with me, since I'm new to meson, but perhaps another error message for this situation could also be helpful for others. Consider it a feature request in the pile of feature requests.

Thanks for developing meson, appart from the above issue I think it looks really promising and I believe it's an "up and coming" build system.

Can't we do like git an walk the directories upwards until we find a meson.build file with project in it?

Yes, that's what I was thinking too. We probably want to look upwards till we find a directory without a meson.build, and the previous dir was probably the source root. Then we tell the user to run meson from that directory.

In some cases there will indeed not be a meson.build with project() anywhere in the parent directories (f.ex., for git submodules that are dropped in as subdirs and not subprojects), and in that case a more useful error message than use project() would be appropriate.

Was this page helpful?
1 / 5 - 1 ratings