- if Unit.File_Names (Body_Part).Name /= No_File
- and then Unit.File_Names (Body_Part).Project /=
- No_Project
- then
- Get_Name_String (Unit.Name);
- Name_Buffer (Name_Len + 1 .. Name_Len + 2) := "%b";
- Name_Len := Name_Len + 2;
- ALI_Unit := Name_Find;
- ALI_Name :=
- Lib_File_Name
- (Unit.File_Names (Body_Part).Display_Name);
- ALI_Project :=
- Unit.File_Names (Body_Part).Project;
-
- -- Otherwise, if there is a spec, put it
- -- in the mapping.
-
- elsif Unit.File_Names (Specification).Name /= No_File
- and then Unit.File_Names (Specification).Project /=
- No_Project
- then
- Get_Name_String (Unit.Name);
- Name_Buffer (Name_Len + 1 .. Name_Len + 2) := "%s";
- Name_Len := Name_Len + 2;
- ALI_Unit := Name_Find;
- ALI_Name :=
- Lib_File_Name
- (Unit.File_Names (Specification).Display_Name);
- ALI_Project :=
- Unit.File_Names (Specification).Project;
-
- else
- ALI_Name := No_File;
- end if;
-
- -- If we have something to put in the mapping
- -- then we do it now. However, if the project
- -- is extended, we don't put anything in the
- -- mapping file, because we do not know where
- -- the ALI file is: it might be in the ext-
- -- ended project obj dir as well as in the
- -- extending project obj dir.
-
- if ALI_Name /= No_File
- and then
- Project_Tree.Projects.Table
- (ALI_Project).Extended_By = No_Project
- and then
- Project_Tree.Projects.Table
- (ALI_Project).Extends = No_Project
- then
- -- First check if the ALI file exists. If it does not,
- -- do not put the unit in the mapping file.
-
- declare
- ALI : constant String :=
- Get_Name_String (ALI_Name);
- PD : Project_Data renames
- Project_Tree.Projects.Table (ALI_Project);
-
- begin
- -- For library projects, use the library directory,
- -- for other projects, use the object directory.
-
- if PD.Library then
- Get_Name_String (PD.Library_Dir.Name);
- else
- Get_Name_String (PD.Object_Directory.Name);
- end if;
-
- if Name_Buffer (Name_Len) /=
- Directory_Separator
- then
- Name_Len := Name_Len + 1;
- Name_Buffer (Name_Len) :=
- Directory_Separator;
- end if;
-
- Name_Buffer
- (Name_Len + 1 ..
- Name_Len + ALI'Length) := ALI;
- Name_Len :=
- Name_Len + ALI'Length + 1;
- Name_Buffer (Name_Len) := ASCII.LF;
-
- declare
- ALI_Path_Name : constant String :=
- Name_Buffer (1 .. Name_Len);
-
- begin
- if Is_Regular_File
- (ALI_Path_Name (1 .. ALI_Path_Name'Last - 1))
- then
-
- -- First line is the unit name
-
- Get_Name_String (ALI_Unit);
- Name_Len := Name_Len + 1;
- Name_Buffer (Name_Len) := ASCII.LF;
- Bytes :=
- Write
- (Mapping_FD,
- Name_Buffer (1)'Address,
- Name_Len);
- OK := Bytes = Name_Len;
-
- exit when not OK;
-
- -- Second line it the ALI file name
-
- Get_Name_String (ALI_Name);
- Name_Len := Name_Len + 1;
- Name_Buffer (Name_Len) := ASCII.LF;
- Bytes :=
- Write
- (Mapping_FD,
- Name_Buffer (1)'Address,
- Name_Len);
- OK := Bytes = Name_Len;
-
- exit when not OK;
-
- -- Third line it the ALI path name
-
- Bytes :=
- Write
- (Mapping_FD,
- ALI_Path_Name (1)'Address,
- ALI_Path_Name'Length);
- OK := Bytes = ALI_Path_Name'Length;
-
- -- If OK is False, it means we were unable
- -- to write a line. No point in continuing
- -- with the other units.
-
- exit when not OK;
- end if;
- end;
- end;
- end if;
- end if;
- end;
- end loop;
-
- Close (Mapping_FD, Status);
-
- OK := OK and Status;
-
- -- If the creation of the mapping file was successful,
- -- we add the switch to the arguments of gnatbind.
-
- if OK then
- Last_Arg := Last_Arg + 1;
- Args (Last_Arg) :=
- new String'("-F=" & Get_Name_String (Mapping_Path));
- end if;
- end if;
- end Create_Binder_Mapping_File;
-
- -- Start of processing for Gnatmake
-
- -- This body is very long, should be broken down ???
-
- begin
- Install_Int_Handler (Sigint_Intercepted'Access);
-
- Do_Compile_Step := True;
- Do_Bind_Step := True;
- Do_Link_Step := True;
-
- Obsoleted.Reset;
-
- Make.Initialize;
-
- Bind_Shared := No_Shared_Switch'Access;
- Link_With_Shared_Libgcc := No_Shared_Libgcc_Switch'Access;
-
- Failed_Links.Set_Last (0);
- Successful_Links.Set_Last (0);
-
- -- Special case when switch -B was specified
-
- if Build_Bind_And_Link_Full_Project then
-
- -- When switch -B is specified, there must be a project file
-
- if Main_Project = No_Project then
- Make_Failed ("-B cannot be used without a project file");
-
- -- No main program may be specified on the command line