[Emacs-ada-mode] Thanks and my first enquiry Fecha: Mon, 21 Aug 2006 22:26:52 +0200

Jean-Pierre Rosen rosen at adalog.fr
Fri Aug 25 02:46:34 PDT 2006


Stephen Leake a écrit :
> Do you have a separate Ada package that parses the *.adp? I could add
> that to Auto_Text_IO; that would be useful.
Just the simple function below (it is part of AdaControl, therefore 
under GMGPL. Tell me if you want a signed letter :-)
------------------------------------------------------
    function I_Options_From_Project (Project_File : String) return String is
       use Ada.Text_IO;
       F : File_Type;
       Key : constant String := "src_dir=";
       function Get_Next_Src return String is
          Buf  : String (1..500);
          Last : Natural;
       begin
          loop  -- Exit on End_Error
             Get_Line (F, Buf, Last);
             if Last > Key'Length and then
               Buf (1..Key'Length) = Key
             then
                return "-I" & Buf(Key'Length+1..Last) & ' ' & Get_Next_Src;
             end if;
          end loop;
       exception
          -- It is better to catch End_Error than to check End_Of_File
          -- in the case of malformed input files
          when End_Error =>
             return "";
       end Get_Next_Src;

    begin    -- I_Options_From_Project
       if Project_File = "" then
          -- No project file
          return "";
       end if;

       Open (F, In_File, Project_File);
       declare
          Result : constant String := Get_Next_Src;
       begin
          Close (F);
          return Result;
       end;
    exception
       when others =>
          if Is_Open (F) then
             Close (F);
          end if;
          raise;
    end I_Options_From_Project;
-------------------------------------------

> One way to support both is to have a functioning 'project_converter'
> (the gpr to adp tool once provided by AdaCore).
> 
I had a slightly different idea: a tool that reads a .gpr files and 
outputs the equivalent in term of gnat options, so any tool (ASIS or 
not) could do something like:
my_tool `gpr2options proj.gpr` ...

I think this is basically what the "gnat" command does, except that the 
options are adjusted for each tool. Maybe a patch to "gnat" that would 
output the options rather than launching the corresponding tool would be 
sufficient.

> The problem with project_converter *.gpr files is that it is
> compiler version dependent (apparently). Since AdaCore doesn't provide
> it anymore, we'd have to maintain versions for each version of gnat.
If we can come up with a simple patch to "gnat", then it would be easy 
to make it follow versions. Or maybe have AdaCore accept the patch.

> You mentioned that AdaCore had no intention of changing their ASIS
> tools to support gnat project files, until someone with deep pockets
> came along. But exporting a supported interface to *.gpr files should
> be simple (if we can agree on what that interface should look like :).
> I'm currently paying for ASIS support thru work; I think I'll ask for
> that for an ASIS tool I use at work, and see what happens.
> 
The most logical thing would be for ASIS to accept the -P option, the 
same way it currently accepts the -I option. I asked for it, and so did 
Eurocontrol. But don't hesitate to ask too: if enough customers ask for 
it, they may eventually do it.
-- 
---------------------------------------------------------
            J-P. Rosen (rosen at adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



More information about the Emacs-ada-mode mailing list