Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / ada / prj-env.ads
blob9dcde3280385b408613610e9fce895d8915152a9
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 ------------------------------------------------------------------------------
26 -- This package implements services for Project-aware tools, mostly related
27 -- to the environment (configuration pragma files, path files, mapping files).
29 package Prj.Env is
31 procedure Initialize (In_Tree : Project_Tree_Ref);
32 -- Initialize global components relative to environment variables
34 procedure Print_Sources (In_Tree : Project_Tree_Ref);
35 -- Output the list of sources, after Project files have been scanned
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.
42 procedure Create_Temp_File
43 (In_Tree : Project_Tree_Ref;
44 Path_FD : out File_Descriptor;
45 Path_Name : out Path_Name_Type;
46 File_Use : String);
47 -- Create temporary file, and fail with an error if it could not be created
49 procedure Create_Mapping_File
50 (Project : Project_Id;
51 Language : Name_Id;
52 In_Tree : Project_Tree_Ref;
53 Name : out Path_Name_Type);
54 -- Create a temporary mapping file for project Project. For each source or
55 -- template of Language in the Project, put the mapping of its file
56 -- name and path name in this file.
58 -- Implementation note: we pass a language name, not a language_index here,
59 -- since the latter would have to match exactly the index of that language
60 -- for the specified project, and that is not information available in
61 -- buildgpr.adb.
63 -- See fmap for a description of the format of the mapping file
65 procedure Create_Config_Pragmas_File
66 (For_Project : Project_Id;
67 In_Tree : Project_Tree_Ref);
68 -- If there needs to have SFN pragmas, either for non standard naming
69 -- schemes or for individual units.
71 procedure Create_New_Path_File
72 (In_Tree : Project_Tree_Ref;
73 Path_FD : out File_Descriptor;
74 Path_Name : out Path_Name_Type);
75 -- Create a new temporary path file. Get the file name in Path_Name.
77 function Ada_Include_Path
78 (Project : Project_Id;
79 In_Tree : Project_Tree_Ref;
80 Recursive : Boolean := False) return String;
81 -- Get the source search path of a Project file. If Recursive it True, get
82 -- all the source directories of the imported and modified project files
83 -- (recursively). If Recursive is False, just get the path for the source
84 -- directories of Project. Note: the resulting String may be empty if there
85 -- is no source directory in the project file.
87 function Ada_Objects_Path
88 (Project : Project_Id;
89 Including_Libraries : Boolean := True) return String_Access;
90 -- Get the ADA_OBJECTS_PATH of a Project file. For the first call, compute
91 -- it and cache it. When Including_Libraries is False, do not include the
92 -- object directories of the library projects, and do not cache the result.
94 procedure Set_Ada_Paths
95 (Project : Project_Id;
96 In_Tree : Project_Tree_Ref;
97 Including_Libraries : Boolean;
98 Include_Path : Boolean := True;
99 Objects_Path : Boolean := True);
100 -- Set the environment variables for additional project path files, after
101 -- creating the path files if necessary.
103 function File_Name_Of_Library_Unit_Body
104 (Name : String;
105 Project : Project_Id;
106 In_Tree : Project_Tree_Ref;
107 Main_Project_Only : Boolean := True;
108 Full_Path : Boolean := False) return String;
109 -- Returns the file name of a library unit, in canonical case. Name may or
110 -- may not have an extension (corresponding to the naming scheme of the
111 -- project). If there is no body with this name, but there is a spec, the
112 -- name of the spec is returned.
114 -- If Full_Path is False (the default), the simple file name is returned.
116 -- If Full_Path is True, the absolute path name is returned.
118 -- If neither a body nor a spec can be found, an empty string is returned.
119 -- If Main_Project_Only is True, the unit must be an immediate source of
120 -- Project. If it is False, it may be a source of one of its imported
121 -- projects.
123 function Project_Of
124 (Name : String;
125 Main_Project : Project_Id;
126 In_Tree : Project_Tree_Ref) return Project_Id;
127 -- Get the project of a source. The source file name may be truncated
128 -- (".adb" or ".ads" may be missing). If the source is in a project being
129 -- extended, return the ultimate extending project. If it is not a source
130 -- of any project, return No_Project.
132 procedure Get_Reference
133 (Source_File_Name : String;
134 In_Tree : Project_Tree_Ref;
135 Project : out Project_Id;
136 Path : out Path_Name_Type);
137 -- Returns the project of a source and its path in displayable form
139 generic
140 with procedure Action (Path : String);
141 procedure For_All_Source_Dirs
142 (Project : Project_Id;
143 In_Tree : Project_Tree_Ref);
144 -- Iterate through all the source directories of a project, including those
145 -- of imported or modified projects.
146 -- Only returns those directories that potentially contain Ada sources (ie
147 -- ignore projects that have no Ada sources
149 generic
150 with procedure Action (Path : String);
151 procedure For_All_Object_Dirs (Project : Project_Id);
152 -- Iterate through all the object directories of a project, including
153 -- those of imported or modified projects.
155 end Prj.Env;