+2009-04-24 Emmanuel Briot <briot@adacore.com>
+
+ * make.adb, prj.adb, prj.ads, makeutl.adb, makeutl.ads:
+ (Project_Data.Dir_Path): field removed, since it can be computed
+ directly from .Directory, and is needed only once when processing the
+ project is buildgpr.adb or make.adb
+
2009-04-24 Robert Dewar <dewar@adacore.com>
* prj-env.adb, prj-proc.adb, prj.adb, prj.ads,
-- We get the project directory for the relative path
-- switches and arguments.
+ Arguments_Project := Ultimate_Extending_Project_Of
+ (Arguments_Project, Project_Tree);
Data := Project_Tree.Projects.Table (Arguments_Project);
- -- If the source is in an extended project, we go to
- -- the ultimate extending project.
-
- while Data.Extended_By /= No_Project loop
- Arguments_Project := Data.Extended_By;
- Data := Project_Tree.Projects.Table (Arguments_Project);
- end loop;
-
-- If building a dynamic or relocatable library, compile with
-- PIC option, if it exists.
end;
end if;
- if Data.Dir_Path = null then
- Data.Dir_Path :=
- new String'(Get_Name_String (Data.Directory.Display_Name));
- Project_Tree.Projects.Table (Arguments_Project) :=
- Data;
- end if;
-
-- We now look for package Compiler and get the switches from
-- this package.
declare
New_Args : Argument_List (1 .. Number);
Last_New : Natural := 0;
+ Dir_Path : constant String :=
+ Get_Name_String (Data.Directory.Name);
begin
Current := Switches.Values;
new String'(Name_Buffer (1 .. Name_Len));
Test_If_Relative_Path
(New_Args (Last_New),
- Parent => Data.Dir_Path,
+ Parent => Dir_Path,
Including_Non_Switch => False);
end if;
New_Args : Argument_List :=
(1 => new String'
(Name_Buffer (1 .. Name_Len)));
+ Dir_Path : constant String :=
+ Get_Name_String (Data.Directory.Name);
begin
Test_If_Relative_Path
(New_Args (1),
- Parent => Data.Dir_Path,
+ Parent => Dir_Path,
Including_Non_Switch => False);
Add_Arguments
(Configuration_Pragmas_Switch (Arguments_Project) &
-- project file.
declare
- Dir_Path : constant String_Access :=
- new String'(Get_Name_String
+ Dir_Path : constant String :=
+ Get_Name_String
(Project_Tree.Projects.Table
- (Main_Project).Directory.Name));
+ (Main_Project).Directory.Name);
begin
for J in 1 .. Binder_Switches.Last loop
Test_If_Relative_Path
for J in 1 .. Saved_Binder_Switches.Last loop
Test_If_Relative_Path
(Saved_Binder_Switches.Table (J),
- Parent => Current_Work_Dir, Including_L_Switch => False);
+ Parent => Current_Work_Dir.all, Including_L_Switch => False);
end loop;
for J in 1 .. Linker_Switches.Last loop
for J in 1 .. Saved_Linker_Switches.Last loop
Test_If_Relative_Path
- (Saved_Linker_Switches.Table (J), Parent => Current_Work_Dir);
+ (Saved_Linker_Switches.Table (J),
+ Parent => Current_Work_Dir.all);
end loop;
for J in 1 .. Gcc_Switches.Last loop
for J in 1 .. Saved_Gcc_Switches.Last loop
Test_If_Relative_Path
(Saved_Gcc_Switches.Table (J),
- Parent => Current_Work_Dir,
+ Parent => Current_Work_Dir.all,
Including_Non_Switch => False);
end loop;
end;
-- relative path in the project file.
declare
- Dir_Path : constant String_Access :=
- new String'(Get_Name_String
- (Project_Tree.Projects.Table
- (Main_Project).Directory.Name));
+ Dir_Path : constant String :=
+ Get_Name_String
+ (Project_Tree.Projects.Table
+ (Main_Project).Directory.Name);
begin
for
J in Last_Binder_Switch + 1 .. Binder_Switches.Last
Proj : constant Project_Id :=
Linker_Opts.Table (Index).Project;
Option : Name_Id;
+ Dir_Path : constant String :=
+ Get_Name_String (In_Tree.Projects.Table (Proj).Directory.Name);
begin
- -- If Dir_Path has not been computed for this project, do it now
-
- if In_Tree.Projects.Table (Proj).Dir_Path = null then
- In_Tree.Projects.Table (Proj).Dir_Path :=
- new String'
- (Get_Name_String
- (In_Tree.Projects.Table (Proj).Directory.Name));
- end if;
-
while Options /= Nil_String loop
Option := In_Tree.String_Elements.Table (Options).Value;
Get_Name_String (Option);
Test_If_Relative_Path
(Switch => Linker_Options_Buffer (Last_Linker_Option),
- Parent => In_Tree.Projects.Table (Proj).Dir_Path,
+ Parent => Dir_Path,
Including_L_Switch => True);
end if;
procedure Test_If_Relative_Path
(Switch : in out String_Access;
- Parent : String_Access;
+ Parent : String;
Including_L_Switch : Boolean := True;
Including_Non_Switch : Boolean := True)
is
-- arguments are not converted.
if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then
- if Parent = null or else Parent'Length = 0 then
+ if Parent'Length = 0 then
Do_Fail
("relative search path switches ("""
& Sw
Switch :=
new String'
(Sw (1 .. Start - 1) &
- Parent.all &
+ Parent &
Directory_Separator &
Sw (Start .. Sw'Last));
end if;
elsif Including_Non_Switch then
if not Is_Absolute_Path (Sw) then
- if Parent = null or else Parent'Length = 0 then
+ if Parent'Length = 0 then
Do_Fail
("relative paths (""" & Sw & """) are not allowed");
else
- Switch :=
- new String'(Parent.all & Directory_Separator & Sw);
+ Switch := new String'(Parent & Directory_Separator & Sw);
end if;
end if;
end if;
-- --
-- S p e c --
-- --
--- Copyright (C) 2004-2008, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-2009, Free Software Foundation, Inc. --
-- --
-- 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- --
procedure Test_If_Relative_Path
(Switch : in out String_Access;
- Parent : String_Access;
+ Parent : String;
Including_L_Switch : Boolean := True;
Including_Non_Switch : Boolean := True);
-- Test if Switch is a relative search path switch.
- -- If it is, fail if Parent is null, otherwise prepend the path with
- -- Parent. This subprogram is only called when using project files.
+ -- If it is, fail if Parent is the empty string, otherwise prepend the path
+ -- with Parent. This subprogram is only called when using project files.
-- For gnatbind switches, Including_L_Switch is False, because the
-- argument of the -L switch is not a path.
Location => No_Location,
Mains => Nil_String,
Directory => No_Path_Information,
- Dir_Path => null,
Library => False,
Library_Dir => No_Path_Information,
Library_Src_Dir => No_Path_Information,
Symbol_Data => No_Symbols,
Ada_Sources => Nil_String,
Interfaces_Defined => False,
- Imported_Directories_Switches => null,
Include_Path => null,
Include_Data_Set => False,
Source_Dirs => Nil_String,
procedure Free (Project : in out Project_Data) is
begin
- Free (Project.Dir_Path);
Free (Project.Include_Path);
Free (Project.Ada_Include_Path);
Free (Project.Objects_Path);
Directory : Path_Information := No_Path_Information;
-- Path name of the directory where the project file resides
- Dir_Path : String_Access;
- -- Same as Directory.Name, but as an access to String
-
Object_Directory : Path_Information := No_Path_Information;
-- The path name of the object directory of this project file
-- True if attribute Interfaces is declared for the project or any
-- project it extends.
- Imported_Directories_Switches : Argument_List_Access := null;
- -- List of the source search switches (-I<source dir>) to be used when
- -- compiling.
-
Include_Path : String_Access := null;
-- The search source path for the project. Used as the value for an
-- environment variable, specified by attribute Include_Path