Open pobrn opened 1 year ago
Here is a rough attempt:
I think it would be useful if it also accepted targets that are installed
In old discussions about this, that was indeed requested. From recollection, the design of install_symlink was intended as an MVP that everyone could agree on -- a portable way to produce symlink objects when you know what the source and destination should be.
Discussion about handling executables got bogged down a bit by concerns about how to handle the names cross-platform, e.g. should meson automatically add a ".exe" to the symlink name when it's pointing to a Windows executable that gains a .exe extension there? Should it just point "foo" to the "bar.exe" file?
I thought it was a bit of a weak argument, myself, the answer should just be "yes, do the magic"... I'm definitely open to the idea of extending this.
We should probably convert the executable to a string inside func_install_symlink, though, not do it inside the backend.
I thought it was a bit of a weak argument, myself, the answer should just be "yes, do the magic"... I'm definitely open to the idea of extending this.
So as far as I understand, the logic would be:
This would create symbolic links for all sonames of a shared library, implibs, debug files (pdb), etc. But I feel this would overload the behaviour of install_symlink()
a bit too much. Maybe an alias_target()
would be more appropriate for this.
We should probably convert the executable to a string inside func_install_symlink, though, not do it inside the backend.
I did it there because e.g. get_target_filename()
is part of Backend
and the methods thereof are not really accessed from Interpreter
as far as I can see.
This would create symbolic links for all sonames of a shared library, implibs, debug files (pdb), etc. But I feel this would overload the behaviour of
install_symlink()
a bit too much. Maybe analias_target()
would be more appropriate for this.
I think that's not necessary, we can just create a symbolic link to the primary output -- people creating symlinks really just want to be able to access the shared or static library, or executable, under a different name. pdb files, the multiple symlink aliases of a versioned library, etc. are not actually intended to be symlinked.
I did it there because e.g.
get_target_filename()
is part ofBackend
That's an interesting point, and I'm not sure what the best thing to do is, but I will note that doing it in the backend means that if there's an error, you don't get it when you use install_symlink and you don't get a reference to the file and line number that provoked the error -- but instead you get an anonymous error while writing out build.ninja.
get_target_filename()
and friends being in backend has annoyed me more than once. I think all those functions should be moved as method on the target object.
Hold on, rereading this, the only point of get_target_filename() is to produce a symlink in the source tree if the executable/whatever you are trying to use as a pointing_to
target, is install: false
.
The answer to this is simple: no.
No. The install_symlink() function clearly installs something, and must point to something that's installed. This is another reason to do this in the interpreter, not the backend: because get_target_filename should be replaced by "error: you may not do this".
Hold on, rereading this, the only point of get_target_filename() is to produce a symlink in the source tree if the executable/whatever you are trying to use as a pointing_to target, is install: false.
Is this in reference to the patch I attached? If so, then I don't understand what you mean because whether or not the target is installed is checked. Or am I missing something?
Also, producing a symlink in the build directory would be a good feature in my opinion. For example, at the moment one has to use custom_target()
(or something) and install_symlink()
if you also need the symlink in the build directory.
Also, producing a symlink in the build directory would be a good feature in my opinion.
Speaking as a project maintainer I consider this a bad feature.
the purpose of symlinks is to expose installable artifacts via aliased names, for example:
progname subcommand
or subcommand
the name "install_*()" is reserved in meson for install-time activities. The InstallSymlinkData() class instance is added to an install.dat
object that gets processed when running meson install
, so they will not exist at build time anyway. If you want to create something at build time, you need to create a mesonbuild.build.CustomTarget()
class instance and add it to build.dat
, and the meson.build function for that is... "custom_target()".
...
If you need a build-time symlink then instead of using a dedicated "install" function without an install dir, just use a custom_target with the /usr/bin/ln program -- this already works. What's the downside of this?
If you need a build-time symlink then instead of using a dedicated "install" function without an install directory, just use a custom_target with the /usr/bin/ln program -- this already works. What's the downside of this?
I would want to have both. In order to have a seamless devenv experience, I would argue that the symlinks would need to exist in the build directory and be installed as well. Currently one needs to use both custom_target()
and install_symlink()
to achieve this, right? Also using custom_target()
will make the build dependent on ln
.
I am not saying that install_symlink()
should be modified. I would just like to see a function that will create a symlink in the build directory and install it as well, and also accepts other (build) targets as (symlink) target.
Currently, the
pointing_to
argument ofinstall_symlink()
only accepts strings:I think it would be useful if it also accepted targets that are installed (probably restricted to targets that have a single output). This would be useful for adding alternative names for executables, libraries, etc. (which was one of the original motivations for adding
install_symlink()
in the first place - this would make it even simpler and more robust).For example:
It would be also nice if in this case the
install_dir
argument could be omitted, and theinstall_dir
of the pointed-to target used. It not clear to me whether relative or absolute paths should be used, but I imagine that could be selected using a keyword argument.