-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
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 ran into this problem by unusual way: Since cmake builds broken for my case (#13390) I tried to call cmake as custom_target Build results is placed into |
If not for this, I had a chance to convince a huge company to switch to Meson. |
I've found this to be a pain point as well. Could this functionality not be part of the A function that accepts a fs = import('fs')
fs.copytree('bundle', {
'config.ini': configure_file('config.ini.in', configuration : { 'name': 'example' }),
'assets': {
'icon': compressed_icon,
'redist': {
'd3d12': {
'D3D12Core.dll': files('data/redist/d3d12/D3D12Core.dll'),
'D3D12Core.pdb': files('data/redist/d3d12/D3D12Core.pdb'),
'D3D12SDKLayers.dll': files('data/redist/d3d12/D3D12SDKLayers.dll'),
'd3d12SDKLayers.pdb': files('data/redist/d3d12/D3D12SDKLayers.pdb'),
}
}
}
}) I originally tried using |
Maybe Muon or Boson can implement this? They are both clones of Meson. Has anyone tried to approach them about this feature? |
What is boson? |
It's a Meson clone written in C: https://sr.ht/~bl4ckb0ne/boson/ |
Still can't figure this out. Thought I could get away with using the stamp approach described above, but then when you try to declare a dependency on a This restriction really just feels arbitrary at this point. 😢 |
https://mesonbuild.com/Reference-manual_functions.html#custom_target_depend_files |
I need this and there is no reasonable workaround with the current state of things. I tried to use generator to generate the output in a subdir. I need to generate like 15 files in 5 or 6 different subdirectories, like this:
With generator I tried something like this:
With a custom target it also works wrong, the output cannot be added subdirs of any kind. Moving down in subdirs also will not work, since those subdir generated files are consumed into the parent dir, so the build dir is the one from the parent, it seems. Not sure if it is an internal detail. I think that not being able to control the output path at least in the way proposed by you is by far the thing that more headaches gave me in Meson when using it for over 6 years (do not remember when I started to use it exactly). I really think @jpakkane this should be fixed and it is a recurrent problem |
Already looked at this - that's not what I'm looking for. Firstly, the documentation states that this allows adding dependencies that are not listed in the command keyword argument. As I already mentioned, trying to add this dependency via a |
@exposedcranium
Ahah I feel your pain because we went through the same thing. The solution we went with (in GIMP) is that it's not just a stamp file. It's a stamp header file. Basically have a Then any other target actually depending on it will actually wait or be rebuilt when appropriate.
I agree. In the end, we usually eventually always find some weird workaround for every use case (we had quite a few headaches in GIMP before having meson finally cater to us), but it does always feel like jumping through hoops instead of having some more generic target-making and dependency rules.
The various options to add file dependencies don't work because every rule out there has just a limited set of acceptable types. In particular here, @exposedcranium is not asking to make a @custom_target, they are talking about an executable, which likely means they wanted to use |
I've been exploring porting my program to meson, and I'm also hitting this. In a lot of ways, any generator that is generating an arbitrary directory structure is roughly equivalent to I think to make this easy to use, we have at least the following constraints/features needed:
To meet those constaints, maybe it could look something like this (or overload custom_target). myfiles = complex_generator(
'name',
input: 'foo.tar.gz',
output: '@OUTDIR@',
command: [tar, '-xf', '@INPUT@', '-C', '@OUTDIR@'],
)
foo_lib = library('foo', [myfiles / 'path' / 'to' / 'foo.cpp']) The idea is that when you do this more complex generator thing, that the object it returns has an overloaded I think the private output directory should not be the current build path (to avoid the subdir problems), but something artificial but recognizable. So maybe if the rule is in 'some/directory/path', meson would use It feels like ninja supports this sort of dynamic target using dyndep, but it's not quite right. |
@virtuald -- you can already have |
You are correct, my example did not show multiple levels. I updated my proposed syntax to show multiple levels. |
I came across this issue while trying to build some parts of aosp with meosn. Specifically tools like diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index ed34be950..b6c89fa72 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -327,8 +327,6 @@ def _output_validator(outputs: T.List[str]) -> T.Optional[str]:
return 'Output must not be empty.'
elif i.strip() == '':
return 'Output must not consist only of whitespace.'
- elif has_path_sep(i):
- return f'Output {i!r} must not contain a path segment.'
elif '@INPUT' in i:
return f'output {i!r} contains "@INPUT", which is invalid. Did you mean "@PLAINNAME@" or "@BASENAME@?' |
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: