File tree Expand file tree Collapse file tree 7 files changed +112
-0
lines changed
integration/vscode/Code Samples/custom_env Expand file tree Collapse file tree 7 files changed +112
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Workspace-specific environment
2
+
3
+ This folder contains a ` custom_env.code-workspace ` file that setups a custom
4
+ environment for this workspace, setting and modifying some environment variables.
5
+
6
+ In particular it modifies ` GPR_PROJECT_PATH ` environment variable in order
7
+ to be able to build the ` default.gpr ` project, which includes a project
8
+ without specifying a path to it. You can find more information on the
9
+ ` GPR_PROJECT_PATH ` environment variable and on how to import other projects
10
+ [ here] ( https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html?highlight=gpr_project_path#importing-projects ) .
11
+
12
+ It also sets the ` MAIN_NUMBER ` scenario variable to ` MAIN_2 ` when loading
13
+ the workspace, instead of the default ` MAIN_1 ` value.
14
+ More information on scenario variables is available [ here] ( https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html?highlight=gpr_project_path#scenarios-in-projects ) .
15
+
16
+ Note that you can set and/or modify any environment variable, including the
17
+ ` PATH ` if you want to use a different Ada toolchain for this project.
18
+
19
+ # Run the Code Sample
20
+
21
+ Open VS Code and click on the ` File -> Open Workspace From File... ` menu
22
+ and select the ` custom_env.code-workspace ` file present in this folder.
23
+
24
+ You can then build the project by clicking on the ` Terminal -> Run Task... ` menu,
25
+ and by selecting the ` gprbuild -> ada: Build current project ` task.
Original file line number Diff line number Diff line change
1
+ {
2
+ "folders" : [
3
+ {
4
+ "path" : " ."
5
+ }
6
+ ],
7
+ "settings" : {
8
+ "ada.projectFile" : " default.gpr" ,
9
+
10
+ // Set a workspace-specific environment for Linux/OSX platforms
11
+ "terminal.integrated.env.linux" : {
12
+ // Set MAIN_NUMBER scenario variable to MAIN_2 directly from the environment
13
+ "MAIN_NUMBER" : " MAIN_2" ,
14
+
15
+ // Optionally, you can append the Ada toolchain of your choice to the PATH environment variable
16
+ // if you want to use a different toolchain.
17
+ // "PATH": "<PATH_TO_TOOLCHAIN>:${env:PATH}",
18
+
19
+ // Append the path to the directory containing print_utils.gpr project file dependency to
20
+ // the GPR_PROJECT_PATH environment variable
21
+ "GPR_PROJECT_PATH" : " ./imported:${env:GPR_PROJECT_PATH}"
22
+ },
23
+
24
+ // Set a workspace-specific environment for Windows
25
+ "terminal.integrated.env.windows" : {
26
+ // Set MAIN_NUMBER scenario variable to MAIN_2 directly from the environment
27
+ "MAIN_NUMBER" : " MAIN_2" ,
28
+
29
+ // Optionally, you can append the Ada toolchain of your choice to the PATH environment variable
30
+ // if you want to use a different toolchain.
31
+ // "PATH": "<PATH_TO_TOOLCHAIN>;${env:PATH}",
32
+
33
+ // Append the path to the directory containing print_utils.gpr project file dependency to
34
+ // the GPR_PROJECT_PATH environment variable
35
+ "GPR_PROJECT_PATH" : " .\\ imported;${env:GPR_PROJECT_PATH}:"
36
+ }
37
+ }
38
+ }
Original file line number Diff line number Diff line change
1
+ with "print_utils.gpr";
2
+
3
+ project Default is
4
+
5
+ for Source_Dirs use ("src");
6
+ for Object_Dir use "obj";
7
+ type MAIN_NUMBER_Type is
8
+ ("MAIN_1", "MAIN_2");
9
+ MAIN_NUMBER : MAIN_NUMBER_Type := external ("MAIN_NUMBER", "MAIN_1");
10
+
11
+ case MAIN_NUMBER is
12
+ when "MAIN_2" =>
13
+ for Main use ("main_2.adb");
14
+
15
+ when "MAIN_1" =>
16
+ for Main use ("main_1.adb");
17
+ end case;
18
+
19
+ -- Use the same executable name for main source files
20
+ package Builder is
21
+ for Executable ("main_1.adb") use "main";
22
+ for Executable ("main_2.adb") use "main";
23
+ end Builder;
24
+
25
+ for Create_Missing_Dirs use "True";
26
+
27
+ end Default;
Original file line number Diff line number Diff line change
1
+ with Ada.Text_IO ;
2
+
3
+ procedure Print (S : String) is
4
+ begin
5
+ Ada.Text_IO.Put_Line (S);
6
+ end Print ;
Original file line number Diff line number Diff line change
1
+ project Print_Utils is
2
+ end Print_Utils;
Original file line number Diff line number Diff line change
1
+ with Ada.Text_IO ;
2
+
3
+ procedure Main_2 is
4
+ begin
5
+ Ada.Text_IO.Put_Line (" Main 2" );
6
+ end Main_2 ;
Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ procedure LSP.Ada_Driver is
170
170
171
171
ALS_Home : constant VSS.Strings.Virtual_String :=
172
172
VSS.Application.System_Environment.Value (" ALS_HOME" );
173
+ GPR_Path : constant VSS.Strings.Virtual_String :=
174
+ VSS.Application.System_Environment.Value (" GPR_PROJECT_PATH" );
175
+ Path : constant VSS.Strings.Virtual_String :=
176
+ VSS.Application.System_Environment.Value (" PATH" );
173
177
Home_Dir : constant Virtual_File :=
174
178
Create_From_UTF8
175
179
(VSS.Strings.Conversions.To_UTF_8_String
@@ -271,6 +275,10 @@ begin
271
275
272
276
Server_Trace.Trace (" Initializing server ..." );
273
277
278
+ Server_Trace.Trace
279
+ (" GPR PATH: " & VSS.Strings.Conversions.To_UTF_8_String (GPR_Path));
280
+ Server_Trace.Trace
281
+ (" PATH: " & VSS.Strings.Conversions.To_UTF_8_String (Path));
274
282
-- Start monitoring the memory if the memory monitor trace is active
275
283
276
284
Memory_Monitor_Enabled := Create (" DEBUG.ADA_MEMORY" ).Is_Active;
You can’t perform that action at this time.
0 commit comments