Commit d579fabd by Pascal Obry Committed by Arnaud Charlet

makegpr.adb (Add_Archive_Path): Use untouched object and library dirs and library name.

2007-04-20  Pascal Obry  <obry@adacore.com>
	    Vincent Celier  <celier@adacore.com>

	* makegpr.adb (Add_Archive_Path): Use untouched object and library
	dirs and library name.
	(Build_Global_Archive): Idem. Minor code clean-up. Removes duplicate
	comments.
	(Build_Library): Idem.
	(Compile_Individual_Sources): Idem.
	(Compile_Link_With_Gnatmake): Idem.
	(Compile_Sources): Idem.
	(Get_Imported_Directories): Idem.
	(Link_Executables): Idem. Same change for the executable dir.
	(Check_Compilation_Needed): C_Source_Path new variable containing
	the canonical form of Source_Path to check against the source names
	in the dependency file.
	(Build_Global_Archive, Compile_Individual_Sources, Compile_Sources): In
	verbose mode, display the name of the object directory we're changing
	to.
	(Saved_Switches): New name of table X_Switches
	(Scan_Arg): Recognize new switch -aP and save in table Saved_Switches
	(Usage): New line for switch -aP
	(Get_Imported_Directories.Add): Make sure that Add_Arg is True before
	testing if a directory should be added to the search path.

From-SVN: r125476
parent e08b38f5
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2004-2006, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2007, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -24,22 +24,9 @@ ...@@ -24,22 +24,9 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Csets; with Csets;
with Gnatvsn; with Gnatvsn;
with Hostparm; use Hostparm; with Hostparm; use Hostparm;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.Dynamic_Tables;
with GNAT.Expect; use GNAT.Expect;
with GNAT.HTable;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Regpat; use GNAT.Regpat;
with Makeutl; use Makeutl; with Makeutl; use Makeutl;
with MLib.Tgt; use MLib.Tgt; with MLib.Tgt; use MLib.Tgt;
with Namet; use Namet; with Namet; use Namet;
...@@ -47,14 +34,28 @@ with Output; use Output; ...@@ -47,14 +34,28 @@ with Output; use Output;
with Opt; use Opt; with Opt; use Opt;
with Osint; use Osint; with Osint; use Osint;
with Prj; use Prj; with Prj; use Prj;
with Prj.Ext; use Prj.Ext;
with Prj.Pars; with Prj.Pars;
with Prj.Util; use Prj.Util; with Prj.Util; use Prj.Util;
with Snames; use Snames; with Snames; use Snames;
with System;
with System.Case_Util; use System.Case_Util;
with Table; with Table;
with Types; use Types; with Types; use Types;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.Dynamic_Tables;
with GNAT.Expect; use GNAT.Expect;
with GNAT.HTable;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Regpat; use GNAT.Regpat;
with System;
with System.Case_Util; use System.Case_Util;
package body Makegpr is package body Makegpr is
On_Windows : constant Boolean := Directory_Separator = '\'; On_Windows : constant Boolean := Directory_Separator = '\';
...@@ -231,18 +232,18 @@ package body Makegpr is ...@@ -231,18 +232,18 @@ package body Makegpr is
(Header_Num => Header_Num, (Header_Num => Header_Num,
Element => Boolean, Element => Boolean,
No_Element => False, No_Element => False,
Key => Name_Id, Key => File_Name_Type,
Hash => Hash, Hash => Hash,
Equal => "="); Equal => "=");
package X_Switches is new Table.Table package Saved_Switches is new Table.Table
(Table_Component_Type => String_Access, (Table_Component_Type => String_Access,
Table_Index_Type => Integer, Table_Index_Type => Integer,
Table_Low_Bound => 1, Table_Low_Bound => 1,
Table_Initial => 10, Table_Initial => 10,
Table_Increment => 100, Table_Increment => 100,
Table_Name => "Makegpr.X_Switches"); Table_Name => "Makegpr.Saved_Switches");
-- Table to store the -X switches to be passed to gnatmake -- Table to store the switches to be passed to gnatmake
Initial_Argument_Count : constant Positive := 20; Initial_Argument_Count : constant Positive := 20;
type Boolean_Array is array (Positive range <>) of Boolean; type Boolean_Array is array (Positive range <>) of Boolean;
...@@ -346,6 +347,11 @@ package body Makegpr is ...@@ -346,6 +347,11 @@ package body Makegpr is
Path_Option : String_Access; Path_Option : String_Access;
-- The path option switch, when supported -- The path option switch, when supported
Project_Of_Current_Object_Directory : Project_Id := No_Project;
-- The object directory of the project for the last compilation. Avoid
-- calling Change_Dir if the current working directory is already this
-- directory.
package Lib_Path is new Table.Table package Lib_Path is new Table.Table
(Table_Component_Type => Character, (Table_Component_Type => Character,
Table_Index_Type => Integer, Table_Index_Type => Integer,
...@@ -385,7 +391,7 @@ package body Makegpr is ...@@ -385,7 +391,7 @@ package body Makegpr is
(Data : Project_Data; (Data : Project_Data;
Proc : Processor; Proc : Processor;
Language : Language_Index; Language : Language_Index;
File_Name : Name_Id); File_Name : File_Name_Type);
-- Add to Arguments the switches, if any, for a source (attribute Switches) -- Add to Arguments the switches, if any, for a source (attribute Switches)
-- or language (attribute Default_Switches), coming from package Compiler -- or language (attribute Default_Switches), coming from package Compiler
-- or Linker (depending on Proc) of a specified project file. -- or Linker (depending on Proc) of a specified project file.
...@@ -474,7 +480,7 @@ package body Makegpr is ...@@ -474,7 +480,7 @@ package body Makegpr is
-- arguments. -- arguments.
function Is_Included_In_Global_Archive function Is_Included_In_Global_Archive
(Object_Name : Name_Id; (Object_Name : File_Name_Type;
Project : Project_Id) return Boolean; Project : Project_Id) return Boolean;
-- Return True if the object Object_Name is not overridden by a source -- Return True if the object Object_Name is not overridden by a source
-- in a project extending project Project. -- in a project extending project Project.
...@@ -544,7 +550,7 @@ package body Makegpr is ...@@ -544,7 +550,7 @@ package body Makegpr is
if not For_Gnatmake then if not For_Gnatmake then
if Data.Library_Kind = Static then if Data.Library_Kind = Static then
Add_Argument Add_Argument
(Get_Name_String (Data.Library_Dir) & (Get_Name_String (Data.Display_Library_Dir) &
Directory_Separator & Directory_Separator &
"lib" & Get_Name_String (Data.Library_Name) & "lib" & Get_Name_String (Data.Library_Name) &
'.' & Archive_Ext, '.' & Archive_Ext,
...@@ -558,7 +564,7 @@ package body Makegpr is ...@@ -558,7 +564,7 @@ package body Makegpr is
("-l" & Get_Name_String (Data.Library_Name), ("-l" & Get_Name_String (Data.Library_Name),
Verbose_Mode); Verbose_Mode);
Get_Name_String (Data.Library_Dir); Get_Name_String (Data.Display_Library_Dir);
Add_Argument Add_Argument
("-L" & Name_Buffer (1 .. Name_Len), ("-L" & Name_Buffer (1 .. Name_Len),
...@@ -610,10 +616,10 @@ package body Makegpr is ...@@ -610,10 +616,10 @@ package body Makegpr is
elsif Project = Main_Project and then Global_Archive_Exists then elsif Project = Main_Project and then Global_Archive_Exists then
Add_Argument Add_Argument
(Get_Name_String (Data.Object_Directory) & (Get_Name_String (Data.Display_Object_Dir) &
Directory_Separator & Directory_Separator &
"lib" & Get_Name_String (Data.Name) & "lib" & Get_Name_String (Data.Display_Name)
'.' & Archive_Ext, & '.' & Archive_Ext,
Verbose_Mode); Verbose_Mode);
end if; end if;
end Add_Archive_Path; end Add_Archive_Path;
...@@ -929,7 +935,7 @@ package body Makegpr is ...@@ -929,7 +935,7 @@ package body Makegpr is
(Data : Project_Data; (Data : Project_Data;
Proc : Processor; Proc : Processor;
Language : Language_Index; Language : Language_Index;
File_Name : Name_Id) File_Name : File_Name_Type)
is is
Switches : Variable_Value; Switches : Variable_Value;
-- The switches, if any, for the file/language -- The switches, if any, for the file/language
...@@ -961,6 +967,7 @@ package body Makegpr is ...@@ -961,6 +967,7 @@ package body Makegpr is
end case; end case;
if Pkg /= No_Package then if Pkg /= No_Package then
-- Get the Switches ("file name"), if they exist -- Get the Switches ("file name"), if they exist
Switches_Array := Prj.Util.Value_Of Switches_Array := Prj.Util.Value_Of
...@@ -971,7 +978,7 @@ package body Makegpr is ...@@ -971,7 +978,7 @@ package body Makegpr is
Switches := Switches :=
Prj.Util.Value_Of Prj.Util.Value_Of
(Index => File_Name, (Index => Name_Id (File_Name),
Src_Index => 0, Src_Index => 0,
In_Array => Switches_Array, In_Array => Switches_Array,
In_Tree => Project_Tree); In_Tree => Project_Tree);
...@@ -1025,39 +1032,51 @@ package body Makegpr is ...@@ -1025,39 +1032,51 @@ package body Makegpr is
-------------------------- --------------------------
procedure Build_Global_Archive is procedure Build_Global_Archive is
Data : Project_Data := Data : Project_Data := Project_Tree.Projects.Table (Main_Project);
Project_Tree.Projects.Table (Main_Project);
Source_Id : Other_Source_Id; Source_Id : Other_Source_Id;
S_Id : Other_Source_Id; S_Id : Other_Source_Id;
Source : Other_Source; Source : Other_Source;
Success : Boolean; Success : Boolean;
Archive_Name : constant String := Archive_Name : constant String :=
"lib" & Get_Name_String (Data.Name) & '.' & Archive_Ext; "lib"
& Get_Name_String (Data.Display_Name)
& '.'
& Archive_Ext;
-- The name of the archive file for this project -- The name of the archive file for this project
Archive_Dep_Name : constant String := Archive_Dep_Name : constant String :=
"lib" & Get_Name_String (Data.Name) & ".deps"; "lib"
& Get_Name_String (Data.Display_Name)
& ".deps";
-- The name of the archive dependency file for this project -- The name of the archive dependency file for this project
Need_To_Rebuild : Boolean := Need_To_Rebuild_Global_Archive; Need_To_Rebuild : Boolean := Need_To_Rebuild_Global_Archive;
-- When True, archive will be rebuilt -- When True, archive will be rebuilt
File : Prj.Util.Text_File; File : Prj.Util.Text_File;
Object_Path : Path_Name_Type;
Object_Path : Name_Id;
Time_Stamp : Time_Stamp_Type; Time_Stamp : Time_Stamp_Type;
Saved_Last_Argument : Natural; Saved_Last_Argument : Natural;
First_Object : Natural; First_Object : Natural;
Discard : Boolean; Discard : Boolean;
begin begin
Check_Archive_Builder; Check_Archive_Builder;
if Project_Of_Current_Object_Directory /= Main_Project then
Project_Of_Current_Object_Directory := Main_Project;
Change_Dir (Get_Name_String (Data.Object_Directory)); Change_Dir (Get_Name_String (Data.Object_Directory));
if Verbose_Mode then
Write_Str ("Changing to object directory of """);
Write_Name (Data.Display_Name);
Write_Str (""": """);
Write_Name (Data.Display_Object_Dir);
Write_Line ("""");
end if;
end if;
if not Need_To_Rebuild then if not Need_To_Rebuild then
if Verbose_Mode then if Verbose_Mode then
Write_Str (" Checking "); Write_Str (" Checking ");
...@@ -1309,9 +1328,8 @@ package body Makegpr is ...@@ -1309,9 +1328,8 @@ package body Makegpr is
Arguments (1 .. Last_Argument), Arguments (1 .. Last_Argument),
Success); Success);
exit when not Success; exit when not Success
or else Last_Argument = Saved_Last_Argument;
exit when Last_Argument = Saved_Last_Argument;
Arguments (1) := r; Arguments (1) := r;
Arguments (3 .. Saved_Last_Argument - Last_Argument + 2) := Arguments (3 .. Saved_Last_Argument - Last_Argument + 2) :=
...@@ -1324,9 +1342,6 @@ package body Makegpr is ...@@ -1324,9 +1342,6 @@ package body Makegpr is
if Success then if Success then
-- If the archive was built, run the archive indexer (ranlib),
-- if there is one.
if Archive_Indexer_Path /= null then if Archive_Indexer_Path /= null then
Last_Argument := 0; Last_Argument := 0;
Add_Argument (Archive_Name, True); Add_Argument (Archive_Name, True);
...@@ -1349,7 +1364,7 @@ package body Makegpr is ...@@ -1349,7 +1364,7 @@ package body Makegpr is
Report_Error Report_Error
("running" & Archive_Indexer & " for project """, ("running" & Archive_Indexer & " for project """,
Get_Name_String (Data.Name), Get_Name_String (Data.Display_Name),
""" failed"); """ failed");
return; return;
end if; end if;
...@@ -1371,7 +1386,7 @@ package body Makegpr is ...@@ -1371,7 +1386,7 @@ package body Makegpr is
Report_Error Report_Error
("building archive for project """, ("building archive for project """,
Get_Name_String (Data.Name), Get_Name_String (Data.Display_Name),
""" failed"); """ failed");
end if; end if;
end if; end if;
...@@ -1389,11 +1404,13 @@ package body Makegpr is ...@@ -1389,11 +1404,13 @@ package body Makegpr is
Source : Other_Source; Source : Other_Source;
Archive_Name : constant String := Archive_Name : constant String :=
"lib" & Get_Name_String (Data.Name) & '.' & Archive_Ext; "lib" & Get_Name_String (Data.Display_Name)
& '.' & Archive_Ext;
-- The name of the archive file for this project -- The name of the archive file for this project
Archive_Dep_Name : constant String := Archive_Dep_Name : constant String :=
"lib" & Get_Name_String (Data.Name) & ".deps"; "lib" & Get_Name_String (Data.Display_Name)
& ".deps";
-- The name of the archive dependency file for this project -- The name of the archive dependency file for this project
Need_To_Rebuild : Boolean := Unconditionally; Need_To_Rebuild : Boolean := Unconditionally;
...@@ -1401,11 +1418,12 @@ package body Makegpr is ...@@ -1401,11 +1418,12 @@ package body Makegpr is
File : Prj.Util.Text_File; File : Prj.Util.Text_File;
Object_Name : Name_Id; Object_Name : File_Name_Type;
Time_Stamp : Time_Stamp_Type; Time_Stamp : Time_Stamp_Type;
Driver_Name : Name_Id := No_Name; Driver_Name : Name_Id := No_Name;
Lib_Opts : Argument_List_Access := No_Argument'Access; Lib_Opts : Argument_List_Access := No_Argument'Access;
begin begin
Check_Archive_Builder; Check_Archive_Builder;
...@@ -1621,7 +1639,7 @@ package body Makegpr is ...@@ -1621,7 +1639,7 @@ package body Makegpr is
(Ofiles => Arguments (1 .. Last_Argument), (Ofiles => Arguments (1 .. Last_Argument),
Afiles => No_Argument, Afiles => No_Argument,
Output_File => Get_Name_String (Data.Library_Name), Output_File => Get_Name_String (Data.Library_Name),
Output_Dir => Get_Name_String (Data.Library_Dir)); Output_Dir => Get_Name_String (Data.Display_Library_Dir));
else else
-- Link with g++ if C++ is one of the languages, otherwise -- Link with g++ if C++ is one of the languages, otherwise
...@@ -1800,6 +1818,7 @@ package body Makegpr is ...@@ -1800,6 +1818,7 @@ package body Makegpr is
Source_Path : constant String := Get_Name_String (Source.Path_Name); Source_Path : constant String := Get_Name_String (Source.Path_Name);
Object_Name : constant String := Get_Name_String (Source.Object_Name); Object_Name : constant String := Get_Name_String (Source.Object_Name);
Dep_Name : constant String := Get_Name_String (Source.Dep_Name); Dep_Name : constant String := Get_Name_String (Source.Dep_Name);
C_Source_Path : String := Source_Path;
Source_In_Dependencies : Boolean := False; Source_In_Dependencies : Boolean := False;
-- Set True if source was found in dependency file of its object file -- Set True if source was found in dependency file of its object file
...@@ -1812,6 +1831,8 @@ package body Makegpr is ...@@ -1812,6 +1831,8 @@ package body Makegpr is
-- Set to True at the end of the first Big_Loop -- Set to True at the end of the first Big_Loop
begin begin
Canonical_Case_File_Name (C_Source_Path);
-- Assume the worst, so that statement "return;" may be used if there -- Assume the worst, so that statement "return;" may be used if there
-- is any problem. -- is any problem.
...@@ -2002,9 +2023,9 @@ package body Makegpr is ...@@ -2002,9 +2023,9 @@ package body Makegpr is
-- line, the next character is part of the path -- line, the next character is part of the path
-- name, even if it is a space. -- name, even if it is a space.
if On_Windows and then if On_Windows
Line (Finish + 1) /= '\' and then and then Line (Finish + 1) /= '\'
Line (Finish + 1) /= ' ' and then Line (Finish + 1) /= ' '
then then
Finish := Finish + 1; Finish := Finish + 1;
...@@ -2039,13 +2060,13 @@ package body Makegpr is ...@@ -2039,13 +2060,13 @@ package body Makegpr is
-- If it is original source, set -- If it is original source, set
-- Source_In_Dependencies. -- Source_In_Dependencies.
if Src_Name = Source_Path then if Src_Name = C_Source_Path then
Source_In_Dependencies := True; Source_In_Dependencies := True;
end if; end if;
Name_Len := 0; Name_Len := 0;
Add_Str_To_Name_Buffer (Src_Name); Add_Str_To_Name_Buffer (Src_Name);
Src_TS := File_Stamp (Name_Find); Src_TS := File_Stamp (File_Name_Type'(Name_Find));
-- If the source does not exist, we need to recompile -- If the source does not exist, we need to recompile
...@@ -2404,7 +2425,7 @@ package body Makegpr is ...@@ -2404,7 +2425,7 @@ package body Makegpr is
Project_Tree.Projects.Table (Main_Project); Project_Tree.Projects.Table (Main_Project);
Source_Id : Other_Source_Id; Source_Id : Other_Source_Id;
Source : Other_Source; Source : Other_Source;
Source_Name : Name_Id; Source_Name : File_Name_Type;
Project_Name : String := Get_Name_String (Data.Name); Project_Name : String := Get_Name_String (Data.Name);
Dummy : Boolean := False; Dummy : Boolean := False;
...@@ -2421,8 +2442,19 @@ package body Makegpr is ...@@ -2421,8 +2442,19 @@ package body Makegpr is
-- Compilation will occur in the object directory -- Compilation will occur in the object directory
if Project_Of_Current_Object_Directory /= Main_Project then
Project_Of_Current_Object_Directory := Main_Project;
Change_Dir (Get_Name_String (Data.Object_Directory)); Change_Dir (Get_Name_String (Data.Object_Directory));
if Verbose_Mode then
Write_Str ("Changing to object directory of """);
Write_Name (Data.Name);
Write_Str (""": """);
Write_Name (Data.Display_Object_Dir);
Write_Line ("""");
end if;
end if;
if not Data.Other_Sources_Present then if not Data.Other_Sources_Present then
if Ada_Is_A_Language then if Ada_Is_A_Language then
Mains.Reset; Mains.Reset;
...@@ -2438,8 +2470,7 @@ package body Makegpr is ...@@ -2438,8 +2470,7 @@ package body Makegpr is
end loop; end loop;
else else
Osint.Fail Osint.Fail ("project ", Project_Name, " contains no source");
("project ", Project_Name, " contains no source");
end if; end if;
else else
...@@ -2520,12 +2551,12 @@ package body Makegpr is ...@@ -2520,12 +2551,12 @@ package body Makegpr is
-- Specify the project file -- Specify the project file
Add_Argument (Dash_P, True); Add_Argument (Dash_P, True);
Add_Argument (Get_Name_String (Data.Path_Name), True); Add_Argument (Get_Name_String (Data.Display_Path_Name), True);
-- Add the -X switches, if any -- Add the saved switches, if any
for Index in 1 .. X_Switches.Last loop for Index in 1 .. Saved_Switches.Last loop
Add_Argument (X_Switches.Table (Index), True); Add_Argument (Saved_Switches.Table (Index), True);
end loop; end loop;
-- If Mains_Specified is True, find the mains in package Mains -- If Mains_Specified is True, find the mains in package Mains
...@@ -2652,7 +2683,6 @@ package body Makegpr is ...@@ -2652,7 +2683,6 @@ package body Makegpr is
Compiler_Names (Ada_Language_Index).all, Compiler_Names (Ada_Language_Index).all,
" failed"); " failed");
end if; end if;
end Compile_Link_With_Gnatmake; end Compile_Link_With_Gnatmake;
--------------------- ---------------------
...@@ -2720,8 +2750,19 @@ package body Makegpr is ...@@ -2720,8 +2750,19 @@ package body Makegpr is
-- Compilation will occur in the object directory -- Compilation will occur in the object directory
if Project_Of_Current_Object_Directory /= Project then
Project_Of_Current_Object_Directory := Project;
Change_Dir (Get_Name_String (Data.Object_Directory)); Change_Dir (Get_Name_String (Data.Object_Directory));
if Verbose_Mode then
Write_Str ("Changing to object directory of """);
Write_Name (Data.Display_Name);
Write_Str (""": """);
Write_Name (Data.Display_Object_Dir);
Write_Line ("""");
end if;
end if;
-- Process each source one by one -- Process each source one by one
Source_Id := Data.First_Other_Source; Source_Id := Data.First_Other_Source;
...@@ -2795,7 +2836,9 @@ package body Makegpr is ...@@ -2795,7 +2836,9 @@ package body Makegpr is
Write_Eol; Write_Eol;
Write_Str ("GPRMAKE "); Write_Str ("GPRMAKE ");
Write_Str (Gnatvsn.Gnat_Version_String); Write_Str (Gnatvsn.Gnat_Version_String);
Write_Str (" Copyright 2004 Free Software Foundation, Inc."); Write_Str (" Copyright 2004-");
Write_Str (Gnatvsn.Current_Year);
Write_Str (" Free Software Foundation, Inc.");
Write_Eol; Write_Eol;
end if; end if;
end Copyright; end Copyright;
...@@ -3059,7 +3102,7 @@ package body Makegpr is ...@@ -3059,7 +3102,7 @@ package body Makegpr is
Element := Project_Tree.String_Elements.Table (Element_Id); Element := Project_Tree.String_Elements.Table (Element_Id);
if Element.Value /= No_Name then if Element.Value /= No_Name then
Get_Name_String (Element.Value); Get_Name_String (Element.Display_Value);
if Name_Len > 0 then if Name_Len > 0 then
...@@ -3079,6 +3122,8 @@ package body Makegpr is ...@@ -3079,6 +3122,8 @@ package body Makegpr is
-- Check if directory is already in the list. If it is, -- Check if directory is already in the list. If it is,
-- no need to put it there again. -- no need to put it there again.
Add_Arg := True;
for Index in 1 .. Last_Argument loop for Index in 1 .. Last_Argument loop
if Arguments (Index).all = Arg then if Arguments (Index).all = Arg then
Add_Arg := False; Add_Arg := False;
...@@ -3139,8 +3184,7 @@ package body Makegpr is ...@@ -3139,8 +3184,7 @@ package body Makegpr is
Imported := Data.Imported_Projects; Imported := Data.Imported_Projects;
while Imported /= Empty_Project_List loop while Imported /= Empty_Project_List loop
Recursive_Get_Dirs Recursive_Get_Dirs
(Project_Tree.Project_Lists.Table (Project_Tree.Project_Lists.Table (Imported).Project);
(Imported).Project);
Imported := Imported :=
Project_Tree.Project_Lists.Table (Imported).Next; Project_Tree.Project_Lists.Table (Imported).Next;
end loop; end loop;
...@@ -3211,7 +3255,7 @@ package body Makegpr is ...@@ -3211,7 +3255,7 @@ package body Makegpr is
if Verbose_Mode then if Verbose_Mode then
Write_Eol; Write_Eol;
Write_Str ("Parsing Project File """); Write_Str ("Parsing project file """);
Write_Str (Project_File_Name.all); Write_Str (Project_File_Name.all);
Write_Str ("""."); Write_Str (""".");
Write_Eol; Write_Eol;
...@@ -3233,7 +3277,7 @@ package body Makegpr is ...@@ -3233,7 +3277,7 @@ package body Makegpr is
if Verbose_Mode then if Verbose_Mode then
Write_Eol; Write_Eol;
Write_Str ("Parsing of Project File """); Write_Str ("Parsing of project file """);
Write_Str (Project_File_Name.all); Write_Str (Project_File_Name.all);
Write_Str (""" is finished."); Write_Str (""" is finished.");
Write_Eol; Write_Eol;
...@@ -3285,7 +3329,7 @@ package body Makegpr is ...@@ -3285,7 +3329,7 @@ package body Makegpr is
if not Compile_Only if not Compile_Only
and then not Data.Library and then not Data.Library
and then Data.Object_Directory /= No_Name and then Data.Object_Directory /= No_Path
then then
Build_Global_Archive; Build_Global_Archive;
Link_Executables; Link_Executables;
...@@ -3368,9 +3412,9 @@ package body Makegpr is ...@@ -3368,9 +3412,9 @@ package body Makegpr is
Add_Str_To_Name_Buffer ("compiler_command"); Add_Str_To_Name_Buffer ("compiler_command");
Name_Compiler_Command := Name_Find; Name_Compiler_Command := Name_Find;
-- Make sure the -X switch table is empty -- Make sure the Saved_Switches table is empty
X_Switches.Set_Last (0); Saved_Switches.Set_Last (0);
-- Get the command line arguments -- Get the command line arguments
...@@ -3407,7 +3451,7 @@ package body Makegpr is ...@@ -3407,7 +3451,7 @@ package body Makegpr is
----------------------------------- -----------------------------------
function Is_Included_In_Global_Archive function Is_Included_In_Global_Archive
(Object_Name : Name_Id; (Object_Name : File_Name_Type;
Project : Project_Id) return Boolean Project : Project_Id) return Boolean
is is
Data : Project_Data := Project_Tree.Projects.Table (Project); Data : Project_Data := Project_Tree.Projects.Table (Project);
...@@ -3444,7 +3488,8 @@ package body Makegpr is ...@@ -3444,7 +3488,8 @@ package body Makegpr is
Mains_Specified : constant Boolean := Mains.Number_Of_Mains /= 0; Mains_Specified : constant Boolean := Mains.Number_Of_Mains /= 0;
-- True if main sources were specified on the command line -- True if main sources were specified on the command line
Object_Dir : constant String := Get_Name_String (Data.Object_Directory); Object_Dir : constant String :=
Get_Name_String (Data.Display_Object_Dir);
-- Path of the object directory of the main project -- Path of the object directory of the main project
Source_Id : Other_Source_Id; Source_Id : Other_Source_Id;
...@@ -3472,7 +3517,7 @@ package body Makegpr is ...@@ -3472,7 +3517,7 @@ package body Makegpr is
procedure Link_Foreign procedure Link_Foreign
(Main : String; (Main : String;
Main_Id : Name_Id; Main_Id : File_Name_Type;
Source : Other_Source); Source : Other_Source);
-- Link a non-Ada main, when there is no Ada code -- Link a non-Ada main, when there is no Ada code
...@@ -3506,19 +3551,15 @@ package body Makegpr is ...@@ -3506,19 +3551,15 @@ package body Makegpr is
if Data.Other_Sources_Present then if Data.Other_Sources_Present then
declare declare
Archive_Path : constant String := Archive_Path : constant String := Get_Name_String
Get_Name_String (Prj_Data.Display_Object_Dir) & Directory_Separator
(Prj_Data.Object_Directory) & & "lib" & Get_Name_String (Prj_Data.Display_Name)
Directory_Separator & & '.' & Archive_Ext;
"lib" &
Get_Name_String (Prj_Data.Name) &
'.' & Archive_Ext;
Archive_TS : Time_Stamp_Type; Archive_TS : Time_Stamp_Type;
begin begin
Name_Len := 0; Name_Len := 0;
Add_Str_To_Name_Buffer Add_Str_To_Name_Buffer (Archive_Path);
(Archive_Path); Archive_TS := File_Stamp (File_Name_Type'(Name_Find));
Archive_TS := File_Stamp (Name_Find);
-- If the archive is later than the -- If the archive is later than the
-- executable, we need to relink. -- executable, we need to relink.
...@@ -3561,7 +3602,7 @@ package body Makegpr is ...@@ -3561,7 +3602,7 @@ package body Makegpr is
procedure Link_Foreign procedure Link_Foreign
(Main : String; (Main : String;
Main_Id : Name_Id; Main_Id : File_Name_Type;
Source : Other_Source) Source : Other_Source)
is is
Executable_Name : constant String := Executable_Name : constant String :=
...@@ -3576,9 +3617,8 @@ package body Makegpr is ...@@ -3576,9 +3617,8 @@ package body Makegpr is
Executable_Path : constant String := Executable_Path : constant String :=
Get_Name_String Get_Name_String
(Data.Exec_Directory) & (Data.Display_Exec_Dir) &
Directory_Separator & Directory_Separator & Executable_Name;
Executable_Name;
-- Path name of the executable -- Path name of the executable
Exec_Time_Stamp : Time_Stamp_Type; Exec_Time_Stamp : Time_Stamp_Type;
...@@ -3594,7 +3634,7 @@ package body Makegpr is ...@@ -3594,7 +3634,7 @@ package body Makegpr is
Name_Len := 0; Name_Len := 0;
Add_Str_To_Name_Buffer (Executable_Path); Add_Str_To_Name_Buffer (Executable_Path);
Exec_Time_Stamp := File_Stamp (Name_Find); Exec_Time_Stamp := File_Stamp (File_Name_Type'(Name_Find));
if Verbose_Mode then if Verbose_Mode then
Write_Str (" Checking executable "); Write_Str (" Checking executable ");
...@@ -3635,7 +3675,7 @@ package body Makegpr is ...@@ -3635,7 +3675,7 @@ package body Makegpr is
Add_Argument (Dash_o, True); Add_Argument (Dash_o, True);
Add_Argument Add_Argument
(Get_Name_String (Data.Exec_Directory) & (Get_Name_String (Data.Display_Exec_Dir) &
Directory_Separator & Directory_Separator &
Get_Name_String Get_Name_String
(Executable_Of (Executable_Of
...@@ -3802,7 +3842,7 @@ package body Makegpr is ...@@ -3802,7 +3842,7 @@ package body Makegpr is
loop loop
declare declare
Main : constant String := Mains.Next_Main; Main : constant String := Mains.Next_Main;
Main_Id : Name_Id; Main_Id : File_Name_Type;
begin begin
exit when Main'Length = 0; exit when Main'Length = 0;
...@@ -3950,7 +3990,7 @@ package body Makegpr is ...@@ -3950,7 +3990,7 @@ package body Makegpr is
loop loop
declare declare
Main : constant String := Mains.Next_Main; Main : constant String := Mains.Next_Main;
Main_Id : Name_Id; Main_Id : File_Name_Type;
begin begin
exit when Main'Length = 0; exit when Main'Length = 0;
...@@ -3999,7 +4039,7 @@ package body Makegpr is ...@@ -3999,7 +4039,7 @@ package body Makegpr is
declare declare
Main : constant String := Mains.Next_Main; Main : constant String := Mains.Next_Main;
Main_Id : Name_Id; Main_Id : File_Name_Type;
begin begin
Name_Len := 0; Name_Len := 0;
Add_Str_To_Name_Buffer (Main); Add_Str_To_Name_Buffer (Main);
...@@ -4153,7 +4193,15 @@ package body Makegpr is ...@@ -4153,7 +4193,15 @@ package body Makegpr is
-- Switches start with '-' -- Switches start with '-'
elsif Arg (1) = '-' then elsif Arg (1) = '-' then
if Arg = "-c" then if Arg'Length > 3 and then Arg (1 .. 3) = "-aP" then
Add_Search_Project_Directory (Arg (4 .. Arg'Last));
-- Record the switch, so that it is passed to gnatmake, if
-- gnatmake is called.
Saved_Switches.Append (new String'(Arg));
elsif Arg = "-c" then
Compile_Only := True; Compile_Only := True;
-- Make sure that when a main is specified and switch -c is used, -- Make sure that when a main is specified and switch -c is used,
...@@ -4227,11 +4275,10 @@ package body Makegpr is ...@@ -4227,11 +4275,10 @@ package body Makegpr is
then then
-- Is_External_Assignment has side effects when it returns True -- Is_External_Assignment has side effects when it returns True
-- Record the -X switch, so that they can be passed to gnatmake, -- Record the -X switch, so that it will be passed to gnatmake,
-- if gnatmake is called. -- if gnatmake is called.
X_Switches.Increment_Last; Saved_Switches.Append (new String'(Arg));
X_Switches.Table (X_Switches.Last) := new String'(Arg);
else else
Osint.Fail ("illegal option """, Arg, """"); Osint.Fail ("illegal option """, Arg, """");
...@@ -4296,6 +4343,11 @@ package body Makegpr is ...@@ -4296,6 +4343,11 @@ package body Makegpr is
Write_Str ("gprmake switches:"); Write_Str ("gprmake switches:");
Write_Eol; Write_Eol;
-- Line for -aP
Write_Str (" -aPdir Add directory dir to project search path");
Write_Eol;
-- Line for -c -- Line for -c
Write_Str (" -c Compile only"); Write_Str (" -c Compile only");
......
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