Replies: 2 comments 2 replies
-
In the wrapdb we don't worry about this, but simply overlay our own meson.build files on top of the upstream tarball. I am not sure I understand why it is specifically necessary to maintain the files in a different source tree.
(This much seems to apply regardless of whether you have a separate root for your meson.build files, but) I think I better understand the desire to reference files relative to the project source root. The main issue is that of active and sustained development, in which changing filepaths a lot can be a bit confusing especially in the logs but also to get correct. The zstd project has an... interesting... solution to this. Every meson.build file has a header variable: zstd_rootdir = '../../..' And then all filepaths are created relative to that variable. The main purpose of this is actually so that they can refer to files outside of the meson/ directory (which has an out of tree build system just like you are using) while being consistent with the wrapdb overlay that adds a top-level meson.build file. They don't really do much refactoring. But this does allow consolidating references so that you only need to refactor them once per file and it's fairly easy to do so in a semi-automated fashion. And it works in all versions of meson, as far as I know. |
Beta Was this translation helpful? Give feedback.
-
The "correct" way of doing this is to have at the top level something like:
and then
And then finally you can do
|
Beta Was this translation helpful? Give feedback.
-
I was tripped up by this recent commit: Fix include_directories test for relative path
I had been arranging the build files under a directory tree that's separate from the source directories and not necessarily matching the source tree directory structure one-to-one, a bit like this -
The
mesonbuild/
tree is a little fluid/changeable and doesn't want to exactly mirror the source tree, mostly because generating nice Visual Studio solution and .vcxprojs often benefits from creating more subdirectory source groupings in the generated .vcxproj.filters (called filters in VS terminology) and, as far as I can tell, the only way to explicitly dictate the filter groups/folders in a generated .vcxproj is through the liberal use of more 'subdir(...)' in the meson.build files. In the above example,mesonbuild/subA/meson.build
referencesa0.cpp
anda1.cpp
sources, but also usessubdir('anotherSub')
, wheremesonbuild/subA/anotherSub/meson.build
references thea2.cpp
source file, and finally a target pulls all 3 sources together ... but the generated project now listsa0.cpp
anda1.cpp
together, alongside aanotherSub
filter folder, which containsa2.cpp
, making preferred source file grouping in the VS proj.It's nice to be able to do this kind of meson build structure separate from source directory and with a different tree structure to the source tree so that we can add a little nicer structure/grouping to the generated .vcxproj, all without having to barge in to someone else's project and upset things with what would be a difficut and probably contentious restructuring of their existing source tree structure.
Because of all of this, and also because I expected to move and restructure targets to make use of more subdir/filter source groups, it seemed reasonable to be able to reference all source files in any
meson.build
file relative to an absolute source route path. E.g. inmesonbuild/meson.build
-Then, no matter where in the subdir tree any
meson.build
lives or wherever I may choose to move/shuffle any subdirectories, all sorce files are referenced in the same fixed way. E.g. -which avoids the need to fix up all source references if/when the meson build structure changes. I.e. I don't have to go from
mesonbuild/subA/meson.build
using -to using -
when moving
a2.cpp
into a newanotherSub
filter group.Finally to the issue -
Consistent use of
src_root_dir
now makes everything's nice and stable, easy to read, and resitant to jiggling around meson build sub directories, and so it's also nice to keep consistent use of this withinclude_directories
too. E.g.Prior to the commit mentioned at the start, this would all work fine. After the commit, I'm now told -
This seems to be a cosmetic (as opposed to functional) error message; without this check, the build will proceed just fine. I suspect the intention is to encourage a good practice of making everything tolerant to relocating the entire source and build directories to a different drive/directory. Is there any other rationale for this check?
If that's all it's for, then it feels flawed and overenthusiastic in my case, which happens to end up using absolute paths but only by way of relative paths to some root, which is itself essentially relative to the top-level meson.build.
I don't see anything wrong with my use of absolute include paths but to work around this new obstacle, I obviously could go and make all relevant include paths relative (breaking from the nice consistency of the
src_root_dir / ...
pattern and now making their use prone to failure under future relocation). Or I could appease this check through use offs.relative_to(...)
. For theinc_dirs
case above -but that seems horrible.
Have I missed something important in constructing my include dirs the way I've described; relative to a common absolute (but still dynamic, mesonbuild-relative) root path, which this check is trying (but failing) to make me aware of? If so, what is it and could the error message be improved?
If not (if I have understood the issues that it's trying to tell me about) and the check is overly simplistic in case like this, should the check remain as is, could it be refined, could it be suppressed through an option that conveys "I know meson is trying to help but I'm happy with absolute include paths so don't bug me about their use", should it be disabled on grounds of blocking some number of non-problematic builds, or do you think it's still probably better existing as it is, even with some unfortunate false positives that might make users have to jump through a little more hoops than ideal?
Beta Was this translation helpful? Give feedback.
All reactions