diff --git a/src/alire-index.adb b/src/alire-index.adb index 45988b8a..919e8799 100644 --- a/src/alire-index.adb +++ b/src/alire-index.adb @@ -30,11 +30,9 @@ package body Alire.Index is Requisites => Requisites, Native => Native) do - if not Available_When.Is_Empty and then - not Available_When.Check (Platform_Properties) + if not Available_When.Is_Empty and Then not Available_When.Check (Platform_Properties) then - Trace.Debug ("Release " & Rel.Milestone_Image & - " requisites not met by platform"); + Trace.Debug ("Release " & Rel.Milestone_Image & " requisites not met by platform"); return; end if; diff --git a/src/alire-index.ads b/src/alire-index.ads index 83d84ee9..b85cb939 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -1,3 +1,5 @@ +private with Alire_Early_Elaboration; pragma Unreferenced (Alire_Early_Elaboration); + with Alire.Containers; with Alire.Compilers; with Alire.Depends; diff --git a/src/alire_early_elaboration.adb b/src/alire_early_elaboration.adb new file mode 100644 index 00000000..0ea17554 --- /dev/null +++ b/src/alire_early_elaboration.adb @@ -0,0 +1,55 @@ +with Alire; -- Kind of circularity here but somehow it slips past static GNAT rules?? + +with GNAT.Command_Line; +with GNAT.OS_Lib; + +with Simple_Logging; + +package body Alire_Early_Elaboration is + + ---------------------------- + -- Early_Switch_Detection -- + ---------------------------- + + procedure Early_Switch_Detection is + use GNAT.Command_Line; + + Config : Command_Line_Configuration; + + begin + Define_Switch (Config, + Switch_Q'Access, + "-q", + Help => "Limit output to errors"); + Define_Switch (Config, + Switch_V'Access, + "-v", + Help => "Be more verbose"); + + Define_Switch (Config, + Switch_D'Access, + "-d", + Help => "Be even more verbose (including debug messages)"); + + Getopt (Config); + + -- Exclusivity check + if (Switch_D and Switch_V) or (Switch_D and Switch_Q) or (Switch_V and Switch_Q) then + Alire.Trace.Info ("Ada Library Repository manager (alr)"); + Alire.Trace.Error ("Only one verbosity switch allowed (either -d, -v or -q)"); + GNAT.OS_Lib.OS_Exit (1); + end if; + + -- Level setting + if Switch_D then + Alire.Log_Level := Simple_Logging.Debug; + elsif Switch_V then + Alire.Log_Level := Simple_Logging.Detail; + elsif Switch_Q then + Alire.Log_Level := Simple_Logging.Error; + end if; + end Early_Switch_Detection; + +begin + Early_Switch_Detection; +end Alire_Early_Elaboration; diff --git a/src/alire_early_elaboration.ads b/src/alire_early_elaboration.ads new file mode 100644 index 00000000..0d8b9d74 --- /dev/null +++ b/src/alire_early_elaboration.ads @@ -0,0 +1,13 @@ +package Alire_Early_Elaboration with Elaborate_Body is + + -- This body should be elaborated among the first ones. + -- For anything requiring early elaboration (e.g. logging setup) + + -- Not directly a child of Alire to avoid circularity + + Switch_D, + Switch_Q, + Switch_V : aliased Boolean := False; + -- Verbosity switches detected during early elaboration + +end Alire_Early_Elaboration;