Commit 104e4daa by Vincent Celier Committed by Arnaud Charlet

clean.adb (Check_Project): Look for Ada code in extending project, even if Ada…

clean.adb (Check_Project): Look for Ada code in extending project, even if Ada is not specified as a language.

2005-11-14  Vincent Celier  <celier@adacore.com>

	* clean.adb (Check_Project): Look for Ada code in extending project,
	even if Ada is not specified as a language.
	Use new function DLL_Prefix for DLL_Name
	(Clean_Interface_Copy_Directory): New procedure
	(Clean_Library_Directory): New procedure
	(Clean_Directory): Remove procedure, no longer used
	(Clean_Project): Do not delete any file in an externally built project

	* prj-env.adb (Set_Ada_Paths.Add.Recursive_Add): Add the object
	directory of an extending project, even when there are no Ada source
	present.
	(Ada_Objects_Path.Add): Add Library_ALI_Dir, not Library_Dir to the path
	(Set_Ada_Paths.Add.Recursive_Add): Ditto

	* mlib-prj.adb (Check_Library): For all library projects, get the
	library file timestamp.
	(Build_Library): Copy ALI files in Library_ALI_Dir, not in Library_Dir
	(Build_Library): Use new function DLL_Prefix for the DLL_Name
	(Clean): Remove procedure, no longer used
	(Ultimate_Extension_Of): New function
	(Build_Library): When cleaning the library directory, only remove an
	existing library file and any ALI file of a source of the project.
	When cleaning the interface copy directory, remove any source that
	could be a source of the project.

	* prj.ads, prj.adb (Project_Empty): Add values of new components
	Library_TS and All_Imported_Projects.
	(Project_Empty): Add values for new components of Project_Data:
	Library_ALI_Dir and Display_Library_ALI_Dir

	* prj-attr.adb: New project level attribute name Library_ALI_Dir

	* prj-nmsc.adb (Check_Library_Attributes): Take into account new
	attribute Library_ALI_Dir.
	(Check_Library_Attributes): The library directory cannot be the same as
	any source directory of the project tree.
	(Check_Stand_Alone_Library): The interface copy directory cannot be
	the same as any source directory of the project tree.

	* mlib.adb: Use Prj.Com.Fail, instead of Osint.Fail directly, to delete
	all temporary files.

From-SVN: r106967
parent f9f7e102
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2005, Ada Core Technologies, Inc. -- -- Copyright (C) 1999-2005, AdaCore --
-- -- -- --
-- 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- --
...@@ -34,6 +34,8 @@ with Namet; use Namet; ...@@ -34,6 +34,8 @@ with Namet; use Namet;
with MLib.Utl; use MLib.Utl; with MLib.Utl; use MLib.Utl;
with Prj.Com;
with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.Directory_Operations; use GNAT.Directory_Operations;
package body MLib is package body MLib is
...@@ -67,22 +69,22 @@ package body MLib is ...@@ -67,22 +69,22 @@ package body MLib is
procedure Check_Library_Name (Name : String) is procedure Check_Library_Name (Name : String) is
begin begin
if Name'Length = 0 then if Name'Length = 0 then
Fail ("library name cannot be empty"); Prj.Com.Fail ("library name cannot be empty");
end if; end if;
if Name'Length > Max_Characters_In_Library_Name then if Name'Length > Max_Characters_In_Library_Name then
Fail ("illegal library name """, Name, """: too long"); Prj.Com.Fail ("illegal library name """, Name, """: too long");
end if; end if;
if not Is_Letter (Name (Name'First)) then if not Is_Letter (Name (Name'First)) then
Fail ("illegal library name """, Prj.Com.Fail ("illegal library name """,
Name, Name,
""": should start with a letter"); """: should start with a letter");
end if; end if;
for Index in Name'Range loop for Index in Name'Range loop
if not Is_Alphanumeric (Name (Index)) then if not Is_Alphanumeric (Name (Index)) then
Fail ("illegal library name """, Prj.Com.Fail ("illegal library name """,
Name, Name,
""": should include only letters and digits"); """: should include only letters and digits");
end if; end if;
...@@ -273,7 +275,7 @@ package body MLib is ...@@ -273,7 +275,7 @@ package body MLib is
end; end;
if not Success then if not Success then
Fail ("could not copy ALI files to library dir"); Prj.Com.Fail ("could not copy ALI files to library dir");
end if; end if;
end loop; end loop;
end if; end if;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2004 Free Software Foundation, Inc. -- -- Copyright (C) 2001-2005, 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- --
...@@ -55,7 +55,7 @@ package body Prj.Attr is ...@@ -55,7 +55,7 @@ package body Prj.Attr is
-- insensitive -- insensitive
-- 'c' same as 'b', with optional index -- 'c' same as 'b', with optional index
-- End is indicated by two consecutive '#'. -- End is indicated by two consecutive '#'
Initialization_Data : constant String := Initialization_Data : constant String :=
...@@ -75,6 +75,7 @@ package body Prj.Attr is ...@@ -75,6 +75,7 @@ package body Prj.Attr is
"SVlibrary_auto_init#" & "SVlibrary_auto_init#" &
"LVlibrary_options#" & "LVlibrary_options#" &
"SVlibrary_src_dir#" & "SVlibrary_src_dir#" &
"SVlibrary_ali_dir#" &
"SVlibrary_gcc#" & "SVlibrary_gcc#" &
"SVlibrary_symbol_file#" & "SVlibrary_symbol_file#" &
"SVlibrary_symbol_policy#" & "SVlibrary_symbol_policy#" &
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2001-2005, 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- --
...@@ -48,7 +48,7 @@ package body Prj.Env is ...@@ -48,7 +48,7 @@ package body Prj.Env is
-- and ADA_OBJECTS_PATH are stored. -- and ADA_OBJECTS_PATH are stored.
Ada_Path_Length : Natural := 0; Ada_Path_Length : Natural := 0;
-- Index of the last valid character in Ada_Path_Buffer. -- Index of the last valid character in Ada_Path_Buffer
Ada_Prj_Include_File_Set : Boolean := False; Ada_Prj_Include_File_Set : Boolean := False;
Ada_Prj_Objects_File_Set : Boolean := False; Ada_Prj_Objects_File_Set : Boolean := False;
...@@ -270,9 +270,9 @@ package body Prj.Env is ...@@ -270,9 +270,9 @@ package body Prj.Env is
if Data.Library then if Data.Library then
if Data.Object_Directory = No_Name if Data.Object_Directory = No_Name
or else or else
Contains_ALI_Files (Data.Library_Dir) Contains_ALI_Files (Data.Library_ALI_Dir)
then then
Add_To_Path (Get_Name_String (Data.Library_Dir)); Add_To_Path (Get_Name_String (Data.Library_ALI_Dir));
else else
Add_To_Path (Get_Name_String (Data.Object_Directory)); Add_To_Path (Get_Name_String (Data.Object_Directory));
end if; end if;
...@@ -2121,16 +2121,17 @@ package body Prj.Env is ...@@ -2121,16 +2121,17 @@ package body Prj.Env is
and then and then
(not Including_Libraries or else not Data.Library)) (not Including_Libraries or else not Data.Library))
then then
-- For a library project, add the library directory -- For a library project, add the library ALI
-- if there is no object directory or if the library -- directory if there is no object directory or
-- directory contains ALI files; otherwise add the -- if the library ALI directory contains ALI files;
-- object directory. -- otherwise add the object directory.
if Data.Library then if Data.Library then
if Data.Object_Directory = No_Name if Data.Object_Directory = No_Name
or else Contains_ALI_Files (Data.Library_Dir) or else Contains_ALI_Files (Data.Library_ALI_Dir)
then then
Add_To_Object_Path (Data.Library_Dir, In_Tree); Add_To_Object_Path
(Data.Library_ALI_Dir, In_Tree);
else else
Add_To_Object_Path Add_To_Object_Path
(Data.Object_Directory, In_Tree); (Data.Object_Directory, In_Tree);
...@@ -2138,13 +2139,18 @@ package body Prj.Env is ...@@ -2138,13 +2139,18 @@ package body Prj.Env is
-- For a non-library project, add the object -- For a non-library project, add the object
-- directory, if it is not a virtual project, and -- directory, if it is not a virtual project, and
-- if there are Ada sources. If there are no Ada -- if there are Ada sources or if the project is an
-- sources, adding the object directory could -- extending project. if There Are No Ada sources,
-- disrupt the order of the object dirs in the path. -- adding the object directory could disrupt
-- the order of the object dirs in the path.
elsif not Data.Virtual elsif not Data.Virtual
and then In_Tree.Projects.Table and then (In_Tree.Projects.Table
(Project).Ada_Sources_Present (Project).Ada_Sources_Present
or else
(Data.Extends /= No_Project
and then
Data.Object_Directory /= No_Name))
then then
Add_To_Object_Path Add_To_Object_Path
(Data.Object_Directory, In_Tree); (Data.Object_Directory, In_Tree);
...@@ -2230,7 +2236,7 @@ package body Prj.Env is ...@@ -2230,7 +2236,7 @@ package body Prj.Env is
Add (Project); Add (Project);
end if; end if;
-- Write and close any file that has been created. -- Write and close any file that has been created
if Source_FD /= Invalid_FD then if Source_FD /= Invalid_FD then
for Index in Source_Path_Table.First .. for Index in Source_Path_Table.First ..
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2001-2005, 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- --
...@@ -102,6 +102,8 @@ package body Prj is ...@@ -102,6 +102,8 @@ package body Prj is
Display_Library_Dir => No_Name, Display_Library_Dir => No_Name,
Library_Src_Dir => No_Name, Library_Src_Dir => No_Name,
Display_Library_Src_Dir => No_Name, Display_Library_Src_Dir => No_Name,
Library_ALI_Dir => No_Name,
Display_Library_ALI_Dir => No_Name,
Library_Name => No_Name, Library_Name => No_Name,
Library_Kind => Static, Library_Kind => Static,
Lib_Internal_Name => No_Name, Lib_Internal_Name => No_Name,
...@@ -121,6 +123,7 @@ package body Prj is ...@@ -121,6 +123,7 @@ package body Prj is
Known_Order_Of_Source_Dirs => True, Known_Order_Of_Source_Dirs => True,
Object_Directory => No_Name, Object_Directory => No_Name,
Display_Object_Dir => No_Name, Display_Object_Dir => No_Name,
Library_TS => Empty_Time_Stamp,
Exec_Directory => No_Name, Exec_Directory => No_Name,
Display_Exec_Dir => No_Name, Display_Exec_Dir => No_Name,
Extends => No_Project, Extends => No_Project,
...@@ -132,6 +135,7 @@ package body Prj is ...@@ -132,6 +135,7 @@ package body Prj is
Default_Linker_Path => No_Name, Default_Linker_Path => No_Name,
Decl => No_Declarations, Decl => No_Declarations,
Imported_Projects => Empty_Project_List, Imported_Projects => Empty_Project_List,
All_Imported_Projects => Empty_Project_List,
Ada_Include_Path => null, Ada_Include_Path => null,
Ada_Objects_Path => null, Ada_Objects_Path => null,
Include_Path_File => No_Name, Include_Path_File => No_Name,
...@@ -485,7 +489,7 @@ package body Prj is ...@@ -485,7 +489,7 @@ package body Prj is
end if; end if;
end loop; end loop;
-- If none can be found, create a new one. -- If none can be found, create a new one
if not Found then if not Found then
Element := Element :=
...@@ -526,7 +530,7 @@ package body Prj is ...@@ -526,7 +530,7 @@ package body Prj is
end if; end if;
end loop; end loop;
-- If none can be found, create a new one. -- If none can be found, create a new one
if not Found then if not Found then
Element := Element :=
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2005 Free Software Foundation, Inc. -- -- Copyright (C) 2001-2005, 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- --
...@@ -73,9 +73,11 @@ package Prj is ...@@ -73,9 +73,11 @@ package Prj is
-- Canonical_Case_File_Name is called on this variable in the body of Prj. -- Canonical_Case_File_Name is called on this variable in the body of Prj.
----------------------------------------------------- -----------------------------------------------------
-- Multi-language stuff that will be modified soon -- -- Multi-language Stuff That Will be Modified Soon --
----------------------------------------------------- -----------------------------------------------------
-- Still should be properly commented ???
type Language_Index is new Nat; type Language_Index is new Nat;
No_Language_Index : constant Language_Index := 0; No_Language_Index : constant Language_Index := 0;
...@@ -232,6 +234,7 @@ package Prj is ...@@ -232,6 +234,7 @@ package Prj is
type Other_Source_Id is new Nat; type Other_Source_Id is new Nat;
No_Other_Source : constant Other_Source_Id := 0; No_Other_Source : constant Other_Source_Id := 0;
type Other_Source is record type Other_Source is record
Language : Language_Index; -- language of the source Language : Language_Index; -- language of the source
File_Name : Name_Id; -- source file simple name File_Name : Name_Id; -- source file simple name
...@@ -430,7 +433,7 @@ package Prj is ...@@ -430,7 +433,7 @@ package Prj is
Parent : Package_Id := No_Package; Parent : Package_Id := No_Package;
Next : Package_Id := No_Package; Next : Package_Id := No_Package;
end record; end record;
-- A package. Includes declarations that may include other packages -- A package (includes declarations that may include other packages)
package Package_Table is new GNAT.Dynamic_Tables package Package_Table is new GNAT.Dynamic_Tables
(Table_Component_Type => Package_Element, (Table_Component_Type => Package_Element,
...@@ -585,6 +588,7 @@ package Prj is ...@@ -585,6 +588,7 @@ package Prj is
-- Directory where the project file resides. Set by Prj.Proc.Process -- Directory where the project file resides. Set by Prj.Proc.Process
Display_Directory : Name_Id := No_Name; Display_Directory : Name_Id := No_Name;
-- comment ???
Dir_Path : String_Access; Dir_Path : String_Access;
-- Same as Directory, but as an access to String. Set by -- Same as Directory, but as an access to String. Set by
...@@ -603,18 +607,31 @@ package Prj is ...@@ -603,18 +607,31 @@ package Prj is
-- different from Library_Dir for platforms where the file names are -- different from Library_Dir for platforms where the file names are
-- case-insensitive. -- case-insensitive.
Library_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- The timestamp of a library file in a library project.
-- Set by MLib.Prj.Check_Library.
Library_Src_Dir : Name_Id := No_Name; Library_Src_Dir : Name_Id := No_Name;
-- If a library project, directory where the sources and the ALI files -- If a Stand-Alone Library project, directory where the sources
-- of the library are copied. By default, if attribute Library_Src_Dir -- of the interfaces of the library are copied. By default, if
-- is not specified, sources are not copied anywhere and ALI files are -- attribute Library_Src_Dir is not specified, sources of the interfaces
-- copied in the Library Directory. Set by -- are not copied anywhere. Set by Prj.Nmsc.Check_Stand_Alone_Library.
-- Prj.Nmsc.Language_Independent_Check.
Display_Library_Src_Dir : Name_Id := No_Name; Display_Library_Src_Dir : Name_Id := No_Name;
-- The name of the library source directory, for display purposes. -- The name of the library source directory, for display purposes.
-- May be different from Library_Src_Dir for platforms where the file -- May be different from Library_Src_Dir for platforms where the file
-- names are case-insensitive. -- names are case-insensitive.
Library_ALI_Dir : Name_Id := No_Name;
-- In a library project, directory where the ALI files are copied.
-- If attribute Library_ALI_Dir is not specified, ALI files are
-- copied in the Library_Dir. Set by Prj.Nmsc.Check_Library_Attributes.
Display_Library_ALI_Dir : Name_Id := No_Name;
-- The name of the library ALI directory, for display purposes. May be
-- different from Library_ALI_Dir for platforms where the file names are
-- case-insensitive.
Library_Name : Name_Id := No_Name; Library_Name : Name_Id := No_Name;
-- If a library project, name of the library -- If a library project, name of the library
-- Set by Prj.Nmsc.Language_Independent_Check. -- Set by Prj.Nmsc.Language_Independent_Check.
...@@ -653,8 +670,8 @@ package Prj is ...@@ -653,8 +670,8 @@ package Prj is
-- A flag that indicates that there are non-Ada sources in this project -- A flag that indicates that there are non-Ada sources in this project
Sources : String_List_Id := Nil_String; Sources : String_List_Id := Nil_String;
-- The list of all the source file names. Set by -- The list of all the source file names.
-- Prj.Nmsc.Check_Ada_Naming_Scheme. -- Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
First_Other_Source : Other_Source_Id := No_Other_Source; First_Other_Source : Other_Source_Id := No_Other_Source;
Last_Other_Source : Other_Source_Id := No_Other_Source; Last_Other_Source : Other_Source_Id := No_Other_Source;
...@@ -712,9 +729,10 @@ package Prj is ...@@ -712,9 +729,10 @@ package Prj is
First_Language_Processing : First_Language_Processing_Data := First_Language_Processing : First_Language_Processing_Data :=
Default_First_Language_Processing_Data; Default_First_Language_Processing_Data;
-- Comment needed ???
Supp_Language_Processing : Supp_Language_Index := Supp_Language_Processing : Supp_Language_Index := No_Supp_Language_Index;
No_Supp_Language_Index; -- Comment needed
Default_Linker : Name_Id := No_Name; Default_Linker : Name_Id := No_Name;
Default_Linker_Path : Name_Id := No_Name; Default_Linker_Path : Name_Id := No_Name;
...@@ -727,6 +745,10 @@ package Prj is ...@@ -727,6 +745,10 @@ package Prj is
-- The list of all directly imported projects, if any. Set by -- The list of all directly imported projects, if any. Set by
-- Prj.Proc.Process. -- Prj.Proc.Process.
All_Imported_Projects : Project_List := Empty_Project_List;
-- The list of all projects imported directly or indirectly, if any.
-- Set by Make.Initialize.
Ada_Include_Path : String_Access := null; Ada_Include_Path : String_Access := null;
-- The cached value of ADA_INCLUDE_PATH for this project file. Do not -- The cached value of ADA_INCLUDE_PATH for this project file. Do not
-- use this field directly outside of the compiler, use -- use this field directly outside of the compiler, use
...@@ -943,14 +965,14 @@ package Prj is ...@@ -943,14 +965,14 @@ package Prj is
In_Project : Project_Data; In_Project : Project_Data;
In_Tree : Project_Tree_Ref) return Boolean; In_Tree : Project_Tree_Ref) return Boolean;
-- Return True when Language is one of the languages used in -- Return True when Language is one of the languages used in
-- project Project. -- project In_Project.
procedure Set procedure Set
(Language : Language_Index; (Language : Language_Index;
Present : Boolean; Present : Boolean;
In_Project : in out Project_Data; In_Project : in out Project_Data;
In_Tree : Project_Tree_Ref); In_Tree : Project_Tree_Ref);
-- Indicate if Language is or not a language used in project Project -- Indicate if Language is or not a language used in project In_Project
function Language_Processing_Data_Of function Language_Processing_Data_Of
(Language : Language_Index; (Language : Language_Index;
...@@ -1018,6 +1040,7 @@ private ...@@ -1018,6 +1040,7 @@ private
Table_Low_Bound => 1, Table_Low_Bound => 1,
Table_Initial => 5, Table_Initial => 5,
Table_Increment => 100); Table_Increment => 100);
-- Comment ???
package Path_File_Table is new GNAT.Dynamic_Tables package Path_File_Table is new GNAT.Dynamic_Tables
(Table_Component_Type => Name_Id, (Table_Component_Type => Name_Id,
...@@ -1051,4 +1074,5 @@ private ...@@ -1051,4 +1074,5 @@ private
Object_Paths : Object_Path_Table.Instance; Object_Paths : Object_Path_Table.Instance;
Default_Naming : Naming_Data; Default_Naming : Naming_Data;
end record; end record;
-- Comment ???
end Prj; end Prj;
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