Skip to content

Commit c49d616

Browse files
committed
Update documentation about VS Code tasks
1 parent a91772a commit c49d616

File tree

1 file changed

+66
-8
lines changed

1 file changed

+66
-8
lines changed

README.md

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ extension at
5151
- [Refactoring](#refactoring)
5252
- [Tasks](#tasks)
5353
- [Task Customization](#task-customization)
54+
- [Tasks for Project Mains](#tasks-for-project-mains)
55+
- [ALIRE Support](#alire-support)
5456
- [Commands and Shortcuts](#commands-and-shortcuts)
5557
- [Ada: Go to other file](#ada-go-to-other-file)
5658
- [Ada: Add subprogram box](#ada-add-subprogram-box)
@@ -190,6 +192,10 @@ The extension provides the following auto-detected tasks
190192
* `spark: Prove selected region` - launch `gnatprove` on the selected region in the current editor
191193
* `spark: Prove line` - launch `gnatprove` on the cursor line in the current editor
192194
* `spark: Clean project for proof` - launch `gnatprove` on the current GPR project to clean proof artefacts
195+
* `ada: Analyze the project with GNAT SAS`
196+
* `ada: Analyze the current file with GNAT SAS`
197+
* `ada: Create a report after a GNAT SAS analysis`
198+
* `ada: Analyze the project with GNAT SAS and produce a report`
193199

194200
You can bind keyboard shortcuts to them by adding to the `keybindings.json` file:
195201

@@ -205,27 +211,78 @@ You can bind keyboard shortcuts to them by adding to the `keybindings.json` file
205211
#### Task Customization
206212

207213
You can [customize auto-detected tasks](https://code.visualstudio.com/docs/editor/tasks#_customizing-autodetected-tasks)
208-
by providing extra tool command line options via the `args` property of the `configuration` object in the `tasks.json`:
214+
by providing extra tool command line options via the `args` property of the object in the `tasks.json`:
209215

210216
```json
211217
{
212218
"version": "2.0.0",
213219
"tasks": [
214220
{
215221
"type": "ada",
216-
"configuration": {
217-
"kind": "buildProject",
218-
"projectFile": "${config:ada.projectFile}",
219-
"args": ["-gargs", "-vh"]
222+
"command": "gprbuild",
223+
"args": [
224+
"${command:ada.gprProjectArgs}",
225+
"-cargs:ada",
226+
"-gnatef",
227+
"-gargs",
228+
"-vh"
229+
],
230+
"problemMatcher": ["$ada"],
231+
"group": "build",
232+
"label": "ada: Build current project"
233+
}
234+
]
235+
}
236+
```
237+
238+
You can also customize the working directory of the task or the environment variables via the `options` property:
239+
240+
```json
241+
{
242+
"version": "2.0.0",
243+
"tasks": [
244+
{
245+
"type": "ada",
246+
"command": "gprbuild",
247+
"args": [
248+
"${command:ada.gprProjectArgs}",
249+
"-cargs:ada",
250+
"-gnatef"
251+
],
252+
"options": {
253+
"cwd": "${workspaceFolder}/my/subdir",
254+
"env": {
255+
"MY_ENV_VAR": "value"
256+
}
220257
},
221258
"problemMatcher": ["$ada"],
222259
"group": "build",
223-
"label": "ada: Build current project with custom options"
260+
"label": "ada: Build current project"
224261
}
225262
]
226263
}
227264
```
228265

266+
#### Tasks for Project Mains
267+
268+
If your GPR project defines main programs via the project attribute `Main`, additional tasks are automatically provided for each defined main.
269+
For example, if the project defines a `main1.adb` and `main2.adb` located under the `src/` source directory, the following tasks will be available:
270+
271+
* `ada: Build main - src/main1.adb`
272+
* `ada: Run main - src/main1.adb`
273+
* `ada: Build and run main - src/main1.adb`
274+
* `ada: Build main - src/main2.adb`
275+
* `ada: Run main - src/main2.adb`
276+
* `ada: Build and run main - src/main2.adb`
277+
278+
#### ALIRE Support
279+
280+
When the workspace is an ALIRE project (i.e. it contains an `alire.toml` file), tasks automatically use standard ALIRE commands.
281+
282+
For example, the `ada: Build current project` task uses the command `alr build` and the `ada: Clean current project` task uses the command `alr clean`.
283+
284+
All other tasks use `alr exec -- ...` to execute the command in the environment provided by ALIRE.
285+
229286
### Commands and Shortcuts
230287

231288
The extension contributes commands and a few default key bindings.
@@ -259,12 +316,13 @@ The VS Code extension has a few limitations and some differences compared to [GN
259316
* **Indentation/formatting**: it does not support automatic indentation when adding a newline and range/document
260317
formatting might no succeed on incomplete/illegal code.
261318

262-
* **Tooling support**: we currently provide minimal support for *SPARK* (see *Prove/Examine* tasks in the [Auto-detected tasks](#auto-detected-tasks) section), but there is no support for tools such as *CodePeer*, *GNATcheck*, *GNATtest* or *GNATcoverage*.
319+
* **Tooling support**: we currently provide support for some *SPARK*, *GNATtest* and *GNAT SAS* [Tasks](#tasks), but there is no support for tools such as *GNATcheck* or *GNATcoverage* yet.
263320

264321
* **Alire support**: if the root folder contains an `alire.toml` file and
265322
there is `alr` executable in the `PATH`, then the language server fetches
266323
the project's search path, environment variables and the project's file
267-
name from the crate description.
324+
name from the crate description. [Tasks](#tasks) are also automatically
325+
invoked with ALIRE in this case.
268326

269327
* **Project support**: there is no `Scenario` view: users should configure scenarios via the *ada.scenarioVariables* setting (see the settings list available [here](doc/settings.md)). Saving the settings file after changing the values will automatically reload the project and update the
270328
predefined tasks to take into account the new scenario values.

0 commit comments

Comments
 (0)