Commit dfa8a067 by Vincent Celier Committed by Arnaud Charlet

make.adb (Scan_Make_Arg): Take into account new switch --source-info=file.

2010-10-05  Vincent Celier  <celier@adacore.com>

	* make.adb (Scan_Make_Arg): Take into account new switch
	--source-info=file.
	* makeusg.adb: Add line for new switch --source-info=file.
	* makeutl.ads (Source_Info_Option): New constant String for new builder
	switch.
	* prj-conf.adb: Put subprograms in alphabetical order
	(Process_Project_And_Apply_Config): Read/write an eventual source info
	file, if necessary.
	* prj-nmsc.adb (Look_For_Sources.Get_Sources_From_Source_Info): New
	procedure.
	(Look_For_Sources): If a source info file was successfully read, get the
	source data from the data read from the source info file.
	* prj-util.adb (Source_Info_Table): New table
	(Source_Info_Project_HTable): New hash table
	(Create): New procedure
	(Put (File), Put_Line): New procedures
	(Write_Source_Info_File): New procedure
	(Read_Source_Info_File): New procedure
	(Initialize): New procedure
	(Source_Info_Of): New procedure
	(Next): New procedure
	(Close): When file is an out file, fail if the buffer cannot be written
	or if the file cannot be close successfully.
	(Get_Line): Fail if file is an out file
	* prj-util.ads (Create): New procedure
	(Put (File), Put_Line): New procedures
	(Write_Source_Info_File): New procedure
	(Read_Source_Info_File): New procedure
	(Source_Info_Data): New record type
	(Source_Info_Iterator): New private type
	(Initialize): New procedure
	(Source_Info_Of): New procedure
	(Next): New procedure
	* prj.ads (Project_Tree_Data): New components Source_Info_File_Name and
	Source_Info_File_Exists.

From-SVN: r164975
parent a8ef12e5
......@@ -7988,6 +7988,12 @@ package body Make is
end;
end if;
elsif Argv'Length > Source_Info_Option'Length and then
Argv (1 .. Source_Info_Option'Length) = Source_Info_Option
then
Project_Tree.Source_Info_File_Name :=
new String'(Argv (Source_Info_Option'Length + 1 .. Argv'Last));
elsif Argv'Length >= 8 and then
Argv (1 .. 8) = "--param="
then
......
......@@ -313,6 +313,13 @@ begin
Write_Str (" --subdirs=dir real obj/lib/exec dirs are subdirs");
Write_Eol;
-- Line for --source-info=
Write_Str (" ");
Write_Str (Makeutl.Source_Info_Option);
Write_Str ("file specify a source info file");
Write_Eol;
-- Line for --unchecked-shared-lib-imports
Write_Str (" ");
......
......@@ -43,6 +43,9 @@ package Makeutl is
Project_Tree : constant Project_Tree_Ref := new Project_Tree_Data;
-- The project tree
Source_Info_Option : constant String := "--source-info=";
-- Switch to indicate the source info file
Subdirs_Option : constant String := "--subdirs=";
-- Switch used to indicate that the real directories (object, exec,
-- library, ...) are subdirectories of those in the project file.
......
......@@ -32,6 +32,7 @@ with Err_Vars; use Err_Vars;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with Prj.Com;
with Prj.Err; use Prj.Err;
with Prj.Util; use Prj.Util;
with Sinput.P;
......@@ -7175,8 +7176,8 @@ package body Prj.Nmsc is
Data : in out Tree_Processing_Data)
is
Object_Files : Object_File_Names_Htable.Instance;
Iter : Source_Iterator;
Src : Source_Id;
Iter : Source_Iterator;
Src : Source_Id;
procedure Check_Object (Src : Source_Id);
-- Check if object file name of Src is already used in the project tree,
......@@ -7192,6 +7193,10 @@ package body Prj.Nmsc is
-- Check whether one of the languages has no sources, and report an
-- error when appropriate
procedure Get_Sources_From_Source_Info;
-- Get the source information from the tabes that were created when a
-- source info fie was read.
---------------------------
-- Check_Missing_Sources --
---------------------------
......@@ -7421,22 +7426,131 @@ package body Prj.Nmsc is
end loop;
end Check_Object_Files;
----------------------------------
-- Get_Sources_From_Source_Info --
----------------------------------
procedure Get_Sources_From_Source_Info is
Iter : Source_Info_Iterator;
Src : Source_Info;
Id : Source_Id;
Lang_Id : Language_Ptr;
begin
Initialize (Iter, Project.Project.Name);
loop
Src := Source_Info_Of (Iter);
exit when Src = No_Source_Info;
Id := new Source_Data;
Id.Project := Project.Project;
Lang_Id := Project.Project.Languages;
while Lang_Id /= No_Language_Index and then
Lang_Id.Name /= Src.Language
loop
Lang_Id := Lang_Id.Next;
end loop;
if Lang_Id = No_Language_Index then
Prj.Com.Fail
("unknown language " &
Get_Name_String (Src.Language) &
" for project " &
Get_Name_String (Src.Project) &
" in source info file");
end if;
Id.Language := Lang_Id;
Id.Kind := Src.Kind;
Id.Index := Src.Index;
Id.Path :=
(Path_Name_Type (Src.Display_Path_Name),
Path_Name_Type (Src.Path_Name));
Name_Len := 0;
Add_Str_To_Name_Buffer
(Ada.Directories.Simple_Name
(Get_Name_String (Src.Path_Name)));
Id.File := Name_Find;
Name_Len := 0;
Add_Str_To_Name_Buffer
(Ada.Directories.Simple_Name
(Get_Name_String (Src.Display_Path_Name)));
Id.Display_File := Name_Find;
Id.Dep_Name := Dependency_Name
(Id.File, Id.Language.Config.Dependency_Kind);
Id.Naming_Exception := Src.Naming_Exception;
Id.Object := Object_Name
(Id.File, Id.Language.Config.Object_File_Suffix);
Id.Switches := Switches_Name (Id.File);
-- Add the source id to the Unit_Sources_HT hash table, if the
-- unit name is not null.
if Src.Kind /= Sep and then Src.Unit_Name /= No_Name then
declare
UData : Unit_Index :=
Units_Htable.Get (Data.Tree.Units_HT, Src.Unit_Name);
begin
if UData = No_Unit_Index then
UData := new Unit_Data;
UData.Name := Src.Unit_Name;
Units_Htable.Set
(Data.Tree.Units_HT, Src.Unit_Name, UData);
end if;
Id.Unit := UData;
end;
-- Note that this updates Unit information as well
Override_Kind (Id, Id.Kind);
end if;
if Src.Index /= 0 then
Project.Project.Has_Multi_Unit_Sources := True;
end if;
-- Add the source to the language list
Id.Next_In_Lang := Id.Language.First_Source;
Id.Language.First_Source := Id;
Files_Htable.Set (Data.File_To_Source, Id.File, Id);
Next (Iter);
end loop;
end Get_Sources_From_Source_Info;
-- Start of processing for Look_For_Sources
begin
if Project.Project.Source_Dirs /= Nil_String then
Find_Excluded_Sources (Project, Data);
if Project.Project.Languages /= No_Language_Index then
Load_Naming_Exceptions (Project, Data);
Find_Sources (Project, Data);
Mark_Excluded_Sources;
Check_Object_Files;
Check_Missing_Sources;
if Data.Tree.Source_Info_File_Exists then
Get_Sources_From_Source_Info;
else
if Project.Project.Source_Dirs /= Nil_String then
Find_Excluded_Sources (Project, Data);
if Project.Project.Languages /= No_Language_Index then
Load_Naming_Exceptions (Project, Data);
Find_Sources (Project, Data);
Mark_Excluded_Sources;
Check_Object_Files;
Check_Missing_Sources;
end if;
end if;
end if;
Object_File_Names_Htable.Reset (Object_Files);
Object_File_Names_Htable.Reset (Object_Files);
end if;
end Look_For_Sources;
------------------
......
......@@ -160,32 +160,93 @@ package Prj.Util is
-- closed.
procedure Open (File : out Text_File; Name : String);
-- Open a text file to read (file is invalid if text file cannot be opened)
-- Open a text file to read (File is invalid if text file cannot be opened)
procedure Create (File : out Text_File; Name : String);
-- Create a text file to write (File is invaid if text file cannot be
-- created).
function End_Of_File (File : Text_File) return Boolean;
-- Returns True if the end of the text file File has been reached. Fails if
-- File is invalid.
-- File is invalid. Return True if File is an out file.
procedure Get_Line
(File : Text_File;
Line : out String;
Last : out Natural);
-- Reads a line from an open text file (fails if file is invalid)
-- Reads a line from an open text file (fails if File is invalid or in an
-- out file).
procedure Put (File : Text_File; S : String);
procedure Put_Line (File : Text_File; Line : String);
-- Output a string or a line to an out text file (fails if File is invalid
-- or in an in file).
procedure Close (File : in out Text_File);
-- Close an open text file. File becomes invalid. Fails if File is already
-- invalid.
-- invalid or if an out file cannot be closed successfully.
-----------------------
-- Source info files --
-----------------------
procedure Write_Source_Info_File (Tree : Project_Tree_Ref);
-- Create a new source info file, with the path name specified in the
-- project tree data. Issue a warning if it is not possible to create
-- the new file.
procedure Read_Source_Info_File (Tree : Project_Tree_Ref);
-- Check if there is a source info file specified for the project Tree and
-- if there is one, attempt to read it. If the file exists and is
-- successfully read, set the flag Source_Info_File_Exists to True for
-- the tree.
type Source_Info_Data is record
Project : Name_Id;
Language : Name_Id;
Kind : Source_Kind;
Display_Path_Name : Name_Id;
Path_Name : Name_Id;
Unit_Name : Name_Id := No_Name;
Index : Int := 0;
Naming_Exception : Boolean := False;
end record;
-- Data read from a source info file for a single source
type Source_Info is access all Source_Info_Data;
No_Source_Info : constant Source_Info := null;
type Source_Info_Iterator is private;
-- Iterator to get the sources for a single project
procedure Initialize
(Iter : out Source_Info_Iterator; For_Project : Name_Id);
-- Initiaize Iter for the project
function Source_Info_Of (Iter : Source_Info_Iterator) return Source_Info;
-- Get the source info for the source corresponding to the current value of
-- the iterator. Returns No_Source_Info if there is no source corresponding
-- to the iterator.
procedure Next (Iter : in out Source_Info_Iterator);
-- Advance the iterator to the next source in the project
private
type Text_File_Data is record
FD : File_Descriptor := Invalid_FD;
Out_File : Boolean := False;
Buffer : String (1 .. 1_000);
Buffer_Len : Natural;
Buffer_Len : Natural := 0;
Cursor : Natural := 0;
End_Of_File_Reached : Boolean := False;
end record;
type Text_File is access Text_File_Data;
type Source_Info_Iterator is record
Info : Source_Info;
Next : Natural;
end record;
end Prj.Util;
......@@ -1354,6 +1354,12 @@ package Prj is
Source_Paths_HT : Source_Paths_Htable.Instance;
-- Full path to Source_Id
Source_Info_File_Name : String_Access := null;
-- The name of the source info file, if specified by the builder
Source_Info_File_Exists : Boolean := False;
-- True when a source info file has been successfully read
Private_Part : Private_Project_Tree_Data;
end record;
-- Data for a project tree
......
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