Commit 1ae44ba2 by Vincent Celier Committed by Arnaud Charlet

prj-nmsc.adb (Language_Independent_Check): Do not forbid virtual extension of library projects.

2004-10-26  Vincent Celier  <celier@gnat.com>

	* prj-nmsc.adb (Language_Independent_Check): Do not forbid virtual
	extension of library projects.

	* prj-part.adb: If env var ADA_PROJECT_PATH is not defined, project
	path defaults to ".:<prefix>/lib/gnat".
	(Parse): For an extending all project, allow direct import of a project
	that is virtually extended.

	* prj-proc.adb (Imported_Or_Extended_Project_From): If a project with
	the specified name is directly imported, return its ID. Otherwise, if
	an extension of this project is imported, return the ID of the
	extension.

From-SVN: r89662
parent 813fc7bf
......@@ -3522,22 +3522,7 @@ package body Prj.Nmsc is
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 " &
......
......@@ -33,6 +33,7 @@ with Prj.Com; use Prj.Com;
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;
......@@ -531,11 +532,6 @@ package body Prj.Part is
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;
......@@ -1708,7 +1704,10 @@ begin
-- 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;
......
......@@ -762,11 +762,13 @@ package body Prj.Proc is
(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
......@@ -776,20 +778,40 @@ package body Prj.Proc is
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment