3a92d9967433664aebe52100356a51ee83da6e47
[gcc.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-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 -- This package implements services for Project-aware tools, mostly related
27 -- to the environment (configuration pragma files, path files, mapping files).
28
29 package Prj.Env is
30
31 procedure Initialize (In_Tree : Project_Tree_Ref);
32 -- Initialize global components relative to environment variables
33
34 procedure Print_Sources (In_Tree : Project_Tree_Ref);
35 -- Output the list of sources, after Project files have been scanned
36
37 procedure Create_Mapping (In_Tree : Project_Tree_Ref);
38 -- Create in memory mapping from the sources of all the projects (in body
39 -- of package Fmap), so that Osint.Find_File will find the correct path
40 -- corresponding to a source.
41
42 procedure Create_Mapping_File
43 (Project : Project_Id;
44 Language : Name_Id := No_Name;
45 In_Tree : Project_Tree_Ref;
46 Name : out Path_Name_Type);
47 -- Create a temporary mapping file for project Project. For each source or
48 -- template of Language in the Project, put the mapping of its file
49 -- name and path name in this file.
50 --
51 -- This function either looks at all the source files for the specified
52 -- language in the project, or if Language is set to No_Name, at all
53 -- units in the project.
54 --
55 -- Implementation note: we pass a language name, not a language_index here,
56 -- since the latter would have to match exactly the index of that language
57 -- for the specified project, and that is not information available in
58 -- buildgpr.adb.
59
60 procedure Set_Mapping_File_Initial_State_To_Empty
61 (In_Tree : Project_Tree_Ref);
62 -- When creating a mapping file, create an empty map. This case occurs when
63 -- run time source files are found in the project files. This only applies
64 -- to the Ada_Only mode.
65
66 procedure Create_Config_Pragmas_File
67 (For_Project : Project_Id;
68 Main_Project : Project_Id;
69 In_Tree : Project_Tree_Ref;
70 Include_Config_Files : Boolean := True);
71 -- If there needs to have SFN pragmas, either for non standard naming
72 -- schemes or for individual units, or (when Include_Config_Files is True)
73 -- if Global_Configuration_Pragmas has been specified in package gnatmake
74 -- of the main project, or if Local_Configuration_Pragmas has been
75 -- specified in package Compiler of the main project, build (if needed)
76 -- a temporary file that contains all configuration pragmas, and specify
77 -- the configuration pragmas file in the project data.
78
79 procedure Create_New_Path_File
80 (In_Tree : Project_Tree_Ref;
81 Path_FD : out File_Descriptor;
82 Path_Name : out Path_Name_Type);
83 -- Create a new temporary path file. Get the file name in Path_Name.
84 -- The name is normally obtained by increasing the number in
85 -- Temp_Path_File_Name by 1.
86
87 function Ada_Include_Path
88 (Project : Project_Id;
89 In_Tree : Project_Tree_Ref) return String_Access;
90 -- Get the source search path of a Project file. For the first call,
91 -- compute it and cache it.
92
93 function Ada_Include_Path
94 (Project : Project_Id;
95 In_Tree : Project_Tree_Ref;
96 Recursive : Boolean) return String;
97 -- Get the source search path of a Project file. If Recursive it True, get
98 -- all the source directories of the imported and modified project files
99 -- (recursively). If Recursive is False, just get the path for the source
100 -- directories of Project. Note: the resulting String may be empty if there
101 -- is no source directory in the project file.
102
103 function Ada_Objects_Path
104 (Project : Project_Id;
105 In_Tree : Project_Tree_Ref;
106 Including_Libraries : Boolean := True) return String_Access;
107 -- Get the ADA_OBJECTS_PATH of a Project file. For the first call, compute
108 -- it and cache it. When Including_Libraries is False, do not include the
109 -- object directories of the library projects, and do not cache the result.
110
111 procedure Set_Ada_Paths
112 (Project : Project_Id;
113 In_Tree : Project_Tree_Ref;
114 Including_Libraries : Boolean);
115 -- Set the environment variables for additional project path files, after
116 -- creating the path files if necessary.
117
118 procedure Delete_All_Path_Files (In_Tree : Project_Tree_Ref);
119 -- Delete all temporary path files that have been created by Set_Ada_Paths
120
121 function File_Name_Of_Library_Unit_Body
122 (Name : String;
123 Project : Project_Id;
124 In_Tree : Project_Tree_Ref;
125 Main_Project_Only : Boolean := True;
126 Full_Path : Boolean := False) return String;
127 -- Returns the file name of a library unit, in canonical case. Name may or
128 -- may not have an extension (corresponding to the naming scheme of the
129 -- project). If there is no body with this name, but there is a spec, the
130 -- name of the spec is returned.
131 --
132 -- If Full_Path is False (the default), the simple file name is returned.
133 --
134 -- If Full_Path is True, the absolute path name is returned.
135 --
136 -- If neither a body nor a spec can be found, an empty string is returned.
137 -- If Main_Project_Only is True, the unit must be an immediate source of
138 -- Project. If it is False, it may be a source of one of its imported
139 -- projects.
140
141 function Project_Of
142 (Name : String;
143 Main_Project : Project_Id;
144 In_Tree : Project_Tree_Ref) return Project_Id;
145 -- Get the project of a source. The source file name may be truncated
146 -- (".adb" or ".ads" may be missing). If the source is in a project being
147 -- extended, return the ultimate extending project. If it is not a source
148 -- of any project, return No_Project.
149
150 procedure Get_Reference
151 (Source_File_Name : String;
152 In_Tree : Project_Tree_Ref;
153 Project : out Project_Id;
154 Path : out Path_Name_Type);
155 -- Returns the project of a source and its path in displayable form
156
157 generic
158 with procedure Action (Path : String);
159 procedure For_All_Source_Dirs
160 (Project : Project_Id;
161 In_Tree : Project_Tree_Ref);
162 -- Iterate through all the source directories of a project, including those
163 -- of imported or modified projects.
164 -- Only returns those directories that potentially contain Ada sources (ie
165 -- ignore projects that have no Ada sources
166
167 generic
168 with procedure Action (Path : String);
169 procedure For_All_Object_Dirs (Project : Project_Id);
170 -- Iterate through all the object directories of a project, including
171 -- those of imported or modified projects.
172
173 end Prj.Env;