@@ -30,6 +30,7 @@ with GNAT.OS_Lib;
30
30
with GNATCOLL.Utils ; use GNATCOLL.Utils;
31
31
32
32
with GPR2.Containers ;
33
+ with GPR2.Environment ;
33
34
with GPR2.Log ;
34
35
with GPR2.Message ;
35
36
with GPR2.Project.Registry.Attribute ;
@@ -315,12 +316,12 @@ package body LSP.Ada_Handlers is
315
316
-- Load the implicit project
316
317
317
318
procedure Load_Project
318
- (Self : access Message_Handler;
319
- Project_File : VSS.Strings.Virtual_String;
320
- Search_Path : VSS.String_Vectors.Virtual_String_Vector ;
321
- Scenario : Scenario_Variable_List ;
322
- Charset : VSS.Strings.Virtual_String;
323
- Status : Load_Project_Status);
319
+ (Self : access Message_Handler;
320
+ Project_File : VSS.Strings.Virtual_String;
321
+ Scenario : Scenario_Variable_List ;
322
+ Environment : GPR2.Environment.Object ;
323
+ Charset : VSS.Strings.Virtual_String;
324
+ Status : Load_Project_Status);
324
325
-- Attempt to load the given project file, with the scenario provided.
325
326
-- This unloads all currently loaded project contexts. This factorizes code
326
327
-- between Load_Project_With_Alire and Ensure_Project_Loaded.
@@ -807,8 +808,8 @@ package body LSP.Ada_Handlers is
807
808
808
809
Self.Load_Project
809
810
(Project_File,
810
- VSS.String_Vectors.Empty_Virtual_String_Vector ,
811
- No_Scenario_Variable ,
811
+ Self.Scenario_Variables ,
812
+ GPR2.Environment.Process_Environment ,
812
813
" iso-8859-1" ,
813
814
Single_Project_Found);
814
815
else
@@ -4853,12 +4854,12 @@ package body LSP.Ada_Handlers is
4853
4854
-- ----------------
4854
4855
4855
4856
procedure Load_Project
4856
- (Self : access Message_Handler;
4857
- Project_File : VSS.Strings.Virtual_String;
4858
- Search_Path : VSS.String_Vectors.Virtual_String_Vector ;
4859
- Scenario : Scenario_Variable_List ;
4860
- Charset : VSS.Strings.Virtual_String;
4861
- Status : Load_Project_Status)
4857
+ (Self : access Message_Handler;
4858
+ Project_File : VSS.Strings.Virtual_String;
4859
+ Scenario : Scenario_Variable_List ;
4860
+ Environment : GPR2.Environment.Object ;
4861
+ Charset : VSS.Strings.Virtual_String;
4862
+ Status : Load_Project_Status)
4862
4863
is
4863
4864
Errors : LSP.Messages.ShowMessageParams;
4864
4865
Error_Text : VSS.String_Vectors.Virtual_String_Vector;
@@ -4956,7 +4957,7 @@ package body LSP.Ada_Handlers is
4956
4957
end Create_Context_For_Non_Aggregate ;
4957
4958
4958
4959
GPR : Virtual_File := To_Virtual_File (Project_File);
4959
- Default_Environment : Environment;
4960
+ Default_Environment : LSP.Ada_Handlers. Environment;
4960
4961
4961
4962
Relocate_Build_Tree : constant Virtual_File :=
4962
4963
To_Virtual_File (Self.Relocate_Build_Tree);
@@ -4997,31 +4998,20 @@ package body LSP.Ada_Handlers is
4997
4998
end if ;
4998
4999
end if ;
4999
5000
5000
- -- Update scenario variables
5001
+ -- Update scenario variables with user provided values
5001
5002
for J in 1 .. Scenario.Names.Length loop
5002
5003
Self.Project_Environment.Context.Insert
5003
5004
(GPR2.Optional_Name_Type
5004
5005
(VSS.Strings.Conversions.To_UTF_8_String (Scenario.Names (J))),
5005
5006
VSS.Strings.Conversions.To_UTF_8_String (Scenario.Values (J)));
5006
5007
end loop ;
5007
5008
5008
- -- Update project search path
5009
- for Item of Search_Path loop
5010
- declare
5011
- Value : constant GPR2.Path_Name.Object :=
5012
- GPR2.Path_Name.Create_Directory
5013
- (GPR2.Filename_Type
5014
- (VSS.Strings.Conversions.To_UTF_8_String (Item)));
5015
- begin
5016
- Self.Project_Tree.Register_Project_Search_Path (Value);
5017
- end ;
5018
- end loop ;
5019
-
5020
5009
begin
5021
5010
Self.Project_Tree.Load_Autoconf
5022
- (Filename => GPR2.Path_Name.Create (GPR),
5023
- Context => Self.Project_Environment.Context,
5024
- Build_Path => Self.Project_Environment.Build_Path);
5011
+ (Filename => GPR2.Path_Name.Create (GPR),
5012
+ Context => Self.Project_Environment.Context,
5013
+ Build_Path => Self.Project_Environment.Build_Path,
5014
+ Environment => Environment);
5025
5015
5026
5016
Self.Project_Tree.Update_Sources (With_Runtime => True);
5027
5017
@@ -5101,10 +5091,11 @@ package body LSP.Ada_Handlers is
5101
5091
Status : Load_Project_Status;
5102
5092
Errors : VSS.Strings.Virtual_String;
5103
5093
Project : VSS.Strings.Virtual_String := Project_File;
5104
- Search_Path : VSS.String_Vectors.Virtual_String_Vector;
5105
- Scenario : Scenario_Variable_List := Scenario_Variables;
5106
5094
UTF_8 : constant VSS.Strings.Virtual_String := " utf-8" ;
5107
5095
5096
+ Environment : GPR2.Environment.Object :=
5097
+ GPR2.Environment.Process_Environment;
5098
+
5108
5099
Alire_TOML : constant GNATCOLL.VFS.Virtual_File :=
5109
5100
Self.Root.Create_From_Dir (" alire.toml" );
5110
5101
begin
@@ -5121,8 +5112,7 @@ package body LSP.Ada_Handlers is
5121
5112
Has_Alire => Has_Alire,
5122
5113
Error => Errors,
5123
5114
Project => Project,
5124
- Search_Path => Search_Path,
5125
- Scenario => Scenario);
5115
+ Environment => Environment);
5126
5116
5127
5117
Status := Alire_Project;
5128
5118
else
@@ -5131,8 +5121,7 @@ package body LSP.Ada_Handlers is
5131
5121
(Root => Self.Root.Display_Full_Name,
5132
5122
Has_Alire => Has_Alire,
5133
5123
Error => Errors,
5134
- Search_Path => Search_Path,
5135
- Scenario => Scenario);
5124
+ Environment => Environment);
5136
5125
5137
5126
Status := Valid_Project_Configured;
5138
5127
end if ;
@@ -5164,26 +5153,10 @@ package body LSP.Ada_Handlers is
5164
5153
(Message => " Project:"
5165
5154
& VSS.Strings.Conversions.To_UTF_8_String (Project));
5166
5155
5167
- Self.Trace.Trace (Message => " Search Path:" );
5168
- for Item of Search_Path loop
5169
- Self.Trace.Trace
5170
- (Message => VSS.Strings.Conversions.To_UTF_8_String (Item));
5171
- end loop ;
5172
-
5173
- Self.Trace.Trace (" Scenario:" );
5174
- for J in 1 .. Scenario.Names.Length loop
5175
- Self.Trace.Trace
5176
- (Message => VSS.Strings.Conversions.To_UTF_8_String
5177
- (Scenario.Names (J))
5178
- & " ="
5179
- & VSS.Strings.Conversions.To_UTF_8_String
5180
- (Scenario.Values (J)));
5181
- end loop ;
5182
-
5183
5156
Self.Load_Project
5184
5157
(Project_File => Project,
5185
- Search_Path => Search_Path ,
5186
- Scenario => Scenario ,
5158
+ Scenario => Scenario_Variables ,
5159
+ Environment => Environment ,
5187
5160
Charset => (if Charset.Is_Empty then UTF_8 else Charset),
5188
5161
Status => Status);
5189
5162
-- Alire projects tend to use utf-8
@@ -5199,8 +5172,8 @@ package body LSP.Ada_Handlers is
5199
5172
5200
5173
Self.Load_Project
5201
5174
(Project_File => Project,
5202
- Search_Path => VSS.String_Vectors.Empty_Virtual_String_Vector,
5203
5175
Scenario => Scenario_Variables,
5176
+ Environment => Environment,
5204
5177
Charset => Charset,
5205
5178
Status => Valid_Project_Configured);
5206
5179
end if ;
0 commit comments