1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2007, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package implements services for Project-aware tools, mostly related
27 -- to the environment (configuration pragma files, path files, mapping files).
32 -- Called by Prj.Initialize to perform required initialization steps for
35 procedure Print_Sources (In_Tree : Project_Tree_Ref);
36 -- Output the list of sources, after Project files have been scanned
38 procedure Create_Mapping_File
39 (Project : Project_Id;
40 In_Tree : Project_Tree_Ref;
41 Name : out Path_Name_Type);
42 -- Create a temporary mapping file for project Project. For each unit
43 -- in the closure of immediate sources of Project, put the mapping of
44 -- its spec and or body to its file name and path name in this file.
46 procedure Create_Mapping_File
47 (Project : Project_Id;
49 In_Tree : Project_Tree_Ref;
50 Name : out Path_Name_Type);
51 -- Create a temporary mapping file for project Project. For each source or
52 -- template of Language in the of Project, put the mapping of its file
53 -- name and path name in this file.
55 procedure Set_Mapping_File_Initial_State_To_Empty;
56 -- When creating a mapping file, create an empty map. This case occurs
57 -- when run time source files are found in the project files.
59 procedure Create_Config_Pragmas_File
60 (For_Project : Project_Id;
61 Main_Project : Project_Id;
62 In_Tree : Project_Tree_Ref;
63 Include_Config_Files : Boolean := True);
64 -- If there needs to have SFN pragmas, either for non standard naming
65 -- schemes or for individual units, or (when Include_Config_Files is True)
66 -- if Global_Configuration_Pragmas has been specified in package gnatmake
67 -- of the main project, or if Local_Configuration_Pragmas has been
68 -- specified in package Compiler of the main project, build (if needed)
69 -- a temporary file that contains all configuration pragmas, and specify
70 -- the configuration pragmas file in the project data.
72 procedure Create_New_Path_File
73 (In_Tree : Project_Tree_Ref;
74 Path_FD : out File_Descriptor;
75 Path_Name : out Path_Name_Type);
76 -- Create a new temporary path file. Get the file name in Path_Name.
77 -- The name is normally obtained by increasing the number in
78 -- Temp_Path_File_Name by 1.
80 function Ada_Include_Path
81 (Project : Project_Id;
82 In_Tree : Project_Tree_Ref) return String_Access;
83 -- Get the ADA_INCLUDE_PATH of a Project file. For the first call, compute
86 function Ada_Include_Path
87 (Project : Project_Id;
88 In_Tree : Project_Tree_Ref;
89 Recursive : Boolean) return String;
90 -- Get the ADA_INCLUDE_PATH of a Project file. If Recursive it True,
91 -- get all the source directories of the imported and modified project
92 -- files (recursively). If Recursive is False, just get the path for the
93 -- source directories of Project. Note: the resulting String may be empty
94 -- if there is no source directory in the project file.
96 function Ada_Objects_Path
97 (Project : Project_Id;
98 In_Tree : Project_Tree_Ref;
99 Including_Libraries : Boolean := True) return String_Access;
100 -- Get the ADA_OBJECTS_PATH of a Project file. For the first call, compute
101 -- it and cache it. When Including_Libraries is False, do not include the
102 -- object directories of the library projects, and do not cache the result.
104 procedure Set_Ada_Paths
105 (Project : Project_Id;
106 In_Tree : Project_Tree_Ref;
107 Including_Libraries : Boolean);
108 -- Set the env vars for additional project path files, after
109 -- creating the path files if necessary.
111 procedure Delete_All_Path_Files (In_Tree : Project_Tree_Ref);
112 -- Delete all temporary path files that have been created by
113 -- calls to Set_Ada_Paths.
115 function Path_Name_Of_Library_Unit_Body
117 Project : Project_Id;
118 In_Tree : Project_Tree_Ref) return String;
119 -- Returns the Path of a library unit
121 function File_Name_Of_Library_Unit_Body
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.
132 -- If Full_Path is False (the default), the simple file name is returned.
134 -- If Full_Path is True, the absolute path name is returned.
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
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.
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
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
163 -- those of imported or modified projects.
166 with procedure Action (Path : String);
167 procedure For_All_Object_Dirs
168 (Project : Project_Id;
169 In_Tree : Project_Tree_Ref);
170 -- Iterate through all the object directories of a project, including
171 -- those of imported or modified projects.