@@ -30,6 +30,7 @@ with GNAT.OS_Lib;
3030with GNATCOLL.Utils ; use GNATCOLL.Utils;
3131
3232with GPR2.Containers ;
33+ with GPR2.Environment ;
3334with GPR2.Log ;
3435with GPR2.Message ;
3536with GPR2.Project.Registry.Attribute ;
@@ -315,12 +316,12 @@ package body LSP.Ada_Handlers is
315316 -- Load the implicit project
316317
317318 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);
324325 -- Attempt to load the given project file, with the scenario provided.
325326 -- This unloads all currently loaded project contexts. This factorizes code
326327 -- between Load_Project_With_Alire and Ensure_Project_Loaded.
@@ -807,8 +808,8 @@ package body LSP.Ada_Handlers is
807808
808809 Self.Load_Project
809810 (Project_File,
810- VSS.String_Vectors.Empty_Virtual_String_Vector ,
811- No_Scenario_Variable ,
811+ Self.Scenario_Variables ,
812+ GPR2.Environment.Process_Environment ,
812813 " iso-8859-1" ,
813814 Single_Project_Found);
814815 else
@@ -4853,12 +4854,12 @@ package body LSP.Ada_Handlers is
48534854 -- ----------------
48544855
48554856 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)
48624863 is
48634864 Errors : LSP.Messages.ShowMessageParams;
48644865 Error_Text : VSS.String_Vectors.Virtual_String_Vector;
@@ -4956,7 +4957,7 @@ package body LSP.Ada_Handlers is
49564957 end Create_Context_For_Non_Aggregate ;
49574958
49584959 GPR : Virtual_File := To_Virtual_File (Project_File);
4959- Default_Environment : Environment;
4960+ Default_Environment : LSP.Ada_Handlers. Environment;
49604961
49614962 Relocate_Build_Tree : constant Virtual_File :=
49624963 To_Virtual_File (Self.Relocate_Build_Tree);
@@ -4997,31 +4998,20 @@ package body LSP.Ada_Handlers is
49974998 end if ;
49984999 end if ;
49995000
5000- -- Update scenario variables
5001+ -- Update scenario variables with user provided values
50015002 for J in 1 .. Scenario.Names.Length loop
50025003 Self.Project_Environment.Context.Insert
50035004 (GPR2.Optional_Name_Type
50045005 (VSS.Strings.Conversions.To_UTF_8_String (Scenario.Names (J))),
50055006 VSS.Strings.Conversions.To_UTF_8_String (Scenario.Values (J)));
50065007 end loop ;
50075008
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-
50205009 begin
50215010 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);
50255015
50265016 Self.Project_Tree.Update_Sources (With_Runtime => True);
50275017
@@ -5101,10 +5091,11 @@ package body LSP.Ada_Handlers is
51015091 Status : Load_Project_Status;
51025092 Errors : VSS.Strings.Virtual_String;
51035093 Project : VSS.Strings.Virtual_String := Project_File;
5104- Search_Path : VSS.String_Vectors.Virtual_String_Vector;
5105- Scenario : Scenario_Variable_List := Scenario_Variables;
51065094 UTF_8 : constant VSS.Strings.Virtual_String := " utf-8" ;
51075095
5096+ Environment : GPR2.Environment.Object :=
5097+ GPR2.Environment.Process_Environment;
5098+
51085099 Alire_TOML : constant GNATCOLL.VFS.Virtual_File :=
51095100 Self.Root.Create_From_Dir (" alire.toml" );
51105101 begin
@@ -5121,8 +5112,7 @@ package body LSP.Ada_Handlers is
51215112 Has_Alire => Has_Alire,
51225113 Error => Errors,
51235114 Project => Project,
5124- Search_Path => Search_Path,
5125- Scenario => Scenario);
5115+ Environment => Environment);
51265116
51275117 Status := Alire_Project;
51285118 else
@@ -5131,8 +5121,7 @@ package body LSP.Ada_Handlers is
51315121 (Root => Self.Root.Display_Full_Name,
51325122 Has_Alire => Has_Alire,
51335123 Error => Errors,
5134- Search_Path => Search_Path,
5135- Scenario => Scenario);
5124+ Environment => Environment);
51365125
51375126 Status := Valid_Project_Configured;
51385127 end if ;
@@ -5164,26 +5153,10 @@ package body LSP.Ada_Handlers is
51645153 (Message => " Project:"
51655154 & VSS.Strings.Conversions.To_UTF_8_String (Project));
51665155
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-
51835156 Self.Load_Project
51845157 (Project_File => Project,
5185- Search_Path => Search_Path ,
5186- Scenario => Scenario ,
5158+ Scenario => Scenario_Variables ,
5159+ Environment => Environment ,
51875160 Charset => (if Charset.Is_Empty then UTF_8 else Charset),
51885161 Status => Status);
51895162 -- Alire projects tend to use utf-8
@@ -5199,8 +5172,8 @@ package body LSP.Ada_Handlers is
51995172
52005173 Self.Load_Project
52015174 (Project_File => Project,
5202- Search_Path => VSS.String_Vectors.Empty_Virtual_String_Vector,
52035175 Scenario => Scenario_Variables,
5176+ Environment => Environment,
52045177 Charset => Charset,
52055178 Status => Valid_Project_Configured);
52065179 end if ;
0 commit comments