Mains.Complete_Mains
(Root_Environment.Flags, Main_Project, Project_Tree);
---
---
--- Real_Main_Project : Project_Id := No_Project;
--- -- The project of the first main
---
--- Proj : Project_Id := No_Project;
--- -- The project of the current main
---
--- Real_Path : String_Access;
---
--- begin
--- Mains.Reset;
---
--- -- Check each main
---
--- loop
--- declare
--- Main : constant String := Mains.Next_Main;
--- -- The name specified on the command line may include directory
--- -- information.
---
--- File_Name : constant String := Base_Name (Main);
--- -- The simple file name of the current main
---
--- Lang : Language_Ptr;
---
--- begin
--- exit when Main = "";
---
--- -- Get the project of the current main
---
--- Proj := Prj.Env.Project_Of
--- (File_Name, Main_Project, Project_Tree);
---
--- -- Fail if the current main is not a source of a project
---
--- if Proj = No_Project then
--- Make_Failed
--- ("""" & Main & """ is not a source of any project");
---
--- else
--- -- If there is directory information, check that the source
--- -- exists and, if it does, that the path is the actual path
--- -- of a source of a project.
---
--- if Main /= File_Name then
--- Lang := Get_Language_From_Name (Main_Project, "ada");
---
--- Real_Path :=
--- Locate_Regular_File
--- (Main & Get_Name_String
--- (Lang.Config.Naming_Data.Body_Suffix),
--- "");
--- if Real_Path = null then
--- Real_Path :=
--- Locate_Regular_File
--- (Main & Get_Name_String
--- (Lang.Config.Naming_Data.Spec_Suffix),
--- "");
--- end if;
---
--- if Real_Path = null then
--- Real_Path := Locate_Regular_File (Main, "");
--- end if;
---
--- -- Fail if the file cannot be found
---
--- if Real_Path = null then
--- Make_Failed ("file """ & Main & """ does not exist");
--- end if;
---
--- declare
--- Project_Path : constant String :=
--- Prj.Env.File_Name_Of_Library_Unit_Body
--- (Name => File_Name,
--- Project => Main_Project,
--- In_Tree => Project_Tree,
--- Main_Project_Only => False,
--- Full_Path => True);
--- Normed_Path : constant String :=
--- Normalize_Pathname
--- (Real_Path.all,
--- Case_Sensitive => False);
--- Proj_Path : constant String :=
--- Normalize_Pathname
--- (Project_Path,
--- Case_Sensitive => False);
---
--- begin
--- Free (Real_Path);
---
--- -- Fail if it is not the correct path
---
--- if Normed_Path /= Proj_Path then
--- if Verbose_Mode then
--- Set_Standard_Error;
--- Write_Str (Normed_Path);
--- Write_Str (" /= ");
--- Write_Line (Proj_Path);
--- end if;
---
--- Make_Failed
--- ("""" & Main &
--- """ is not a source of any project");
--- end if;
--- end;
--- end if;
---
--- if not Unique_Compile then
---
--- -- Record the project, if it is the first main
---
--- if Real_Main_Project = No_Project then
--- Real_Main_Project := Proj;
---
--- elsif Proj /= Real_Main_Project then
---
--- -- Fail, as the current main is not a source of the
--- -- same project as the first main.
---
--- Make_Failed
--- ("""" & Main &
--- """ is not a source of project " &
--- Get_Name_String (Real_Main_Project.Name));
--- end if;
--- end if;
--- end if;
---
--- -- If -u and -U are not used, we may have mains that are
--- -- sources of a project that is not the one specified with
--- -- switch -P.
---
--- if not Unique_Compile then
--- Main_Project := Real_Main_Project;
--- end if;
--- end;
--- end loop;
end Check_Mains;
-- Start of processing for Gnatmake
for J in reverse Names.First .. Names.Last loop
declare
- File : Main_Info := Names.Table (J);
- Main_Id : File_Name_Type := File.File;
- Main : constant String :=
- Get_Name_String (Main_Id);
- Source : Prj.Source_Id := No_Source;
+ File : Main_Info := Names.Table (J);
+ Main_Id : File_Name_Type := File.File;
+ Main : constant String := Get_Name_String (Main_Id);
+ Source : Prj.Source_Id := No_Source;
+ Suffix : File_Name_Type;
+ Iter : Source_Iterator;
Is_Absolute : Boolean := False;
- Suffix : File_Name_Type;
- Iter : Source_Iterator;
begin
- if Base_Name (Main) /= Main then
+ if Base /= Main then
if Is_Absolute_Path (Main) then
- Main_Id := Create_Name (Base_Name (Main));
+ Main_Id := Create_Name (Base);
Is_Absolute := True;
else
- Fail_Program
- (Tree,
- "mains cannot include directory information ("""
- & Main & """)");
+ declare
+ Absolute : constant String :=
+ Normalize_Pathname
+ (Name => Main,
+ Directory => "",
+ Resolve_Links => False);
+ begin
+ File.File := Create_Name (Absolute);
+ Main_Id := Create_Name (Base);
+ end;
end if;
end if;
end if;
end if;
+ if Source = No_Source then
+ -- Still not found ? Maybe we have a unit name
+ declare
+ Unit : constant Unit_Index :=
+ Units_Htable.Get
+ (File.Tree.Units_HT, Name_Id (Main_Id));
+ begin
+ if Unit /= No_Unit_Index then
+ Source := Unit.File_Names (Impl);
+ if Source = No_Source then
+ Source := Unit.File_Names (Spec);
+ end if;
+ end if;
+ end;
+ end if;
+
if Source /= No_Source then
-- If we have found a multi-unit source file but