-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configure_file, custom_target and generator output file to subdirectories under builddir #2320
Comments
I think I have a similar case: https://stackoverflow.com/questions/46729488/how-to-compile-aidl-files-using-meson I need these source files:
to be compiled under:
From the java compiler point of view, this is an error for a java file not be in a directory matching the package name. |
#2548 is possible way to fix this type of issue. if one project call configure_file() with install_dir, install_headers(), and so on. copy these header files to a include_intermediates_dir, and all compile target include this intermediate directory. |
@nirbheek
And it worked surprisingly well. But I'm afraid by doing this I may be breaking something else inside meson. Could you please give me some explanation about this limitation and let me know your thought about its removal (or replacement with something like |
Just to mention that I recently (#3023) also found it a little awkward that In my case it's possible to work around the limitation by creating a I wonder if the subdirectory were limited to matching the subdirectory of the input filename that might appease some of the general concern around having random control over the build directory layout. This would still allow meson control to change the top level structure of the build directory but it would have to preserve the subdirectories requested for an output file. E.g. if I want to generate a
And in the build directory meson can create: The top level layout doesn't really matter (at least in my case) so long as the java compiler + ninja backends knows what it is. So it might not imply spaghetti access to arbitrary build directories, just some control to build a sub-heirachy within the build directory. |
Also ran into this problem with custom_target and doxygen. The call to doxygen will produce the html files needed and the latex sources needed. Doxygen also produces a Makefile that helps you run pdflatex the right amount of times and in the right order. I would like to write something like this: cdata = configuration_data()
cdata.set('TOP_SRCDIR', meson.source_root())
cdata.set('TOP_BUILDDIR', meson.build_root())
cdata.set('VERSION', meson.project_version())
doxyfile = configure_file(
input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: cdata,
install: false
)
html_target = custom_target(
'htmldocs',
build_by_default: false,
input: doxyfile,
output: ['html/index.html', 'latex/Makefile'],
command: [doxygen, doxyfile],
)
pdf_target = custom_target(
'pdfdocs',
build_by_default: false,
input: 'latex/Makefile',
output: 'latex/refman.pdf',
command: [make, '-C', '@OUTDIR@/latex'],
)
|
I also ran into this problem and currently don't know how to work around it. This usually works like this: You generate something like a IP-variation file, which is some kind of XML format, good for versioning and then you run a IP-generator on this file and get a bunch of output files. Example output files for generating the IP
So i tried to put this into a cutom target like so: qsys = find_program('qsys-generate')
python = import('python').find_installation('python')
files = run_command(
python, 'cat.py', files('ip/cms_sys_pll.outputs'),
).stdout().strip().split('\n')
custom_target('cms_sys_pll',
build_by_default: true,
output: files,
input: 'ip/cms_sys_pll/cms_sys_pll.qsys',
command: [
qsys,
'--output-directory=@OUTDIR@/cms_sys_pll',
'--synthesis=VHDL',
'--simulation=VERILOG',
'@INPUT@']
) And of course i ran into the error:
Do you have any suggestions to work around this issue? |
Well personally I decided to give up meson and went back to the good old CMake because of this one. And I find modern style CMake comfortable enough I stopped looking for another build system generator. |
Hi @jasonszang, thanks for your answer. I see this issue was first posted by you. If you don't mind i would like to ask you if you have experience with CMake and let's say "custom toolchains"? |
The question here is does the file really need to be in a |
Yeah, you're right, that is a mistake in my build file. I can give the tool any directory, so |
@jasonszang I have the same frustration. One way to work around it is that you create a sub meson.buil in the subdir and do the remaining thing there. Then subdir the newly created meson.build. Not optimal but i think it works |
gir-to-d also generates subdirectories, like
Why is this ridiculous limitation still present? >_< UPD: seems like there are workarounds in gir-to-d for this |
Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. [1] mesonbuild/meson#2320
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Meson doesn't allow putting the generated header in a subdir of the builddir without jumping through hoops. See mesonbuild/meson#2320 for more details. So we move the header to the top level build dir and adjust some include paths.
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] mesonbuild/meson#2320 Fixes T8168 Differential Revision: https://phab.enlightenment.org/D9717
@jpakkane if there's consensus that this is a good idea to explore / implement with the restrictions mentioned, I can take a stab at it. But I need to know that it clears the design hurdle first... |
I think that'd be useful for custom targets that generate many files, e.g. some types of documentation generators. You can kind of do that today, but it doesn't work quite right everywhere today.
It'd not make me entirely happy. If you have lots of small binaries for example, you might want to generate those in the directory corresponding to the source code, but without lots of redundant buildsystem code in each directory. The obvious way to implement that would be to have per-directory meson.build files that populate an array, and then higher up iterate over the array and generate the relevant targets. But the output-directory restriction doesn't allow that. Generating all the outputs in a top-level directory gets pretty messy, so also isn't really an option.
The thing is, that I agree with that, as a goal. It's just that there's tension between a) the 1:1 source/build mapping b) buildsystem code duplication c) not allowing user defined functions. I think something gotta give. Perhaps part of this concern could be addressed by allowing output into a subdir with a meson.build by having the subdir/meson.build doing something like |
That wouldn't help the case where the desired directory doesn't existing in the source tree (like the multilib setup). It would be nice to solve both the multilib issue and the subdir problem with the same mechanism, but if not, we can do them separately. |
Indeed, you can use
Right, this is currently not possible and while my proposal would allow it as long as the filelist isn't generated by populating the array via per-directory meson.build files (I honestly don't see the problem with hoisting the list up, or just using
I don't think that would really solve the concern, because you would not know what that additional thing would be. Moreover, would this allow you to create the output from anywhere? e.g. given a project with two subdirs "sub1" and "sub2", could I define a current_directory() and then have sub1 produce outputs in sub2 instead even though it isn't a parent but rather a sibling? (Even worse: what if it's a nephew? Or a granddaughter?) Sure, you could forbid it to be anything other than a direct parent but then you could also use my original suggestion and not use sentinel "I know what I'm doing" types. |
Hoisting the list up increases the likelihood of conflicts and also just leads to huge files. Using a different type of file that's then read with fs.read() doesn't really work, as there often are generated sources or such for a specific binary. It also leads to not having useful error messages and other such fun.
It'd at least be easier to search for...
Sure. It's probably going to rarely be useful, but at some point restricting things makes them more complicated without a gain in clarity. |
Let's assume for a moment here that we're talking about a build system that does restrict things, and we're discussing possibilities for compromising and loosening the restrictions a bit. If we do make that assumption, it seems plausible to say that 6 years of arguing "restricting things is pointless" and getting nowhere isn't going to change today because someone said "restricting things makes them more complicated without a gain in clarity". But figuring out a way to restrict things that meets the original design goal of the person who enforced a restriction, while still unlocking at least some use cases, feels useful and is, at a minimum, better than before. That's what I, personally, am interested in thinking about. |
I can't imagine why it "wouldn't work". If there are generated sources for a specific binary, those could be generated alongside the target handling, and offloading the filelist to a dedicated file will still serve the purpose of greatly reducing the complexity, just not totally reducing it. A strict win over the current state of affairs, I would say.
I'm baffled at why error messages would inherently become not useful as a result of this. In fact, I'm baffled at why error messages would lack usefulness at all. It's the same information either way. |
Sure, that's possible - but you end up with a lot of buildsystem code in a single file...
If I have a syntax error in meson.build, I am helpfully pointed at the specific line. If there's an error in a file read by fs.read(), that's not typically going to be the case. You're likely going to have to build a bit of parsing logic in meson (e.g. filtering out comment lines). Not impossible, but also not exactly optimal. |
I wasn't advocating dropping all restrictions in my comment - I was purely commenting on the parent vs sibling vs nephew aspect.
I agree. |
For lexer errors, yes. Anything else, e.g. invalid kwargs or disallowed values, we just point at the line containing the primary operation (usually the function call itself).
... and there we have it, I viewed the fs.read() thing as a way to build better lists of strings, not a way to offload a DSL and conditional logic to a new file. :D |
It can treat it like a file output, because if you write something in the subdir itself, the mtime of the directory changes to that value (I think on all platforms but not really sure). But it requires that whatever command generates the output writes something in the top level dir on incremental builds. Otherwise Ninja will run the target again next time. |
Upvoting this. Was trying to move away from cmake to meson, but eventually give up due to this. |
What is the exact thing that you needed to do but couldn't? |
I want a soft switch from cmake to meson. For our cmake build, we are using a Python script to convert things like |
For this specific case you can create a |
This workaround is not perfect, but sounds acceptable. Thanks for the suggestion! |
There's been several occasions where I've had to wrap my I've been porting the building of source rpms to building with meson. As you might know, source rpms have a structure of However with meson's custom_target, I'm forced to copy/flatten the generated directory structure's include files and libraries in to the directory where my meson.build's I guess this just reeks of a code smell -- but I'm getting convinced that it isn't in our meson.build files, but rather meson's design in this area. I like the restrictions that meson does in other areas as I think it helps you re-think your design and structure to make sure you do things correctly and cleanly. However, in respect of having to port third-party code generators and now rpmbuild... I think this restriction is actually a code-smell in meson instead. If we could just simply specify our outputs in the I like how meson tries to prevent you from having to 'hack' the build system to get it to work, but I think having to 'hack' rpmbuild and other tools to flatten out all their outputs to the calling custom_target directory is just as bad. I admit I may not be aware of a meson feature that allows me to do what I'm doing, so I'd love to hear suggestions of meson features that would let me work around having to copy around the output of building source rpms to be able to have those headers and libraries used as part of other build targets. As you can see from other comments in this thread, the restriction doesn't just apply to rpmbuild, but there are many other code generators and other external build tools that create outputs in a nice, clean subdirectory structure ready for user consumption. Meson should not be requiring that clean structure to be flattened or that directory structure to be pre-existing (so you can put meson.build files in them) in order to be consumed. |
My interest here is for code generators and external build tools that require structures as part of their design intrinsics, such as generated headers which must match the Producing a declare_dependency() which is interchangeable with the installed version is also important, mainly for external wraps where you cannot just arbitrarily re-order public headers into the common However I'm not certain I understand the case for rpmbuild. For rpmbuild, you should be invoking Lines 1 to 45 in 5e76e2a
|
I was unclear, I apologize. I was giving an example of using rpmbuild to build the source code of certain packages, not to use it to generate an rpm. By defining It was probably a bad example, but I'm finding more and more third-party tools that stage built libraries and headers in a directory structure. AFAIK, meson doesn't allow you to consume it without copying the files to either pre-existing folders, or to copy the files to the Am I mistaken? Do you know if there any plans to allow |
Meson does provide
I would like to allow it for the reasons, and using the approach, which I outlined in #2320 (comment) and which @jpakkane tweaked in #2320 (comment) I would like to know from @jpakkane if that is an acceptable approach and worth my investing time to implement it. |
Personally, I like what you have outlined in #2320 (comment) much better. It is more intuitive. People on this thread are already naturally looking to add paths to the Having another argument like That is my opinion though, and I respect your decisions as you are the ones maintaining and know better the side-effects of all this. I wouldn't mind putting in some skin in the game and helping implement the addition. |
Here is another scenario where I think I need paths in the
This command will generate 1536 files. I need to compile the following generated files out of these 1536:
How do I pass these files as sources to a |
Here is my workaround for this issue that generates GTK C++ bindings. It isn't lovely. It involves copying the generated source files into one directory, generating a dummy header file, and using directories as an output of |
I've encountered two cases that would require configurating / generating file into subdirectories.
Say I have a library project named foo and the project layout is like this:
We would want our client code use
#include <foo/config.h>
to include ourconfig.h
since we don't installconfig.h
directly toincludedir
. But for our own code this would be impossible since generatedconfig.h
is directly under<builddir>
, not<builddir/foo>
.Of course, for
foo.cpp
the work-around is easy: just#include <config.h>
. But it becomes complicated we need to includeconfig.h
frombar.h
andfoobar.h
.In fact, there is no way to correctly include
config.h
that both work in project directory and after installation. If we wantbar.h
andfoobar.h
to be correct after installation we must#include <foo/config.h>
or use relative path in them. Including<foo/config.h>
won't compile, and although relative path happens to work forbar.h
, it won't forfoobar.h
. Neither will it work if we reside in a subdir. Using#include <config.h>
allows us to compile, butbar.h
andfoobar.h
breaks up after installation.The correctly way to configure and include config.h should be just generate it under
builddir/foo
and#include <foo/config.h>
everywhere, just as if it were in the position ofconfig.h.in
. Currently meson does not allow this, and forces a flat include directory, or hacking into builddir.This one is simpler. If we have some protos like
in which
bar.proto
importsfoo.proto
.it would be nice if we could use one generator for both protos and and get under build directory something like this:For the compiled protos to work the directory structure of generated sources must mirror the protos, because bar.pb.h will
#include "foo/foo.pb.h"
. The generated sources must look like this:Althouth this would also require something like @dirname@ substitution if we are to pass generated sources to build targets properly, but without supporting generating source trees we cannot use protos with subdirectories. This also prevents wrapping of existing projects that use protos this way, which is quite a common practice.
PS: I suggest putting every generated file from
configure_file()
andcustom_target()
(including ones insubdir
s) into one directory tree named something like<builddir>/sources@gen
, add it to include directory, and allowoutput
ing to subdirectories under it. This should avoid potential name clashes and give developers control over generated folder layout.The text was updated successfully, but these errors were encountered: