Utter brokenness

This commit is contained in:
Alejandro R Mosteo
2018-03-15 17:59:23 +01:00
parent b02a823903
commit 6f45ebc408
4 changed files with 53 additions and 15 deletions
-11
View File
@@ -1,11 +0,0 @@
with Alire.Origins;
package Alire.Hooks with Preelaborate is
-- Hackish way to enable Alire to obtain some platform-specific info that only Alr knows how to get
-- WARNING: this will be null during elaboration!
Version_Getter : access function (O : Origins.Origin) return String;
end Alire.Hooks;
+32
View File
@@ -0,0 +1,32 @@
with Ada.Containers.Indefinite_Holders;
package body Alire.Platform is
package Holders is new Ada.Containers.Indefinite_Holders (Supported_Platform'Class);
This : Holders.Holder;
type Unsupported_Platform is new Supported_Platform with null record;
overriding function Package_Version (P : Unsupported_Platform; Origin : Origins.Origin) return String is ("");
-------------
-- Current --
-------------
function Current return Supported_Platform'Class is
(if This.Is_Empty
then Unsupported_Platform'(Supported_Platform with null record)
else This.Element);
------------------
-- Set_Platform --
------------------
procedure Set_Platform (P : Supported_Platform'Class) is
begin
This.Replace_Element (P);
end Set_Platform;
end Alire.Platform;
+18
View File
@@ -0,0 +1,18 @@
with Alire.Origins;
package Alire.Platform with Preelaborate is
-- This interface encapsulates what a supported platform must provide for use in Alire, and a way
-- to hook it after elaboration
type Supported_Platform is interface;
function Package_Version (P : Supported_Platform; Origin : Origins.Origin) return String is abstract;
procedure Set_Platform (P : Supported_Platform'Class);
function Current return Supported_Platform'Class
with Pre => Platform'Elaborated;
-- Always valid, because at worst a dummy do-nothign one is returned
end Alire.Platform;
+3 -4
View File
@@ -1,6 +1,6 @@
with Alire.Conditional_Values;
with Alire.Dependencies.Vectors;
with Alire.Hooks;
with Alire.Platform;
with Alire.Platforms;
with Alire.Requisites.Booleans;
@@ -247,11 +247,10 @@ package body Alire.Releases is
-------------
function Version (R : Release) return Semantic_Versioning.Version is
use Hooks;
begin
if Hooks.Version_Getter /= null and then R.Origin.Is_Native then
if R.Origin.Is_Native then
declare
Native_Version : constant String := Hooks.Version_Getter (R.Origin);
Native_Version : constant String := Platform.Current.Package_Version (R.Origin);
begin
if Native_Version /= "" then
return New_Version (Image (R.Version) & "+" & Native_Version);