end if;
if Lib_Dir.Default then
-
- -- If the extending project is a virtual project, we
- -- put the error message in the library project that
- -- is extended, rather than in the extending all project.
- -- Of course, we cannot put it in the virtual extending
- -- project, because it has no source.
-
- if Data.Virtual then
- Error_Msg_Name_1 := Extended_Data.Name;
-
- Error_Msg
- (Project,
- "library project % cannot be virtually extended",
- Extended_Data.Location);
-
- else
+ if not Data.Virtual then
Error_Msg
(Project,
"a project extending a library project must " &
with Prj.Dect;
with Prj.Err; use Prj.Err;
with Scans; use Scans;
+with Sdefault;
with Sinput; use Sinput;
with Sinput.P; use Sinput.P;
with Snames;
Virtual_Hash.Remove (Imported);
Declaration := Project_Declaration_Of (Imported);
end loop;
-
- elsif Virtual_Hash.Get (Imported) /= Empty_Node then
- Error_Msg
- ("this project cannot be imported directly",
- Location_Of (With_Clause));
end if;
end if;
-- Initialize Project_Path during package elaboration
if Prj_Path.all = "" then
- Project_Path := new String'(".");
+ Project_Path :=
+ new String'("." & Path_Separator & Sdefault.Search_Dir_Prefix.all &
+ ".." & Directory_Separator & ".." & Directory_Separator &
+ ".." & Directory_Separator & "gnat");
else
Project_Path := new String'("." & Path_Separator & Prj_Path.all);
end if;
(Project : Project_Id;
With_Name : Name_Id) return Project_Id
is
- Data : constant Project_Data := Projects.Table (Project);
- List : Project_List := Data.Imported_Projects;
+ Data : constant Project_Data := Projects.Table (Project);
+ List : Project_List := Data.Imported_Projects;
+ Result : Project_Id := No_Project;
+ Temp_Result : Project_Id := No_Project;
begin
- -- First check if it is the name of a extended project
+ -- First check if it is the name of an extended project
if Data.Extends /= No_Project
and then Projects.Table (Data.Extends).Name = With_Name
else
-- Then check the name of each imported project
- while List /= Empty_Project_List
- and then
- Projects.Table
- (Project_Lists.Table (List).Project).Name /= With_Name
+ while List /= Empty_Project_List loop
+ Result := Project_Lists.Table (List).Project;
+
+ -- If the project is directly imported, then returns its ID
+
+ if Projects.Table (Result).Name = With_Name then
+ return Result;
+ end if;
+
+ -- If a project extending the project is imported, then keep
+ -- this extending project as a possibility. It will be the
+ -- returned ID if the project is not imported directly.
+
+ declare
+ Proj : Project_Id := Projects.Table (Result).Extends;
+ begin
+ while Proj /= No_Project loop
+ if Projects.Table (Proj).Name = With_Name then
+ Temp_Result := Result;
+ exit;
+ end if;
+
+ Proj := Projects.Table (Proj).Extends;
+ end loop;
+ end;
- loop
List := Project_Lists.Table (List).Next;
end loop;
pragma Assert
- (List /= Empty_Project_List,
+ (Temp_Result /= No_Project,
"project not found");
- return Project_Lists.Table (List).Project;
+ return Temp_Result;
end if;
end Imported_Or_Extended_Project_From;