Skip to content

Commit dd4e60f

Browse files
committed
Revamp tasks with cleaner dependencies
* Implement buildAndRunMain by invoking a build task and a run task. * Introduce properties to configure the build task and run task called by a buildAndRunMain task.
1 parent 2253f74 commit dd4e60f

File tree

5 files changed

+482
-221
lines changed

5 files changed

+482
-221
lines changed

.vscode/tasks.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
}
4747
},
4848
{
49-
// This task starts a background npm process that monitors changes to
50-
// TS files and recompiles them as needed. It is configured to be run
51-
// before the (vscode)-based launch configurations to make sure the TS
52-
// files are compiled and re-compiled upon changes.
5349
"type": "npm",
5450
"script": "watch",
5551
"path": "integration/vscode/ada",
@@ -68,6 +64,24 @@
6864
"problemMatcher": ["$ada"],
6965
"group": "build",
7066
"label": "ada: Check current file"
67+
},
68+
{
69+
"type": "npm",
70+
"script": "watch",
71+
"path": "integration/vscode/ada",
72+
"group": "build",
73+
"problemMatcher": [
74+
{
75+
"base": "$tsc-watch",
76+
"fileLocation": [
77+
"relative",
78+
"${workspaceFolder}/integration/vscode/ada"
79+
]
80+
}
81+
],
82+
"label": "npm: watch - integration/vscode/ada",
83+
"detail": "node ./node_modules/typescript/bin/tsc -watch",
84+
"isBackground": true
7185
}
7286
]
7387
}

integration/vscode/ada/package.json

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@
482482
"configuration": {
483483
"type": "object",
484484
"required": [
485-
"kind",
486-
"projectFile"
485+
"kind"
487486
],
488487
"properties": {
489488
"kind": {
@@ -494,7 +493,16 @@
494493
"checkFile",
495494
"cleanProject",
496495
"buildMain",
496+
"runMain",
497497
"buildAndRunMain"
498+
],
499+
"enumDescriptions": [
500+
"Build a GPR project",
501+
"Run semantic checks on an Ada file",
502+
"Clean a GPR project",
503+
"Build a main program specified in a GPR project",
504+
"Run a main program specified in a GPR project",
505+
"Run a build task and a run task in sequence for a given main program"
498506
]
499507
},
500508
"projectFile": {
@@ -554,19 +562,14 @@
554562
"properties": {
555563
"kind": {
556564
"enum": [
557-
"buildAndRunMain"
565+
"runMain"
558566
]
559567
},
560568
"projectFile": true,
561-
"args": true,
562569
"main": {
563570
"type": "string",
564571
"description": "Path to main source file"
565572
},
566-
"executable": {
567-
"type": "string",
568-
"description": "Path to main executable file (if it cannot be computed automatically)"
569-
},
570573
"mainArgs": {
571574
"type": "array",
572575
"items": {
@@ -576,6 +579,29 @@
576579
}
577580
},
578581
"additionalProperties": false
582+
},
583+
{
584+
"required": [
585+
"buildTask",
586+
"runTask"
587+
],
588+
"$comment": "Each oneOf is evaluated regardless of the parent schema. That's why valid properties of the parent must be repeated here in order to be allowed.",
589+
"properties": {
590+
"kind": {
591+
"enum": [
592+
"buildAndRunMain"
593+
]
594+
},
595+
"buildTask": {
596+
"type": "string",
597+
"description": "Name of the task that builds the main executable"
598+
},
599+
"runTask": {
600+
"type": "string",
601+
"description": "Name of the task that runs the main executable"
602+
}
603+
},
604+
"additionalProperties": false
579605
}
580606
]
581607
}

integration/vscode/ada/src/commands.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import { ExtensionState } from './ExtensionState';
88
import { getOrAskForProgram } from './debugConfigProvider';
99
import { adaExtState, mainOutputChannel } from './extension';
1010
import { getProjectFileRelPath } from './helpers';
11-
import { CustomTaskDefinition, getEnclosingSymbol } from './taskProviders';
11+
import {
12+
CustomTaskDefinition,
13+
getConventionalTaskLabel,
14+
getEnclosingSymbol,
15+
isFromWorkspace,
16+
} from './taskProviders';
1217

1318
export function registerCommands(context: vscode.ExtensionContext, clients: ExtensionState) {
1419
context.subscriptions.push(vscode.commands.registerCommand('ada.otherFile', otherFileHandler));
@@ -159,27 +164,6 @@ function getTaskLabel(task: vscode.Task): string {
159164
return isFromWorkspace(task) ? `(From Workspace) ${task.name}` : getConventionalTaskLabel(task);
160165
}
161166

162-
/**
163-
*
164-
* @param task - a task
165-
* @returns the label typically generated for that task by vscode. For tasks not
166-
* defined explicitely in the workspace, this is `ada: <task name>`. For tasks
167-
* defined in the workspace simply return the name which should already include
168-
* the convention.
169-
*/
170-
function getConventionalTaskLabel(task: vscode.Task): string {
171-
return isFromWorkspace(task) ? task.name : `${task.source}: ${task.name}`;
172-
}
173-
174-
/**
175-
*
176-
* @param task - a task
177-
* @returns `true` if the task is defined explicitely in the workspace's tasks.json
178-
*/
179-
function isFromWorkspace(task: vscode.Task) {
180-
return task.source == 'Workspace';
181-
}
182-
183167
interface TaskQuickPickItem extends vscode.QuickPickItem {
184168
task: vscode.Task;
185169
}

integration/vscode/ada/src/debugConfigProvider.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,6 @@ const setupCmd = [
227227
text: '-enable-pretty-printing',
228228
ignoreFailures: true,
229229
},
230-
{
231-
description: 'Set Disassembly Flavor to Intel',
232-
text: '-gdb-set disassembly-flavor intel',
233-
ignoreFailures: true,
234-
},
235230
];
236231

237232
type QuickPickAdaMain = {
@@ -363,6 +358,11 @@ function createAttachConfig(adaMain: AdaMain): AdaConfig {
363358
program: `\${workspaceFolder}/${adaMain.execRelPath()}`,
364359
processId: '${command:pickProcess}',
365360
MIMode: 'gdb',
366-
preLaunchTask: adaMain ? getBuildTaskName(adaMain) : BUILD_PROJECT_TASK_NAME,
361+
/**
362+
* If the User is trying to attach to a running process, we have to
363+
* assume that they already built the project. It would be detrimental
364+
* to trigger an unwanted rebuild, so we don't set a preLaunchTask.
365+
*/
366+
// preLaunchTask: adaMain ? getBuildTaskName(adaMain) : BUILD_PROJECT_TASK_NAME,
367367
};
368368
}

0 commit comments

Comments
 (0)