summaryrefslogtreecommitdiff
path: root/gcc/ada/prj-conf.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/prj-conf.adb')
-rw-r--r--gcc/ada/prj-conf.adb100
1 files changed, 84 insertions, 16 deletions
diff --git a/gcc/ada/prj-conf.adb b/gcc/ada/prj-conf.adb
index 6d5cdc7cc15..206fa4c7228 100644
--- a/gcc/ada/prj-conf.adb
+++ b/gcc/ada/prj-conf.adb
@@ -1584,9 +1584,24 @@ package body Prj.Conf is
Implicit_Project : Boolean := False;
On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
is
+ Success : Boolean := False;
+ Try_Again : Boolean := True;
+
begin
pragma Assert (Prj.Env.Is_Initialized (Env.Project_Path));
+ -- Record Target_Value and Target_Origin.
+
+ if Target_Name = "" then
+ Opt.Target_Value := new String'(Normalized_Hostname);
+ Opt.Target_Origin := Default;
+ else
+ Opt.Target_Value := new String'(Target_Name);
+ Opt.Target_Origin := Specified;
+ end if;
+
+ <<Parse_Again>>
+
-- Parse the user project tree
Prj.Initialize (Project_Tree);
@@ -1609,6 +1624,55 @@ package body Prj.Conf is
return;
end if;
+ -- If --target was not specified on the command line, then do Phase 1 to
+ -- check if attribute Target is declared in the main project.
+
+ if Opt.Target_Origin /= Specified then
+ Main_Project := No_Project;
+ Process_Project_Tree_Phase_1
+ (In_Tree => Project_Tree,
+ Project => Main_Project,
+ Packages_To_Check => Packages_To_Check,
+ Success => Success,
+ From_Project_Node => User_Project_Node,
+ From_Project_Node_Tree => Project_Node_Tree,
+ Env => Env,
+ Reset_Tree => True,
+ On_New_Tree_Loaded => On_New_Tree_Loaded);
+
+ if not Success then
+ Main_Project := No_Project;
+ return;
+ end if;
+
+ declare
+ Variable : constant Variable_Value :=
+ Value_Of
+ (Name_Target,
+ Main_Project.Decl.Attributes,
+ Project_Tree.Shared);
+ begin
+ if Variable /= Nil_Variable_Value
+ and then not Variable.Default
+ and then
+ Get_Name_String (Variable.Value) /= Opt.Target_Value.all
+ then
+ if Try_Again then
+ Opt.Target_Value :=
+ new String'(Get_Name_String (Variable.Value));
+ Try_Again := False;
+ goto Parse_Again;
+
+ else
+ Fail_Program
+ (Project_Tree,
+ "inconsistent value of attribute Target");
+ end if;
+ end if;
+ end;
+
+ end if;
+
Process_Project_And_Apply_Config
(Main_Project => Main_Project,
User_Project_Node => User_Project_Node,
@@ -1624,7 +1688,8 @@ package body Prj.Conf is
Target_Name => Target_Name,
Normalized_Hostname => Normalized_Hostname,
On_Load_Config => On_Load_Config,
- On_New_Tree_Loaded => On_New_Tree_Loaded);
+ On_New_Tree_Loaded => On_New_Tree_Loaded,
+ Do_Phase_1 => Opt.Target_Origin = Specified);
end Parse_Project_And_Apply_Config;
--------------------------------------
@@ -1647,7 +1712,8 @@ package body Prj.Conf is
Normalized_Hostname : String;
On_Load_Config : Config_File_Hook := null;
Reset_Tree : Boolean := True;
- On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null)
+ On_New_Tree_Loaded : Prj.Proc.Tree_Loaded_Callback := null;
+ Do_Phase_1 : Boolean := True)
is
Shared : constant Shared_Project_Tree_Data_Access :=
Project_Tree.Shared;
@@ -1692,23 +1758,25 @@ package body Prj.Conf is
-- Start of processing for Process_Project_And_Apply_Config
begin
- Main_Project := No_Project;
Automatically_Generated := False;
- Process_Project_Tree_Phase_1
- (In_Tree => Project_Tree,
- Project => Main_Project,
- Packages_To_Check => Packages_To_Check,
- Success => Success,
- From_Project_Node => User_Project_Node,
- From_Project_Node_Tree => Project_Node_Tree,
- Env => Env,
- Reset_Tree => Reset_Tree,
- On_New_Tree_Loaded => On_New_Tree_Loaded);
-
- if not Success then
+ if Do_Phase_1 then
Main_Project := No_Project;
- return;
+ Process_Project_Tree_Phase_1
+ (In_Tree => Project_Tree,
+ Project => Main_Project,
+ Packages_To_Check => Packages_To_Check,
+ Success => Success,
+ From_Project_Node => User_Project_Node,
+ From_Project_Node_Tree => Project_Node_Tree,
+ Env => Env,
+ Reset_Tree => Reset_Tree,
+ On_New_Tree_Loaded => On_New_Tree_Loaded);
+
+ if not Success then
+ Main_Project := No_Project;
+ return;
+ end if;
end if;
if Project_Tree.Source_Info_File_Name /= null then