-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
[RFC] Installation and sharing of resources #948
Conversation
Down the road, |
I have pushed 94749df that gprinstalls any project that's gprbuilt, and it seems to work as expected. A side effect is that now binaries appear both in-tree and in the internal installation prefix. So |
I still don't have I a clear idea of what is needed, and when :) In terms of resources there are two situation as far as I can see: During development, where crates can be located anywhere (because of pins), and after the install where tools, libs, and resources will be in a common location. I don't think that doing gprinstall after every builds, or before every run, is an option that will scale. Installation can move huge amounts of data around. So we need a way to make things work in both dev and install scenarios. Something that we discussed during FOSDEM was to use an environment variable to define the location of resources for each crate. For instance we could have as part of the
Each crate that needs to access resources could then use these env variables to get resources path. And we can develop a Now what to do after installation? The Looking at other ecosystems:
Maybe alr run should only look in generic
Crate_Name : String;
package Resources is
function Prefix_Path return String;
function Resource_Path (Relative_Path : String) return String;
end Resources; with Ada.Text_IO;
with Resources;
procedure Plop is
package Res is new Resources ("plop");
begin
Ada.Text_IO.Put_Line (Res.Prefix_Path);
Ada.Text_IO.Put_Line (Res.Resource_Path ("share/plop/template/plop.tmplt"));
null;
end Plop; with GNATcoll.Utils;
with GNAT.OS_Lib;
with GNAT.Strings;
with Ada.Characters.Handling;
package body Resources is
-----------------
-- Prefix_Path --
-----------------
function Prefix_Path return String is
use Ada.Characters.Handling;
use GNAT.Strings;
Env_Prefix : GNAT.Strings.String_Access :=
GNAT.OS_Lib.Getenv (To_Upper (Crate_Name) & "_PREFIX");
begin
if Env_Prefix /= null then
return Result : String (1 .. Env_Prefix.all'Length) do
Result := Env_Prefix.all;
GNAT.Strings.Free (Env_Prefix);
end return;
else
-- Fallback to a path relative to the executable
return GNATCOLL.Utils.Executable_Location;
end if;
end Prefix_Path;
-------------------
-- Resource_Path --
-------------------
function Resource_Path (Relative_Path : String) return String is
begin
return Prefix_Path & "/" & Relative_Path;
end Resource_Path;
end Resources; The dependency on GNATcoll seems overkill here... |
Okay, important information all around. So, on the one hand releases can already export an env var via manifest to point to their resources during development. So a follow-up question is if we want to standardize the naming of such variables or leave that to crate documentation. As for This discussion leaves out reuse of large dependencies, that to me is a separate can of worms. I wouldn't do any of that through What I'm now clear is that using grpinstall as a default step during build is not a sound idea, so I'll remove that from the PR and let it rest while we muse ideas. |
If internal installation is performed during build, it makes no sense that explicit user-requested installation goes to the same place and not to the presumably intended "external" location.
@stcarrez we really need you opinion on this :) |
As far as I'm concerned, there are two aspects to consider
I really like the idea of having a Using When For a development installation the Ada For AWA, the framework is using some simple configuration file with a multi-path search mechanisms to find files in possibly several directories. To make it usable with Alire, I would need:
For development, 2) is easier because files are not copied. For example, I would need some post build command that generates somewhere something that looks like:
Such generation must not be made be Alire because that's too specific to the |
Thanks @onox
This is what I do for startup-gen, see artifact in GPR here and corresponding folders here.
|
Thanks @stcarrez
That's not my intent, so maybe my example was not clear. After installation, The constraint is that executable and dependencies resources have to be installed in the same prefix dir.
This sounds compatible with what I have in mind.
I am worried that this will lead us to re-invent the wheel. Alire has some hooks to run scripts/programs at given points (post-fetch, pre-build, post-build, etc.), I think that for your use case it will be a matter of |
Yes, I agree. Alire must not do it but it must allow me to do it. If the hooks have access to the environment variables when it is executed, then such setup could be implemented by some script or tool. |
Hello all, I started a prototype of what the It is based on the |
This is to be used for retrieval of crate resources, see #948.
Hi all, The solution described above is now available in the development branch of Alire (3e9da2f and 303de0e) and the associated To give it a try: $ alr init --bin test
$ cd test
$ alr with resources --use=https://github.com/alire-project/resources and: with Resources;
with Ada.Text_IO; use Ada.Text_IO;
with Test_Config;
procedure Test is
package My_Resources is new Resources (Test_Config.Crate_Name);
begin
Put_Line ("Prefix_Path: " & My_Resources.Prefix_Path);
end Test; @stcarrez it would be nice to have you feedback, in particular because you requested the feature. |
So, to summarize my current understanding of these matters, an a few thoughts on related features:
In this way, the new |
What's not clear to me yet is what will happen when I want to install tools that depend on two different version of a library. |
This is really tricky. I think it merits its own discussion beyond resources. I will open a new issue focused on installation of binaries and libraries. |
I'd say that resources are on the right track, so I'll close this one now, and I invite you all to reopen or open more focused issues down the road. |
I'm playing with an hypothetical new
alr install
that relies ongprinstall
. It seems to work well. What I'm currently doing is:${CRATE_ROOT}
/alire/prefix.ALIRE_PREFIX
in our environment.I tried the
for Artifacts ("path") use (...)
of GPR files and also works as expected. So, an executable run within ouralr printenv
can locate shared resources viaALIRE_PREFIX
.But, all in all, I have not much experience with installation and gprinstall. I have some fuzzy ideas were I'd like to hear your feedback @Fabien-Chouteau (and interested parties, e.g. @stcarrez):
My stance on this right now lends to not duplicating the work of gprinstall. At most have an
export-resources
flag, or even peek into project files forArtifacts
clauses (that could be too hackish if there are cases involved).Separate issue: at present, gprinstall is only called through
alr install
but:alr printenv
In this regard, I suspect that gprinstall is probably very solid and will simplify our lives down the road. We are currently doing everything in-tree, which I'm wary of (except for edition were we want the actual sources and not some installed headers -- I've been bitten by this in the past and it was a pain).