-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Connect executables
with targets
#591
Comments
I really like this idea of being able to list out
This portion I dislike, but maybe I'm not seeing the benefit - why would I want to wait for a tool to build the first time I invoke it, instead of when I run I can't speak for others, but I only include executables / tools that I actively use in my |
@Vici37 IIUC The reason is to reduce the |
Use cases differ. I would argue that I might not need all these tools if I just want to checkout the code of your shard, or maybe to build it and run tests?
And I'm not suggesting that lazy building should be the only option. If you want to have all executables build on |
That's fair. Reading your reasons for wanting to pull and build a given shard here, it does look like there's existing I'm not opposed to creating a new sub-sub command to handle this phase (i.e. |
shard.yml
allows defining executables that are supposed to be installed in the main project'sbin/
folder, and it allows defining build targets. But they are currently not related.If executables need to be built, the only way to do that is run a build command in
postinstall
. Ideally, that's justshards build
.I think it would be a good opportunity to automate that by hooking up
executables
with the availabletargets
information.Operation would be quite simple: When shards cannot find a file for a declared executable, but there is a
target
definition of the same name, it runsshards build $executable_name
. Then the executable file should exist.This works without disrupting existing workflows where the executable is already available in the source or built by a postinstall hook because existing files would be preferred.
An immediate result is simplification of the
shard.yml
, with the additional benefit of turning imperative instructions into declarations (which helps portability).So the above
shard.yml
could be shortened to this:No need to define
shards build
(or the equivalent usingmake
or whatever) inpostinstall
.This probably won't work for all shards, because some have more complex builds. But I figure it should be good for the vast majority of typical development tools.
As a further enhancement, instead of building directly upon installation, the executable could actually be a shim which invokes the build command on demand. This avoids waiting for executables to build when running
shards install
and only builds them if they are actually used. That causes some delay when used the first time, but that should be acceptable: If you want to use it, you have to wait for the build anyway at some point. But if you don't use it, there's no need to build it!This proposal is based on some ideas previously mentioned in https://forum.crystal-lang.org/t/shards-postinstall-considered-harmful/3910/14?u=straight-shoota
The text was updated successfully, but these errors were encountered: