OSDN Git Service

2007-08-14 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / prj-env.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              P R J . E N V                               --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2001-2007, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package implements services for Project-aware tools, mostly related
28 --  to the environment (configuration pragma files, path files, mapping files).
29
30 package Prj.Env is
31
32    procedure Initialize;
33    --  Called by Prj.Initialize to perform required initialization steps for
34    --  this package.
35
36    procedure Print_Sources (In_Tree : Project_Tree_Ref);
37    --  Output the list of sources, after Project files have been scanned
38
39    procedure Create_Mapping_File
40      (Project : Project_Id;
41       In_Tree : Project_Tree_Ref;
42       Name    : out Path_Name_Type);
43    --  Create a temporary mapping file for project Project. For each unit
44    --  in the closure of immediate sources of Project, put the mapping of
45    --  its spec and or body to its file name and path name in this file.
46
47    procedure Create_Mapping_File
48      (Project  : Project_Id;
49       Language : Name_Id;
50       Runtime  : Project_Id;
51       In_Tree  : Project_Tree_Ref;
52       Name     : out Path_Name_Type);
53    --  Create a temporary mapping file for project Project. For each source or
54    --  template of Language in the of Project, put the mapping of its file
55    --  name and path name in this file.
56
57    procedure Set_Mapping_File_Initial_State_To_Empty;
58    --  When creating a mapping file, create an empty map. This case occurs
59    --  when run time source files are found in the project files.
60
61    procedure Create_Config_Pragmas_File
62      (For_Project          : Project_Id;
63       Main_Project         : Project_Id;
64       In_Tree              : Project_Tree_Ref;
65       Include_Config_Files : Boolean := True);
66    --  If there needs to have SFN pragmas, either for non standard naming
67    --  schemes or for individual units, or (when Include_Config_Files is True)
68    --  if Global_Configuration_Pragmas has been specified in package gnatmake
69    --  of the main project, or if Local_Configuration_Pragmas has been
70    --  specified in package Compiler of the main project, build (if needed)
71    --  a temporary file that contains all configuration pragmas, and specify
72    --  the configuration pragmas file in the project data.
73
74    procedure Create_New_Path_File
75      (In_Tree   : Project_Tree_Ref;
76       Path_FD   : out File_Descriptor;
77       Path_Name : out Path_Name_Type);
78    --  Create a new temporary path file. Get the file name in Path_Name.
79    --  The name is normally obtained by increasing the number in
80    --  Temp_Path_File_Name by 1.
81
82    function Ada_Include_Path
83      (Project : Project_Id;
84       In_Tree : Project_Tree_Ref) return String_Access;
85    --  Get the ADA_INCLUDE_PATH of a Project file. For the first call, compute
86    --  it and cache it.
87
88    function Ada_Include_Path
89      (Project   : Project_Id;
90       In_Tree   : Project_Tree_Ref;
91       Recursive : Boolean) return String;
92    --  Get the ADA_INCLUDE_PATH of a Project file. If Recursive it True,
93    --  get all the source directories of the imported and modified project
94    --  files (recursively). If Recursive is False, just get the path for the
95    --  source directories of Project. Note: the resulting String may be empty
96    --  if there is no source directory in the project file.
97
98    function Ada_Objects_Path
99      (Project             : Project_Id;
100       In_Tree             : Project_Tree_Ref;
101       Including_Libraries : Boolean := True) return String_Access;
102    --  Get the ADA_OBJECTS_PATH of a Project file. For the first call, compute
103    --  it and cache it. When Including_Libraries is False, do not include the
104    --  object directories of the library projects, and do not cache the result.
105
106    procedure Set_Ada_Paths
107      (Project             : Project_Id;
108       In_Tree             : Project_Tree_Ref;
109       Including_Libraries : Boolean);
110    --  Set the env vars for additional project path files, after
111    --  creating the path files if necessary.
112
113    procedure Delete_All_Path_Files (In_Tree : Project_Tree_Ref);
114    --  Delete all temporary path files that have been created by
115    --  calls to Set_Ada_Paths.
116
117    function Path_Name_Of_Library_Unit_Body
118      (Name    : String;
119       Project : Project_Id;
120       In_Tree : Project_Tree_Ref) return String;
121    --  Returns the Path of a library unit
122
123    function File_Name_Of_Library_Unit_Body
124      (Name              : String;
125       Project           : Project_Id;
126       In_Tree           : Project_Tree_Ref;
127       Main_Project_Only : Boolean := True;
128       Full_Path         : Boolean := False) return String;
129    --  Returns the file name of a library unit, in canonical case. Name may or
130    --  may not have an extension (corresponding to the naming scheme of the
131    --  project). If there is no body with this name, but there is a spec, the
132    --  name of the spec is returned.
133    --
134    --  If Full_Path is False (the default), the simple file name is returned.
135    --
136    --  If Full_Path is True, the absolute path name is returned.
137    --
138    --  If neither a body nor a spec can be found, an empty string is returned.
139    --  If Main_Project_Only is True, the unit must be an immediate source of
140    --  Project. If it is False, it may be a source of one of its imported
141    --  projects.
142
143    function Project_Of
144      (Name         : String;
145       Main_Project : Project_Id;
146       In_Tree      : Project_Tree_Ref) return Project_Id;
147    --  Get the project of a source. The source file name may be truncated
148    --  (".adb" or ".ads" may be missing). If the source is in a project being
149    --  extended, return the ultimate extending project. If it is not a source
150    --  of any project, return No_Project.
151
152    procedure Get_Reference
153      (Source_File_Name : String;
154       In_Tree          : Project_Tree_Ref;
155       Project          : out Project_Id;
156       Path             : out Path_Name_Type);
157    --  Returns the project of a source and its path in displayable form
158
159    generic
160       with procedure Action (Path : String);
161    procedure For_All_Source_Dirs
162      (Project : Project_Id;
163       In_Tree : Project_Tree_Ref);
164    --  Iterate through all the source directories of a project, including
165    --  those of imported or modified projects.
166
167    generic
168       with procedure Action (Path : String);
169    procedure For_All_Object_Dirs
170      (Project : Project_Id;
171       In_Tree : Project_Tree_Ref);
172    --  Iterate through all the object directories of a project, including
173    --  those of imported or modified projects.
174
175 end Prj.Env;