A test in each subdir, but a web of dependencies between them #11847
-
I am writing unit tests for an ESP-IDF project, and I'm doing so with Clang for the C/C++ compilation. I'm not confident that I can put my separate chunks of code in a "subprojects" folder (I think it has to be in a folder called "components"). Therefore, as far as meson is concerned, I may be stuck with using a "subdir" paradigm instead of a "subproject" paradigm. Ideally, I'd like to set up my structure like this:
I'd also like to set up each of my module's meson.build files where they simply declare a test as well as a dependency for if other modules need this module, in which case the real headers and fake source will be pointed to. So nearly each module will have one "test()" and one "declare_dependency()" in its meson.build, however the dependencies for its test will likely be dependencies from other modules. Also note, I can't compile all of these modules into the same test executable because of link-time substitutions that must be made to shim fakes for other modules. So is this sort of thing possible? I figured in the main meson.build file I could start with a "subdir()" line including the sub-directories, but what if it encounters a module that requires a dependency that hasn't been encountered yet? Or instead can I do something fancy where I reference one module from another module with a path of "../other_module" then I getVariable() from that meson.build file? Or could I have each sub-directory start with its own "subdir()" lines to point to the other subdirs? I feel like that last one could end up in a loop... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
See https://mesonbuild.com/Reference-manual_functions.html#project_subproject_dir for how to override the default "subprojects" directory to something else. Intended for compatibility with existing codebases that expect a specific location already. Aside for that, Without using subprojects, it would still be relatively simple enough to manually resolve order and then shift up/down different subdir() lines until components are included in the correct order, but it would have to be manually maintained which I guess could be annoying. But renaming the default subprojects directory should work, I think. |
Beta Was this translation helpful? Give feedback.
See https://mesonbuild.com/Reference-manual_functions.html#project_subproject_dir for how to override the default "subprojects" directory to something else. Intended for compatibility with existing codebases that expect a specific location already.
Aside for that,
subdir()
cannot include backtracking, that is, ../ path segments, and can only be done once per subdir. So the loop issue won't come up. :)Without using subprojects, it would still be relatively simple enough to manually resolve order and then shift up/down different subdir() lines until components are included in the correct order, but it would have to be manually maintained which I guess could be annoying. But renaming the de…