OSDN Git Service

2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / makeutl.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              M A K E U T L                               --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2004-2009, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license.          --
20 --                                                                          --
21 -- GNAT was originally developed  by the GNAT team at  New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
23 --                                                                          --
24 ------------------------------------------------------------------------------
25
26 with Namet; use Namet;
27 with Osint;
28 with Prj;   use Prj;
29 with Types; use Types;
30
31 with GNAT.OS_Lib; use GNAT.OS_Lib;
32
33 package Makeutl is
34
35    type Fail_Proc is access procedure (S : String);
36    Do_Fail : Fail_Proc := Osint.Fail'Access;
37    --  Failing procedure called from procedure Test_If_Relative_Path below.
38    --  May be redirected.
39
40    Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data;
41    --  The project tree
42
43    Subdirs_Option : constant String := "--subdirs=";
44    --  Switch used to indicate that the real directories (object, exec,
45    --  library, ...) are subdirectories of those in the project file.
46
47    procedure Add
48      (Option : String_Access;
49       To     : in out String_List_Access;
50       Last   : in out Natural);
51    procedure Add
52      (Option : String;
53       To     : in out String_List_Access;
54       Last   : in out Natural);
55    --  Add a string to a list of strings
56
57    function Create_Name (Name : String) return File_Name_Type;
58    function Create_Name (Name : String) return Name_Id;
59    function Create_Name (Name : String) return Path_Name_Type;
60    --  Get the Name_Id of a name
61
62    function Executable_Prefix_Path return String;
63    --  Return the absolute path parent directory of the directory where the
64    --  current executable resides, if its directory is named "bin", otherwise
65    --  return an empty string. When a directory is returned, it is guaranteed
66    --  to end with a directory separator.
67
68    procedure Inform (N : Name_Id := No_Name; Msg : String);
69    procedure Inform (N : File_Name_Type; Msg : String);
70    --  Prints out the program name followed by a colon, N and S
71
72    function Is_External_Assignment (Argv : String) return Boolean;
73    --  Verify that an external assignment switch is syntactically correct
74    --
75    --  Correct forms are:
76    --
77    --      -Xname=value
78    --      -X"name=other value"
79    --
80    --  Assumptions: 'First = 1, Argv (1 .. 2) = "-X"
81    --  When this function returns True, the external assignment has
82    --  been entered by a call to Prj.Ext.Add, so that in a project
83    --  file, External ("name") will return "value".
84
85    function Linker_Options_Switches
86      (Project  : Project_Id;
87       In_Tree  : Project_Tree_Ref) return String_List;
88    --  Collect the options specified in the Linker'Linker_Options attributes
89    --  of project Project, in project tree In_Tree, and in the projects that
90    --  it imports directly or indirectly, and returns the result.
91
92    --  Package Mains is used to store the mains specified on the command line
93    --  and to retrieve them when a project file is used, to verify that the
94    --  files exist and that they belong to a project file.
95
96    function Unit_Index_Of (ALI_File : File_Name_Type) return Int;
97    --  Find the index of a unit in a source file. Return zero if the file
98    --  is not a multi-unit source file.
99
100    package Mains is
101
102       --  Mains are stored in a table. An index is used to retrieve the mains
103       --  from the table.
104
105       procedure Add_Main (Name : String);
106       --  Add one main to the table
107
108       procedure Set_Location (Location : Source_Ptr);
109       --  Set the location of the last main added. By default, the location is
110       --  No_Location.
111
112       procedure Delete;
113       --  Empty the table
114
115       procedure Reset;
116       --  Reset the index to the beginning of the table
117
118       function Next_Main return String;
119       --  Increase the index and return the next main.
120       --  If table is exhausted, return an empty string.
121
122       function Get_Location return Source_Ptr;
123       --  Get the location of the current main
124
125       procedure Update_Main (Name : String);
126       --  Update the file name of the current main
127
128       function Number_Of_Mains return Natural;
129       --  Returns the number of mains added with Add_Main since the last call
130       --  to Delete.
131
132    end Mains;
133
134    procedure Test_If_Relative_Path
135      (Switch               : in out String_Access;
136       Parent               : String;
137       Including_L_Switch   : Boolean := True;
138       Including_Non_Switch : Boolean := True;
139       Including_RTS        : Boolean := False);
140    --  Test if Switch is a relative search path switch.
141    --  If it is, fail if Parent is the empty string, otherwise prepend the path
142    --  with Parent. This subprogram is only called when using project files.
143    --  For gnatbind switches, Including_L_Switch is False, because the
144    --  argument of the -L switch is not a path. If Including_RTS is True,
145    --  process also switches --RTS=.
146
147    function Path_Or_File_Name (Path : Path_Name_Type) return String;
148    --  Returns a file name if -df is used, otherwise return a path name
149
150    ----------------------
151    -- Marking Routines --
152    ----------------------
153
154    procedure Mark (Source_File : File_Name_Type; Index : Int := 0);
155    --  Mark a unit, identified by its source file and, when Index is not 0,
156    --  the index of the unit in the source file. Marking is used to signal
157    --  that the unit has already been inserted in the Q.
158
159    function Is_Marked
160      (Source_File : File_Name_Type;
161       Index       : Int := 0) return Boolean;
162    --  Returns True if the unit was previously marked
163
164    procedure Delete_All_Marks;
165    --  Remove all file/index couples marked
166
167 end Makeutl;