AdaCore / gprbuild

GPRbuild is an advanced build system designed to help automate the construction of multi-language systems.
Other
65 stars 21 forks source link

Wish: Raise declaration. #71

Closed Blady-Com closed 4 years ago

Blady-Com commented 5 years ago

Hello,

In order to facilitate GPR projects tuning (as they may become very complex), GPRBuild might support raise declarations as: raise_declaration ::= 'raise' 'Info' | 'Warning' | 'Error' ['with' string_expression] Examples:

raise Info with "Compiler options: " & CO;
raise Warning;
raise Error with "Undefined";

In all case, GRPBuild outputs a message as: sample.gpr:6:06: raised Warning In case of Error, GRPBuild stops:

sample.gpr:9:09: raised Error "Undefined"
gprbuild: "sample.gpr" processing failed

Thus it might be useful, for instance, in case constructions:

Example 2.10.9. Case Constructions of GPRBuild manual:

project MyProj is
   type OS_Type is ("GNU/Linux", "Unix", "Windows", "VMS");
   OS : OS_Type := external ("OS", "GNU/Linux");
   package Compiler is
     case OS is
       when "GNU/Linux" | "Unix" =>
         for Switches ("Ada")
             use ("-gnath");
       when "Windows" =>
         for Switches ("Ada")
             use ("-gnatP");
       when others =>
         raise Error with OS & " is not supported";
     end case;
     raise Info with "Compiler options: " & Switches ("Ada");
   end Compiler;
end MyProj;

HTH, Pascal.

t-14 commented 4 years ago

There is support for user-defined warning messages, via attribute Warning_Message:

for Warning_Message use "Hi there.";

will display:

p.gpr:1:09: warning: Hi there.

For now we are not planning to extend this functionality.