-- --
-- S p e c --
-- --
--- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2010, 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- --
with Casing; use Casing;
with Namet; use Namet;
+with Osint;
with Scans; use Scans;
with Types; use Types;
type Yes_No_Unknown is (Yes, No, Unknown);
-- Tri-state to decide if -lgnarl is needed when linking
- type Mode is (Multi_Language, Ada_Only);
- -- Ada_Only: mode for gnatmake, gnatclean, gnatname, the GNAT driver
- -- Multi_Language: mode for gprbuild, gprclean
-
type Project_Qualifier is
(Unspecified,
Standard,
-- Aggregate_Library: aggregate library project is ...
-- Configuration: configuration project is ...
- function Get_Mode return Mode;
- pragma Inline (Get_Mode);
-
- procedure Set_Mode (New_Mode : Mode);
- pragma Inline (Set_Mode);
-
- Default_Language_Is_Ada : Boolean := True;
- -- If no language was defined in the project or the configuration file, it
- -- is an error, unless this variable is True, in which case it defaults to
- -- Ada. Calling Set_Mode will reset this variable, default is for Ada_Only.
-
- Must_Check_Configuration : Boolean := False;
- -- True when the contents of the configuration file must be checked. This
- -- is in general only needed by gprbuild itself, since other applications
- -- can ignore such errors when they don't need to build directly. Calling
- -- Set_Mode will reset this variable, default is for Ada_Only.
-
All_Packages : constant String_List_Access;
-- Default value of parameter Packages of procedures Parse, in Prj.Pars and
-- Prj.Part, indicating that all packages should be checked.
procedure Free (Tree : in out Project_Tree_Ref);
-- Free memory associated with the tree
- function Default_Ada_Spec_Suffix return File_Name_Type;
- pragma Inline (Default_Ada_Spec_Suffix);
- -- The name for the standard GNAT suffix for Ada spec source file name
- -- ".ads". Initialized by Prj.Initialize.
-
- function Default_Ada_Body_Suffix return File_Name_Type;
- pragma Inline (Default_Ada_Body_Suffix);
- -- The name for the standard GNAT suffix for Ada body source file name
- -- ".adb". Initialized by Prj.Initialize.
-
Config_Project_File_Extension : String := ".cgpr";
Project_File_Extension : String := ".gpr";
-- The standard config and user project file name extensions. They are not
-- constants, because Canonical_Case_File_Name is called on these variables
-- in the body of Prj.
- type Error_Warning is (Silent, Warning, Error);
- -- Severity of some situations, such as: no Ada sources in a project where
- -- Ada is one of the language.
- --
- -- When the situation occurs, the behaviour depends on the setting:
- --
- -- - Silent: no action
- -- - Warning: issue a warning, does not cause the tool to fail
- -- - Error: issue an error, causes the tool to fail
-
function Empty_File return File_Name_Type;
function Empty_String return Name_Id;
-- Return the id for an empty string ""
Name : Path_Name_Type := No_Path;
Display_Name : Path_Name_Type := No_Path;
end record;
+ -- Directory names always end with a directory separator
No_Path_Information : constant Path_Information := (No_Path, No_Path);
end case;
end record;
-- Values for variables and array elements. Default is True if the
- -- current value is the default one for the variable
+ -- current value is the default one for the variable.
Nil_Variable_Value : constant Variable_Value;
-- Value of a non existing variable or array element
function Hash (Name : Name_Id) return Header_Num;
function Hash (Name : File_Name_Type) return Header_Num;
function Hash (Name : Path_Name_Type) return Header_Num;
- function Hash (Project : Project_Id) return Header_Num;
- -- Used for computing hash values for names put into above hash table
+ function Hash (Project : Project_Id) return Header_Num;
+ -- Used for computing hash values for names put into hash tables
type Language_Kind is (File_Based, Unit_Based);
-- Type for the kind of language. All languages are file based, except Ada
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 100);
- -- The table for lists of names used in package Language_Processing
+ -- The table for lists of names
+
+ function Length
+ (Table : Name_List_Table.Instance;
+ List : Name_List_Index) return Natural;
+ -- Return the number of elements in specified list
+
+ type Number_List_Index is new Nat;
+ No_Number_List : constant Number_List_Index := 0;
+
+ type Number_Node is record
+ Number : Natural := 0;
+ Next : Number_List_Index := No_Number_List;
+ end record;
+
+ package Number_List_Table is new GNAT.Dynamic_Tables
+ (Table_Component_Type => Number_Node,
+ Table_Index_Type => Number_List_Index,
+ Table_Low_Bound => 1,
+ Table_Initial => 10,
+ Table_Increment => 100);
+ -- The table for lists of numbers
package Mapping_Files_Htable is new Simple_HTable
(Header_Num => Header_Num,
Equal => "=");
-- A hash table to store the mapping files that are not used
+ -- The following record ???
+
type Lang_Naming_Data is record
Dot_Replacement : File_Name_Type := No_File;
-- The string to replace '.' in the source file name (for Ada)
Spec_Suffix => No_File,
Body_Suffix => No_File);
+ function Is_Standard_GNAT_Naming (Naming : Lang_Naming_Data) return Boolean;
+ -- True if the naming scheme is GNAT's default naming scheme. This
+ -- is to take into account shortened names like "Ada." (a-), "System." (s-)
+ -- and so on.
+
type Source_Data;
type Source_Id is access all Source_Data;
type Path_Syntax_Kind is
(Canonical,
-- Unix style
-
Host);
-- Host specific syntax, for example on VMS (the default)
+ -- The following record describes the configuration of a language
+
type Language_Config is record
Kind : Language_Kind := File_Based;
-- Kind of language. All languages are file based, except Ada which is
-- The naming data for the languages (prefixes, etc.)
Include_Compatible_Languages : Name_List_Index := No_Name_List;
- -- The list of languages that are "include compatible" with this
- -- language. A language B (for example "C") is "include compatible" with
- -- a language A (for example "C++") if it is expected that sources of
- -- language A may "include" header files from language B.
+ -- List of languages that are "include compatible" with this language. A
+ -- language B (for example "C") is "include compatible" with a language
+ -- A (for example "C++") if it is expected that sources of language A
+ -- may "include" header files from language B.
Compiler_Driver : File_Name_Type := No_File;
-- The name of the executable for the compiler of the language
-- The list of final switches that are required as a minimum to invoke
-- the compiler driver.
- Path_Syntax : Path_Syntax_Kind := Host;
+ Multi_Unit_Switches : Name_List_Index := No_Name_List;
+ -- The switch(es) to indicate the index of a unit in a multi-source file
+
+ Multi_Unit_Object_Separator : Character := ' ';
+ -- The string separating the base name of a source from the index of the
+ -- unit in a multi-source file, in the object file name.
+
+ Path_Syntax : Path_Syntax_Kind := Host;
-- Value may be Canonical (Unix style) or Host (host syntax, for example
-- on VMS for DEC C).
- Object_File_Suffix : Name_Id := No_Name;
+ Object_File_Suffix : Name_Id := No_Name;
-- Optional alternate object file suffix
- Object_File_Switches : Name_List_Index := No_Name_List;
+ Object_File_Switches : Name_List_Index := No_Name_List;
-- Optional object file switches. When this is defined, the switches
-- are used to specify the object file. The object file name is appended
-- to the last switch in the list. Example: ("-o", "").
-- shared libraries. Specified in the configuration. When not specified,
-- there is no need for such switch.
- Object_Generated : Boolean := True;
+ Object_Generated : Boolean := True;
-- False in no object file is generated
- Objects_Linked : Boolean := True;
+ Objects_Linked : Boolean := True;
-- False if object files are not use to link executables and build
-- libraries.
- Runtime_Library_Dir : Name_Id := No_Name;
+ Runtime_Library_Dir : Name_Id := No_Name;
-- Path name of the runtime library directory, if any
- Runtime_Source_Dir : Name_Id := No_Name;
+ Runtime_Source_Dir : Name_Id := No_Name;
-- Path name of the runtime source directory, if any
- Mapping_File_Switches : Name_List_Index := No_Name_List;
+ Mapping_File_Switches : Name_List_Index := No_Name_List;
-- The option(s) to provide a mapping file to the compiler. Specified in
-- the configuration. When value is No_Name_List, there is no mapping
-- file.
- Mapping_Spec_Suffix : File_Name_Type := No_File;
+ Mapping_Spec_Suffix : File_Name_Type := No_File;
-- Placeholder representing the spec suffix in a mapping file
- Mapping_Body_Suffix : File_Name_Type := No_File;
+ Mapping_Body_Suffix : File_Name_Type := No_File;
-- Placeholder representing the body suffix in a mapping file
- Config_File_Switches : Name_List_Index := No_Name_List;
+ Config_File_Switches : Name_List_Index := No_Name_List;
-- The option(s) to provide a config file to the compiler. Specified in
- -- the configuration. When value is No_Name_List, there is no config
- -- file.
+ -- the configuration. If value is No_Name_List there is no config file.
- Dependency_Kind : Dependency_File_Kind := None;
+ Dependency_Kind : Dependency_File_Kind := None;
-- The kind of dependency to be checked: none, Makefile fragment or
-- ALI file (for Ada).
- Dependency_Option : Name_List_Index := No_Name_List;
+ Dependency_Option : Name_List_Index := No_Name_List;
-- The option(s) to be used to create the dependency file. When value is
-- No_Name_List, there is not such option(s).
- Compute_Dependency : Name_List_Index := No_Name_List;
+ Compute_Dependency : Name_List_Index := No_Name_List;
-- Hold the value of attribute Dependency_Driver, if declared for the
-- language.
- Include_Option : Name_List_Index := No_Name_List;
+ Include_Option : Name_List_Index := No_Name_List;
-- Hold the value of attribute Include_Switches, if declared for the
-- language.
-- Name of environment variable declared by attribute Objects_Path_File
-- for the language.
- Config_Body : Name_Id := No_Name;
+ Config_Body : Name_Id := No_Name;
-- The template for a pragma Source_File_Name(_Project) for a specific
-- file name of a body.
- Config_Spec : Name_Id := No_Name;
+ Config_Body_Index : Name_Id := No_Name;
-- The template for a pragma Source_File_Name(_Project) for a specific
- -- file name of a spec.
+ -- file name of a body in a multi-source file.
- Config_Body_Pattern : Name_Id := No_Name;
+ Config_Body_Pattern : Name_Id := No_Name;
-- The template for a pragma Source_File_Name(_Project) for a naming
-- body pattern.
- Config_Spec_Pattern : Name_Id := No_Name;
+ Config_Spec : Name_Id := No_Name;
+ -- The template for a pragma Source_File_Name(_Project) for a specific
+ -- file name of a spec.
+
+ Config_Spec_Index : Name_Id := No_Name;
+ -- The template for a pragma Source_File_Name(_Project) for a specific
+ -- file name of a spec in a multi-source file.
+
+ Config_Spec_Pattern : Name_Id := No_Name;
-- The template for a pragma Source_File_Name(_Project) for a naming
-- spec pattern.
- Config_File_Unique : Boolean := False;
+ Config_File_Unique : Boolean := False;
-- Indicate if the config file specified to the compiler needs to be
-- unique. If it is unique, then all config files are concatenated into
-- a temp config file.
- Binder_Driver : File_Name_Type := No_File;
+ Binder_Driver : File_Name_Type := No_File;
-- The name of the binder driver for the language, if any
- Binder_Driver_Path : Path_Name_Type := No_Path;
+ Binder_Driver_Path : Path_Name_Type := No_Path;
-- The path name of the binder driver
- Binder_Required_Switches : Name_List_Index := No_Name_List;
+ Binder_Required_Switches : Name_List_Index := No_Name_List;
-- Hold the value of attribute Binder'Required_Switches for the language
- Binder_Prefix : Name_Id := No_Name;
+ Binder_Prefix : Name_Id := No_Name;
-- Hold the value of attribute Binder'Prefix for the language
- Toolchain_Version : Name_Id := No_Name;
+ Toolchain_Version : Name_Id := No_Name;
-- Hold the value of attribute Toolchain_Version for the language
- Toolchain_Description : Name_Id := No_Name;
+ Toolchain_Description : Name_Id := No_Name;
-- Hold the value of attribute Toolchain_Description for the language
end record;
- -- Record describing the configuration of a language
No_Language_Config : constant Language_Config :=
(Kind => File_Based,
Compiler_Driver_Path => null,
Compiler_Leading_Required_Switches => No_Name_List,
Compiler_Trailing_Required_Switches => No_Name_List,
+ Multi_Unit_Switches => No_Name_List,
+ Multi_Unit_Object_Separator => ' ',
Path_Syntax => Canonical,
Object_File_Suffix => No_Name,
Object_File_Switches => No_Name_List,
Mapping_Spec_Suffix => No_File,
Mapping_Body_Suffix => No_File,
Config_File_Switches => No_Name_List,
- Dependency_Kind => Makefile,
+ Dependency_Kind => None,
Dependency_Option => No_Name_List,
Compute_Dependency => No_Name_List,
Include_Option => No_Name_List,
Objects_Path => No_Name,
Objects_Path_File => No_Name,
Config_Body => No_Name,
- Config_Spec => No_Name,
+ Config_Body_Index => No_Name,
Config_Body_Pattern => No_Name,
+ Config_Spec => No_Name,
+ Config_Spec_Index => No_Name,
Config_Spec_Pattern => No_Name,
Config_File_Unique => False,
Binder_Driver => No_File,
Toolchain_Version => No_Name,
Toolchain_Description => No_Name);
+ -- The following record ???
+
type Language_Data is record
Name : Name_Id := No_Name;
Display_Name : Name_Id := No_Name;
type Source_Kind is (Spec, Impl, Sep);
subtype Spec_Or_Body is Source_Kind range Spec .. Impl;
+ -- The following declarations declare a structure used to store the Name
+ -- and File and Path names of a unit, with a reference to its GNAT Project
+ -- File(s). Some units might have neither Spec nor Impl when they were
+ -- created for a "separate".
+
type File_Names_Data is array (Spec_Or_Body) of Source_Id;
+
type Unit_Data is record
Name : Name_Id := No_Name;
File_Names : File_Names_Data;
end record;
- type Unit_Index is access Unit_Data;
+
+ type Unit_Index is access all Unit_Data;
+
No_Unit_Index : constant Unit_Index := null;
- -- Name and File and Path names of a unit, with a reference to its
- -- GNAT Project File(s).
+ -- Used to indicate a null entry for no unit
+
+ -- Structure to define source data
type Source_Data is record
- Project : Project_Id := No_Project;
+ Project : Project_Id := No_Project;
-- Project of the source
- Language : Language_Ptr := No_Language_Index;
+ Location : Source_Ptr := No_Location;
+ -- Location in the project file of the declaration of the source in
+ -- package Naming.
+
+ Source_Dir_Rank : Natural := 0;
+ -- The rank of the source directory in list declared with attribute
+ -- Source_Dirs. Two source files with the same name cannot appears in
+ -- different directory with the same rank. That can happen when the
+ -- recursive notation <dir>/** is used in attribute Source_Dirs.
+
+ Language : Language_Ptr := No_Language_Index;
-- Index of the language. This is an index into
-- Project_Tree.Languages_Data.
- In_Interfaces : Boolean := True;
+ In_Interfaces : Boolean := True;
-- False when the source is not included in interfaces, when attribute
-- Interfaces is declared.
- Declared_In_Interfaces : Boolean := False;
+ Declared_In_Interfaces : Boolean := False;
-- True when source is declared in attribute Interfaces
- Alternate_Languages : Language_List;
+ Alternate_Languages : Language_List := null;
-- List of languages a header file may also be, in addition of language
-- Language_Name.
- Kind : Source_Kind := Spec;
+ Kind : Source_Kind := Spec;
-- Kind of the source: spec, body or subunit
- Unit : Unit_Index := No_Unit_Index;
+ Unit : Unit_Index := No_Unit_Index;
-- Name of the unit, if language is unit based. This is only set for
- -- those finles that are part of the compilation set (for instance a
+ -- those files that are part of the compilation set (for instance a
-- file in an extended project that is overridden will not have this
-- field set).
- Index : Int := 0;
+ Index : Int := 0;
-- Index of the source in a multi unit source file (the same Source_Data
-- is duplicated several times when there are several units in the same
-- file). Index is 0 if there is either no unit or a single one, and
-- starts at 1 when there are multiple units
- Locally_Removed : Boolean := False;
+ Locally_Removed : Boolean := False;
-- True if the source has been "excluded"
- Replaced_By : Source_Id := No_Source;
+ Replaced_By : Source_Id := No_Source;
+ -- Missing comment ???
- File : File_Name_Type := No_File;
+ File : File_Name_Type := No_File;
-- Canonical file name of the source
- Display_File : File_Name_Type := No_File;
+ Display_File : File_Name_Type := No_File;
-- File name of the source, for display purposes
- Path : Path_Information := No_Path_Information;
+ Path : Path_Information := No_Path_Information;
-- Path name of the source
- Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
+ Source_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Time stamp of the source file
- Object_Project : Project_Id := No_Project;
+ Object_Project : Project_Id := No_Project;
-- Project where the object file is. This might be different from
-- Project when using extending project files.
- Object : File_Name_Type := No_File;
+ Object : File_Name_Type := No_File;
-- File name of the object file
- Current_Object_Path : Path_Name_Type := No_Path;
+ Current_Object_Path : Path_Name_Type := No_Path;
-- Object path of an existing object file
- Object_Path : Path_Name_Type := No_Path;
+ Object_Path : Path_Name_Type := No_Path;
-- Object path of the real object file
- Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
+ Object_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Object file time stamp
- Dep_Name : File_Name_Type := No_File;
+ Dep_Name : File_Name_Type := No_File;
-- Dependency file simple name
- Current_Dep_Path : Path_Name_Type := No_Path;
+ Current_Dep_Path : Path_Name_Type := No_Path;
-- Path name of an existing dependency file
- Dep_Path : Path_Name_Type := No_Path;
+ Dep_Path : Path_Name_Type := No_Path;
-- Path name of the real dependency file
- Dep_TS : Time_Stamp_Type := Empty_Time_Stamp;
+ Dep_TS : aliased Osint.File_Attributes := Osint.Unknown_Attributes;
-- Dependency file time stamp
- Switches : File_Name_Type := No_File;
+ Switches : File_Name_Type := No_File;
-- File name of the switches file. For all languages, this is a file
-- that ends with the .cswi extension.
- Switches_Path : Path_Name_Type := No_Path;
+ Switches_Path : Path_Name_Type := No_Path;
-- Path name of the switches file
- Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
+ Switches_TS : Time_Stamp_Type := Empty_Time_Stamp;
-- Switches file time stamp
- Naming_Exception : Boolean := False;
+ Naming_Exception : Boolean := False;
-- True if the source has an exceptional name
- Next_In_Lang : Source_Id := No_Source;
+ Next_In_Lang : Source_Id := No_Source;
-- Link to another source of the same language in the same project
end record;
No_Source_Data : constant Source_Data :=
(Project => No_Project,
+ Location => No_Location,
+ Source_Dir_Rank => 0,
Language => No_Language_Index,
In_Interfaces => True,
Declared_In_Interfaces => False,
Dep_Name => No_File,
Current_Dep_Path => No_Path,
Dep_Path => No_Path,
- Dep_TS => Empty_Time_Stamp,
+ Dep_TS => Osint.Unknown_Attributes,
Switches => No_File,
Switches_Path => No_Path,
Switches_TS => Empty_Time_Stamp,
Equal => "=");
type Verbosity is (Default, Medium, High);
+ pragma Ordered (Verbosity);
-- Verbosity when parsing GNAT Project Files
-- Default is default (very quiet, if no errors).
-- Medium is more verbose.
Symbol_Policy => Autonomous);
-- The default value of the symbol data
- function Image (Casing : Casing_Type) return String;
+ function Image (The_Casing : Casing_Type) return String;
-- Similar to 'Image (but avoid use of this attribute in compiler)
function Value (Image : String) return Casing_Type;
-- The following record contains data for a naming scheme
- type Naming_Data is record
-
- Dot_Replacement : File_Name_Type := No_File;
- -- The string to replace '.' in the source file name (for Ada)
-
- Casing : Casing_Type := All_Lower_Case;
- -- The casing of the source file name (for Ada)
-
- Spec_Suffix : Array_Element_Id := No_Array_Element;
- -- The string to append to the unit name for the
- -- source file name of a spec.
- -- Indexed by the programming language.
-
- Body_Suffix : Array_Element_Id := No_Array_Element;
- -- The string to append to the unit name for the
- -- source file name of a body.
- -- Indexed by the programming language.
-
- Separate_Suffix : File_Name_Type := No_File;
- -- String to append to unit name for source file name of an Ada subunit
-
- end record;
-
- function Spec_Suffix_Of
- (In_Tree : Project_Tree_Ref;
- Language : String;
- Naming : Naming_Data) return String;
-
- function Spec_Suffix_Id_Of
- (In_Tree : Project_Tree_Ref;
- Language_Id : Name_Id;
- Naming : Naming_Data) return File_Name_Type;
-
- procedure Set_Spec_Suffix
- (In_Tree : Project_Tree_Ref;
- Language : String;
- Naming : in out Naming_Data;
- Suffix : File_Name_Type);
-
- function Body_Suffix_Id_Of
- (In_Tree : Project_Tree_Ref;
- Language_Id : Name_Id;
- Naming : Naming_Data) return File_Name_Type;
-
- function Body_Suffix_Of
- (In_Tree : Project_Tree_Ref;
- Language : String;
- Naming : Naming_Data) return String;
-
- procedure Set_Body_Suffix
- (In_Tree : Project_Tree_Ref;
- Language : String;
- Naming : in out Naming_Data;
- Suffix : File_Name_Type);
-
function Get_Object_Directory
(Project : Project_Id;
Including_Libraries : Boolean;
-- If Only_If_Ada is True, then No_Name will be returned when the project
-- doesn't Ada sources.
- procedure Compute_All_Imported_Projects (Project : Project_Id);
- -- Compute, the list of the projects imported directly or indirectly by
- -- project Project. The result is stored in Project.All_Imported_Projects
+ procedure Compute_All_Imported_Projects (Tree : Project_Tree_Ref);
+ -- For all projects in the tree, compute the list of the projects imported
+ -- directly or indirectly by project Project. The result is stored in
+ -- Project.All_Imported_Projects for each project
function Ultimate_Extending_Project_Of
(Proj : Project_Id) return Project_Id;
-- Returns the ultimate extending project of project Proj. If project Proj
-- is not extended, returns Proj.
- function Standard_Naming_Data
- (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data;
- pragma Inline (Standard_Naming_Data);
- -- The standard GNAT naming scheme when Tree is No_Project_Tree.
- -- Otherwise, return the default naming scheme for the project tree Tree,
- -- which must have been Initialized.
-
- function Same_Naming_Scheme
- (Left, Right : Naming_Data) return Boolean;
- -- Returns True if Left and Right are the same naming scheme
- -- not considering Specs and Bodies.
-
type Project_List_Element;
type Project_List is access all Project_List_Element;
type Project_List_Element is record
(None,
GNU,
Object_List,
- Option_List);
+ Option_List,
+ GCC,
+ GCC_GNU,
+ GCC_Object_List,
+ GCC_Option_List);
-- The format of the different response files
type Project_Configuration is record
- Target : Name_Id := No_Name;
+ Target : Name_Id := No_Name;
-- The target of the configuration, when specified
- Run_Path_Option : Name_List_Index := No_Name_List;
+ Run_Path_Option : Name_List_Index := No_Name_List;
-- The option to use when linking to specify the path where to look for
-- libraries.
- Separate_Run_Path_Options : Boolean := False;
+ Run_Path_Origin : Name_Id := No_Name;
+ -- Specify the string (such as "$ORIGIN") to indicate paths relative to
+ -- the directory of the executable in the run path option.
+
+ Library_Install_Name_Option : Name_Id := No_Name;
+ -- When this is not an empty list, this option, followed by the single
+ -- name of the shared library file is used when linking a shared
+ -- library.
+
+ Separate_Run_Path_Options : Boolean := False;
-- True if each directory needs to be specified in a separate run path
-- option.
- Executable_Suffix : Name_Id := No_Name;
+ Executable_Suffix : Name_Id := No_Name;
-- The suffix of executables, when specified in the configuration or in
-- package Builder of the main project. When this is not specified, the
-- executable suffix is the default for the platform.
-- Linking
- Linker : Path_Name_Type := No_Path;
+ Linker : Path_Name_Type := No_Path;
-- Path name of the linker driver. Specified in the configuration or in
-- the package Builder of the main project.
- Map_File_Option : Name_Id := No_Name;
+ Map_File_Option : Name_Id := No_Name;
-- Option to use when invoking the linker to build a map file
- Minimum_Linker_Options : Name_List_Index := No_Name_List;
+ Trailing_Linker_Required_Switches : Name_List_Index := No_Name_List;
-- The minimum options for the linker driver. Specified in the
-- configuration.
- Linker_Executable_Option : Name_List_Index := No_Name_List;
+ Linker_Executable_Option : Name_List_Index := No_Name_List;
-- The option(s) to indicate the name of the executable in the linker
-- command. Specified in the configuration. When not specified, default
-- to -o <executable name>.
- Linker_Lib_Dir_Option : Name_Id := No_Name;
+ Linker_Lib_Dir_Option : Name_Id := No_Name;
-- The option to specify where to find a library for linking. Specified
-- in the configuration. When not specified, defaults to "-L".
- Linker_Lib_Name_Option : Name_Id := No_Name;
+ Linker_Lib_Name_Option : Name_Id := No_Name;
-- The option to specify the name of a library for linking. Specified in
-- the configuration. When not specified, defaults to "-l".
- Max_Command_Line_Length : Natural := 0;
+ Max_Command_Line_Length : Natural := 0;
-- When positive and when Resp_File_Format (see below) is not None,
-- if the command line for the invocation of the linker would be greater
-- than this value, a response file is used to invoke the linker.
- Resp_File_Format : Response_File_Format := None;
+ Resp_File_Format : Response_File_Format := None;
-- The format of a response file, when linking with a response file is
-- supported.
- Resp_File_Options : Name_List_Index := No_Name_List;
+ Resp_File_Options : Name_List_Index := No_Name_List;
-- The switches, if any, that precede the path name of the response
-- file in the invocation of the linker.
-- Libraries
- Library_Builder : Path_Name_Type := No_Path;
+ Library_Builder : Path_Name_Type := No_Path;
-- The executable to build library (specified in the configuration)
- Lib_Support : Library_Support := None;
+ Lib_Support : Library_Support := None;
-- The level of library support. Specified in the configuration. Support
-- is none, static libraries only or both static and shared libraries.
- Archive_Builder : Name_List_Index := No_Name_List;
+ Archive_Builder : Name_List_Index := No_Name_List;
-- The name of the executable to build archives, with the minimum
-- switches. Specified in the configuration.
Archive_Builder_Append_Option : Name_List_Index := No_Name_List;
-- The options to append object files to an archive
- Archive_Indexer : Name_List_Index := No_Name_List;
+ Archive_Indexer : Name_List_Index := No_Name_List;
-- The name of the executable to index archives, with the minimum
-- switches. Specified in the configuration.
- Archive_Suffix : File_Name_Type := No_File;
+ Archive_Suffix : File_Name_Type := No_File;
-- The suffix of archives. Specified in the configuration. When not
-- specified, defaults to ".a".
- Lib_Partial_Linker : Name_List_Index := No_Name_List;
+ Lib_Partial_Linker : Name_List_Index := No_Name_List;
-- Shared libraries
- Shared_Lib_Driver : File_Name_Type := No_File;
+ Shared_Lib_Driver : File_Name_Type := No_File;
-- The driver to link shared libraries. Set with attribute Library_GCC.
-- Default to gcc.
- Shared_Lib_Prefix : File_Name_Type := No_File;
+ Shared_Lib_Prefix : File_Name_Type := No_File;
-- Part of a shared library file name that precedes the name of the
-- library. Specified in the configuration. When not specified, defaults
-- to "lib".
- Shared_Lib_Suffix : File_Name_Type := No_File;
+ Shared_Lib_Suffix : File_Name_Type := No_File;
-- Suffix of shared libraries, after the library name in the shared
-- library name. Specified in the configuration. When not specified,
-- default to ".so".
- Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
+ Shared_Lib_Min_Options : Name_List_Index := No_Name_List;
-- The minimum options to use when building a shared library
- Lib_Version_Options : Name_List_Index := No_Name_List;
+ Lib_Version_Options : Name_List_Index := No_Name_List;
-- The options to use to specify a library version
- Symbolic_Link_Supported : Boolean := False;
+ Symbolic_Link_Supported : Boolean := False;
-- True if the platform supports symbolic link files
- Lib_Maj_Min_Id_Supported : Boolean := False;
+ Lib_Maj_Min_Id_Supported : Boolean := False;
-- True if platform supports library major and minor options, such as
-- libname.so -> libname.so.2 -> libname.so.2.4
- Auto_Init_Supported : Boolean := False;
+ Auto_Init_Supported : Boolean := False;
-- True if automatic initialisation is supported for shared stand-alone
-- libraries.
end record;
Default_Project_Config : constant Project_Configuration :=
(Target => No_Name,
Run_Path_Option => No_Name_List,
+ Run_Path_Origin => No_Name,
+ Library_Install_Name_Option => No_Name,
Separate_Run_Path_Options => False,
Executable_Suffix => No_Name,
Linker => No_Path,
Map_File_Option => No_Name,
- Minimum_Linker_Options => No_Name_List,
+ Trailing_Linker_Required_Switches =>
+ No_Name_List,
Linker_Executable_Option => No_Name_List,
Linker_Lib_Dir_Option => No_Name,
Linker_Lib_Name_Option => No_Name,
Location : Source_Ptr := No_Location;
-- The location in the project file source of the reserved word project
- Naming : Naming_Data := Standard_Naming_Data;
- -- The naming scheme of this project file
-
---------------
-- Languages --
---------------
-- The list of all directly imported projects, if any
All_Imported_Projects : Project_List;
- -- The list of all projects imported directly or indirectly, if any
+ -- The list of all projects imported directly or indirectly, if any.
+ -- This does not include the project itself.
-----------------
-- Directories --
-- The sources for all languages including Ada are accessible through
-- the Source_Iterator type
- Interfaces_Defined : Boolean := False;
+ Interfaces_Defined : Boolean := False;
-- True if attribute Interfaces is declared for the project or any
-- project it extends.
- 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
- -- (<language>). The names of the environment variables are in component
- -- Include_Path of the records Language_Config.
-
Include_Path_File : Path_Name_Type := No_Path;
- -- The path name of the of the source search directory file
-
- Include_Data_Set : Boolean := False;
- -- Set True when Imported_Directories_Switches or Include_Path are set
+ -- The path name of the of the source search directory file.
+ -- This is only used by gnatmake
Source_Dirs : String_List_Id := Nil_String;
-- The list of all the source directories
- Known_Order_Of_Source_Dirs : Boolean := True;
- -- False, if there is any /** in the Source_Dirs, because in this case
- -- the ordering of the source subdirs depend on the OS. If True,
- -- duplicate file names in the same project file are allowed.
+ Source_Dir_Ranks : Number_List_Index := No_Number_List;
Ada_Include_Path : String_Access := null;
-- The cached value of source search path for this project file. Set by
-- use this field directly outside of the project manager, use
-- Prj.Env.Ada_Include_Path instead.
+ Has_Multi_Unit_Sources : Boolean := False;
+ -- Whether there is at least one source file containing multiple units
+
-------------------
-- Miscellaneous --
-------------------
end record;
- function Empty_Project (Tree : Project_Tree_Ref) return Project_Data;
- -- Return the representation of an empty project in project Tree tree.
- -- The project tree Tree must have been Initialized and/or Reset.
+ function Empty_Project return Project_Data;
+ -- Return the representation of an empty project
function Is_Extending
(Extending : Project_Id;
Extended : Project_Id) return Boolean;
-- Return True if Extending is extending the Extended project
- function Is_A_Language
- (Project : Project_Id;
- Language_Name : Name_Id) return Boolean;
- -- Return True when Language_Name (which must be lower case) is one of the
- -- languages used for the project.
-
function Has_Ada_Sources (Data : Project_Id) return Boolean;
-- Return True if the project has Ada sources
- function Has_Foreign_Sources (Data : Project_Id) return Boolean;
- -- Return True if the project has foreign sources
-
Project_Error : exception;
-- Raised by some subprograms in Prj.Attr
Equal => "=");
-- Mapping of unit names to indexes in the Units table
- package Files_Htable is new Simple_HTable
- (Header_Num => Header_Num,
- Element => Project_Id,
- No_Element => No_Project,
- Key => File_Name_Type,
- Hash => Hash,
- Equal => "=");
- -- Mapping of file names to indexes in the Units table
-
---------------------
-- Source_Iterator --
---------------------
procedure Next (Iter : in out Source_Iterator);
-- Move on to the next source
+ function Find_Source
+ (In_Tree : Project_Tree_Ref;
+ Project : Project_Id;
+ In_Imported_Only : Boolean := False;
+ In_Extended_Only : Boolean := False;
+ Base_Name : File_Name_Type) return Source_Id;
+ -- Find the first source file with the given name either in the whole tree
+ -- (if In_Imported_Only is False) or in the projects imported or extended
+ -- by Project otherwise. In_Extended_Only implies In_Imported_Only, and
+ -- will only look in Project and the projects it extends
+
-----------------------
-- Project_Tree_Data --
-----------------------
type Project_Tree_Data is
record
Name_Lists : Name_List_Table.Instance;
+ Number_Lists : Number_List_Table.Instance;
String_Elements : String_Element_Table.Instance;
Variable_Elements : Variable_Element_Table.Instance;
Array_Elements : Array_Element_Table.Instance;
Arrays : Array_Table.Instance;
Packages : Package_Table.Instance;
Projects : Project_List;
+
Units_HT : Units_Htable.Instance;
+ -- Unit name to Unit_Index (and from there so Source_Id)
+
Source_Paths_HT : Source_Paths_Htable.Instance;
- Unit_Sources_HT : Unit_Sources_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
- -- Private part
+ Source_Info_File_Exists : Boolean := False;
+ -- True when a source info file has been successfully read
- Private_Part : Private_Project_Tree_Data;
+ Private_Part : Private_Project_Tree_Data;
end record;
-- Data for a project tree
- type Put_Line_Access is access procedure
- (Line : String;
- Project : Project_Id;
- In_Tree : Project_Tree_Ref);
- -- Use to customize error reporting in Prj.Proc and Prj.Nmsc
-
procedure Expect (The_Token : Token_Type; Token_Image : String);
-- Check that the current token is The_Token. If it is not, then output
-- an error message.
-- This procedure resets all the tables that are used when processing a
-- project file tree. Initialize must be called before the call to Reset.
- procedure Register_Default_Naming_Scheme
- (Language : Name_Id;
- Default_Spec_Suffix : File_Name_Type;
- Default_Body_Suffix : File_Name_Type;
- In_Tree : Project_Tree_Ref);
- -- Register the default suffixes for a given language. These extensions
- -- will be ignored if the user has specified a new naming scheme in a
- -- project file.
- --
- -- Otherwise, this information will be automatically added to Naming_Data
- -- when a project is processed, in the lists Spec_Suffix and Body_Suffix.
-
package Project_Boolean_Htable is new Simple_HTable
(Header_Num => Header_Num,
Element => Boolean,
Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
-- Returns the object file name corresponding to a source file name
+ function Object_Name
+ (Source_File_Name : File_Name_Type;
+ Source_Index : Int;
+ Index_Separator : Character;
+ Object_File_Suffix : Name_Id := No_Name) return File_Name_Type;
+ -- Returns the object file name corresponding to a unit in a multi-source
+ -- file.
+
function Dependency_Name
(Source_File_Name : File_Name_Type;
Dependency : Dependency_File_Kind) return File_Name_Type;
(Source_File_Name : File_Name_Type) return File_Name_Type;
-- Returns the switches file name corresponding to a source file name
+ -----------
+ -- Flags --
+ -----------
+
+ type Processing_Flags is private;
+ -- Flags used while parsing and processing a project tree to configure the
+ -- behavior of the parser, and indicate how to report error messages. This
+ -- structure does not allocate memory and never needs to be freed
+
+ type Error_Warning is (Silent, Warning, Error);
+ -- Severity of some situations, such as: no Ada sources in a project where
+ -- Ada is one of the language.
+ --
+ -- When the situation occurs, the behaviour depends on the setting:
+ --
+ -- - Silent: no action
+ -- - Warning: issue a warning, does not cause the tool to fail
+ -- - Error: issue an error, causes the tool to fail
+
+ type Error_Handler is access procedure
+ (Project : Project_Id;
+ Is_Warning : Boolean);
+ -- This warngs when an error was found when parsing a project. The error
+ -- itself is handled through Prj.Err (and Prj.Err.Finalize should be called
+ -- to actually print the error). This ensures that duplicate error messages
+ -- are always correctly removed, that errors msgs are sorted, and that all
+ -- tools will report the same error to the user.
+
+ function Create_Flags
+ (Report_Error : Error_Handler;
+ When_No_Sources : Error_Warning;
+ Require_Sources_Other_Lang : Boolean := True;
+ Allow_Duplicate_Basenames : Boolean := True;
+ Compiler_Driver_Mandatory : Boolean := False;
+ Error_On_Unknown_Language : Boolean := True;
+ Require_Obj_Dirs : Error_Warning := Error;
+ Allow_Invalid_External : Error_Warning := Error;
+ Missing_Source_Files : Error_Warning := Error)
+ return Processing_Flags;
+ -- Function used to create Processing_Flags structure
+ --
+ -- If Allow_Duplicate_Basenames, then files with the same base names are
+ -- authorized within a project for source-based languages (never for unit
+ -- based languages).
+ --
+ -- If Compiler_Driver_Mandatory is true, then a Compiler.Driver attribute
+ -- for each language must be defined, or we will not look for its source
+ -- files.
+ --
+ -- When_No_Sources indicates what should be done when no sources of a
+ -- language are found in a project where this language is declared.
+ -- If Require_Sources_Other_Lang is true, then all languages must have at
+ -- least one source file, or an error is reported via When_No_Sources. If
+ -- it is false, this is only required for Ada (and only if it is a language
+ -- of the project). When this parameter is set to False, we do not check
+ -- that a proper naming scheme is defined for languages other than Ada.
+ --
+ -- If Report_Error is null, use the standard error reporting mechanism
+ -- (Errout). Otherwise, report errors using Report_Error.
+ --
+ -- If Error_On_Unknown_Language is true, an error is displayed if some of
+ -- the source files listed in the project do not match any naming scheme
+ --
+ -- If Require_Obj_Dirs is true, then all object directories must exist
+ -- (possibly after they have been created automatically if the appropriate
+ -- switches were specified), or an error is raised.
+ --
+ -- If Allow_Invalid_External is Silent, then no error is reported when an
+ -- invalid value is used for an external variable (and it doesn't match its
+ -- type). Instead, the first possible value is used.
+ --
+ -- Missing_Source_Files indicates whether it is an error or a warning that
+ -- a source file mentioned in the Source_Files attributes is not actually
+ -- found in the source directories. This also impacts errors for missing
+ -- source directories.
+
+ Gprbuild_Flags : constant Processing_Flags;
+ Gprclean_Flags : constant Processing_Flags;
+ Gnatmake_Flags : constant Processing_Flags;
+ -- Flags used by the various tools. They all display the error messages
+ -- through Prj.Err.
+
----------------
-- Temp Files --
----------------
- procedure Record_Temp_File (Path : Path_Name_Type);
+ procedure Record_Temp_File
+ (Tree : Project_Tree_Ref;
+ Path : Path_Name_Type);
-- Record the path of a newly created temporary file, so that it can be
-- deleted later.
- procedure Delete_All_Temp_Files;
- -- Delete all recorded temporary files
+ procedure Delete_All_Temp_Files (Tree : Project_Tree_Ref);
+ -- Delete all recorded temporary files.
+ -- Does nothing if Debug.Debug_Flag_N is set
+
+ procedure Delete_Temporary_File
+ (Tree : Project_Tree_Ref;
+ Path : Path_Name_Type);
+ -- Delete a temporary file from the disk. The file is also removed from the
+ -- list of temporary files to delete at the end of the program, in case
+ -- another program running on the same machine has recreated it.
+ -- Does nothing if Debug.Debug_Flag_N is set
+
+ Virtual_Prefix : constant String := "v$";
+ -- The prefix for virtual extending projects. Because of the '$', which is
+ -- normally forbidden for project names, there cannot be any name clash.
private
Location => No_Location,
Default => False);
- Virtual_Prefix : constant String := "v$";
- -- The prefix for virtual extending projects. Because of the '$', which is
- -- normally forbidden for project names, there cannot be any name clash.
-
- Empty_Name : Name_Id;
- -- Name_Id for an empty name (no characters). Initialized in procedure
- -- Initialize.
-
- Empty_File_Name : File_Name_Type;
- -- Empty File_Name_Type (no characters). Initialized in procedure
- -- Initialize.
-
type Source_Iterator is record
In_Tree : Project_Tree_Ref;
Last : in out Natural);
-- Append a String to the Buffer
- type Naming_Id is new Nat;
-
- package Naming_Table is new GNAT.Dynamic_Tables
- (Table_Component_Type => Naming_Data,
- Table_Index_Type => Naming_Id,
- Table_Low_Bound => 1,
- Table_Initial => 5,
- Table_Increment => 100);
- -- Table storing the naming data for gnatmake/gprmake
-
- package Path_File_Table is new GNAT.Dynamic_Tables
- (Table_Component_Type => Path_Name_Type,
- Table_Index_Type => Natural,
- Table_Low_Bound => 1,
- Table_Initial => 50,
- Table_Increment => 100);
- -- Table storing all the temp path file names.
- -- Used by Delete_All_Path_Files.
-
- package Source_Path_Table is new GNAT.Dynamic_Tables
- (Table_Component_Type => Name_Id,
- Table_Index_Type => Natural,
- Table_Low_Bound => 1,
- Table_Initial => 50,
- Table_Increment => 100);
- -- A table to store the source dirs before creating the source path file
-
- package Object_Path_Table is new GNAT.Dynamic_Tables
+ package Temp_Files_Table is new GNAT.Dynamic_Tables
(Table_Component_Type => Path_Name_Type,
- Table_Index_Type => Natural,
+ Table_Index_Type => Integer,
Table_Low_Bound => 1,
- Table_Initial => 50,
- Table_Increment => 100);
- -- A table to store the object dirs, before creating the object path file
+ Table_Initial => 10,
+ Table_Increment => 10);
+ -- Table to store the path name of all the created temporary files, so that
+ -- they can be deleted at the end, or when the program is interrupted.
type Private_Project_Tree_Data is record
- Namings : Naming_Table.Instance;
- Path_Files : Path_File_Table.Instance;
- Source_Paths : Source_Path_Table.Instance;
- Object_Paths : Object_Path_Table.Instance;
- Default_Naming : Naming_Data;
+ Temp_Files : Temp_Files_Table.Instance;
+ -- Temporary files created as part of running tools (pragma files,
+ -- mapping files,...)
Current_Source_Path_File : Path_Name_Type := No_Path;
-- Current value of project source path file env var. Used to avoid
- -- setting the env var to the same value.
+ -- setting the env var to the same value. When different from No_Path,
+ -- this indicates that logical names (VMS) or environment variables were
+ -- created and should be deassigned to avoid polluting the environment
+ -- on VMS.
+ -- gnatmake only
Current_Object_Path_File : Path_Name_Type := No_Path;
-- Current value of project object path file env var. Used to avoid
-- setting the env var to the same value.
-
- Ada_Path_Buffer : String_Access := new String (1 .. 1024);
- -- A buffer where values for ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are
- -- stored.
-
- Ada_Path_Length : Natural := 0;
- -- Index of the last valid character in Ada_Path_Buffer
-
- Ada_Prj_Include_File_Set : Boolean := False;
- Ada_Prj_Objects_File_Set : Boolean := False;
- -- These flags are set to True when the corresponding environment
- -- variables are set and are used to give these environment variables an
- -- empty string value at the end of the program. This has no practical
- -- effect on most platforms, except on VMS where the logical names are
- -- deassigned, thus avoiding the pollution of the environment of the
- -- caller.
-
- Fill_Mapping_File : Boolean := True;
+ -- gnatmake only
end record;
-- Type to represent the part of a project tree which is private to the
-- Project Manager.
+ type Processing_Flags is record
+ Require_Sources_Other_Lang : Boolean;
+ Report_Error : Error_Handler;
+ When_No_Sources : Error_Warning;
+ Allow_Duplicate_Basenames : Boolean;
+ Compiler_Driver_Mandatory : Boolean;
+ Error_On_Unknown_Language : Boolean;
+ Require_Obj_Dirs : Error_Warning;
+ Allow_Invalid_External : Error_Warning;
+ Missing_Source_Files : Error_Warning;
+ end record;
+
+ Gprbuild_Flags : constant Processing_Flags :=
+ (Report_Error => null,
+ When_No_Sources => Warning,
+ Require_Sources_Other_Lang => True,
+ Allow_Duplicate_Basenames => False,
+ Compiler_Driver_Mandatory => True,
+ Error_On_Unknown_Language => True,
+ Require_Obj_Dirs => Error,
+ Allow_Invalid_External => Error,
+ Missing_Source_Files => Error);
+
+ Gprclean_Flags : constant Processing_Flags :=
+ (Report_Error => null,
+ When_No_Sources => Warning,
+ Require_Sources_Other_Lang => True,
+ Allow_Duplicate_Basenames => False,
+ Compiler_Driver_Mandatory => True,
+ Error_On_Unknown_Language => True,
+ Require_Obj_Dirs => Warning,
+ Allow_Invalid_External => Error,
+ Missing_Source_Files => Error);
+
+ Gnatmake_Flags : constant Processing_Flags :=
+ (Report_Error => null,
+ When_No_Sources => Error,
+ Require_Sources_Other_Lang => False,
+ Allow_Duplicate_Basenames => False,
+ Compiler_Driver_Mandatory => False,
+ Error_On_Unknown_Language => False,
+ Require_Obj_Dirs => Error,
+ Allow_Invalid_External => Error,
+ Missing_Source_Files => Error);
+
end Prj;