As mentioned in the title, with "meson" I generally create an out-of-tree build directory where "meson -C /path/to/build/directory setup" is run, then "samu -C /path/to/build/directory" is run, followed by "samu -C /path/to/build/directory install", but with "muon" I am able to run "muon -C /path/to/build/directory setup" but running "samu" next does not work as it does not see meson_options.txt? Also why do we have to use "muon -C /path/to/build/directory install" to install something instead of "samu"?
using the latest muon git revision, this doesn't work:
# muon -C builddir setup err missing operand
meson 1.0.1
# meson -C builddir setup usage: meson [-h] {setup,configure,dist,install,introspect,init,test,wrap,subprojects,rewrite,compile,devenv,env2mfile,help} ... meson: error: unrecognized arguments: -C
This is an issue I had months ago, extremely confusing how to use meson & muon, but now both work with the same setup command:
# muon setup [options] builddir # meson setup [options] builddir
I found that older versions than meson 1.0 make everything harder and confusing. Of course muon should improve add support for
-C DIR
after command, that single change would make the world a happier place
muon expects to be run inside the source directory, and accept the build directory as an argument. Meson supports that as well, but also supports specifying both as arguments.
with "meson" I generally create an out-of-tree build directory where "meson -C /path/to/build/directory setup" is run
This doesn't sound like meson's officially supported workflow?
"muon -C builddir setup" works whether builddir is in tree or out of tree, but "samu -C builddir" only works in tree.
This is not an issue with "samu" because when using "meson", samu just works fine and in and out of tree.
I'm not sure what this mean? samu doesn't know anything about the tree at all -- and it works the same with both meson and muon.
That is, samu must be run from the builddir or run with the -C argument.
The -C argument, where supported, has the following semantic:
It makes the program being run behave as though, before running the program, you had used the shell command
cd
to change directories.That's what it means with GNU make, that's what it means with samu, and that's what it means with muon.
Meson doesn't support a -C argument for
meson setup
.
I apologize if I didn't make myself clear.
I am not asking whether muon/meson are run from within the source directory or not. I understand that you have to be inside the source directory to run muon/meson.
But what I don't understand is why should the build directory be inside the source directory as well?
Why does this work with meson:
cd source_dir meson setup ../build_dir samu -C ../build_dir samu -C ../build_dir install
and this does not work with muon?
cd source_dir muon setup ../build_dir samu -C ../build_dir // samu fails due to missing meson_options.txt or other files
Also why should I install with "muon -C ../build_dir install" when using muon, instead of running "samu -C ../build_dir install" like meson?
Oh, I see what you mean. This is a bug. In
src/backend/common_args.c
the function relativize_paths tries to relativize paths written to build.ninja, relative to the build.ninja directory.This hands off to
src/platform/path.c
, given a build_root and the abspath of meson_options.txt, and path_relative_to() returns a broken value.* input: base="/path/to/build" * path="/path/to/src/asd.c" * output: "../src/asd.c"
This much is true, but when base (the build_root) has a ".." in it, because the argument to
muon setup
used relative paths of the form ../build_dir rather than absolute paths of the form$(realpath ../build_dir)
...... then path_relative_to fails.
This issue should be fixed in 34953adc.
As to why you need to use
muon -C ../build_dir install
, this is because muon does not create a build target named install to run this command for you. When using meson, allsamu -C ../build_dir install
does is runmeson install -C ../build_dir
for you. In general, it is better to run the command yourself since you then can pass arguments, so I omitted the shorthand version from muon. There is also the worry of accidentally running samu with superuser privileges causing it to corrupt the build directory.
Thanks for your input on this.
I can confirm this only happens when using a relative path "../build_dir" or when using an absolute path with relative elements "$PWD/../build_dir" (as if path resolution is not getting picked up?)..
It works fine when I specify "/some/path/to/build_dir" with no relative elements whatsoever.
~firasuke, did you test the latest master? It should now work even with .. in the path.
I can confirm that relative paths are now working. I even tried the bootstrap script with relative paths, and it worked as expected in all trials.
Keep up the great work!