Skip to content

Commit

Permalink
Add {resolve|build|clean|install|rebuild} tasks support
Browse files Browse the repository at this point in the history
Fixes: #66
  • Loading branch information
denis-shienkov committed Feb 1, 2023
1 parent b7416b7 commit 634ba43
Show file tree
Hide file tree
Showing 11 changed files with 521 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# What's New?

## 2.1.0

- [#66](https://github.com/denis-shienkov/vscode-qbs/issues/66)
Added support for resolve/build/clean/install/rebuild tasks.

## 2.0.2

- [#70](https://github.com/denis-shienkov/vscode-qbs/issues/70)
Expand Down
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ with Qbs-based projects.
[Build configurations and overriden properties](qbs-build-configurations.md)
* [Create configurations](qbs-build-configurations.md#create-build-configurations)
* [Override properties](qbs-build-configurations.md#specify-overriden-properties)

[Configure tasks](qbs-tasks.md)
* [Resolve with Qbs tools tasks](qbs-tasks.md#resolve-with-qbs-tools-tasks)
* [Build with Qbs tools tasks](qbs-tasks.md#build-with-qbs-tools-tasks)
* [Clean with Qbs tools tasks](qbs-tasks.md#clean-with-qbs-tools-tasks)
* [Install with Qbs tools tasks](qbs-tasks.md#install-with-qbs-tools-tasks)
* [Rebuild with Qbs tools tasks](qbs-tasks.md#rebuild-with-qbs-tools-tasks)
Binary file added docs/images/qbs-configure-task.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 126 additions & 0 deletions docs/qbs-tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Resolve with Qbs tools tasks

You can create a resolve task from the VS Code command pallette by running the **Tasks: Configure task** command.

![Configure a task](images/qbs-configure-task.png)

By selecting "Qbs: Resolve" template this task will be generated in `tasks.json` file:

```json
{
"type": "qbs",
"label": "Qbs: Resolve",
"command": "resolve",
"problemMatcher": [],
"detail": "Qbs template Resolve task"
}
```

**Note**: You can change the `label` and the `detail` properties as you want.

# Build with Qbs tools tasks

You can create a build task from the VS Code command pallette by running the **Tasks: Configure task** command.

By selecting "Qbs: Build" template this task will be generated in `tasks.json` file:

```json
{
"type": "qbs",
"label": "Qbs: Build",
"command": "build",
"products": [
"current_product_name"
],
"group": "build",
"problemMatcher": [],
"detail": "Qbs template Build task"
}
```

**Note**: The `products` property will be automatically filled with the current build product selected
from the status bar.

**Note**: The empty `products` property as `[]` means that all products will be build.

**Note**: You can change the `label`, `detail`, and `products` properties as you want.

# Clean with Qbs tools tasks

You can create a clean task from the VS Code command pallette by running the **Tasks: Configure task** command.

By selecting "Qbs: Clean" template this task will be generated in `tasks.json` file:

```json
{
"type": "qbs",
"label": "Qbs: Clean",
"command": "clean",
"products": [
"current_product_name"
],
"group": "clean",
"problemMatcher": [],
"detail": "Qbs template Clean task"
}
```

**Note**: The `products` property will be automatically filled with the current build product selected
from the status bar.

**Note**: The empty `products` property as `[]` means that all products will be cleaned.

**Note**: You can change the `label`, `detail`, and `products` properties as you want.

# Install with Qbs tools tasks

You can create an install task from the VS Code command pallette by running the **Tasks: Configure task** command.

By selecting "Qbs: Install" template this task will be generated in `tasks.json` file:

```json
{
"type": "qbs",
"label": "Qbs: Install",
"command": "install",
"products": [
"current_product_name"
],
"problemMatcher": [],
"detail": "Qbs template Install task"
}
```

**Note**: The `products` property will be automatically filled with the current build product selected
from the status bar.

**Note**: The empty `products` property as `[]` means that all products will be installed.

**Note**: You can change the `label`, `detail`, and `products` properties as you want.

# Rebuild with Qbs tools tasks

You can create a rebuild task from the VS Code command pallette by running the **Tasks: Configure task** command.

By selecting "Qbs: Rebuild" template this task will be generated in `tasks.json` file:

```json
{
"type": "qbs",
"label": "Qbs: Rebuild",
"command": "rebuild",
"products": [
"current_product_name"
],
"group": "rebuild",
"problemMatcher": [],
"detail": "Qbs template Rebuild task"
}
```

**Note**: The `products` property will be automatically filled with the current build product selected
from the status bar.

**Note**: The empty `products` property as `[]` means that all products will be rebuild.

**Note**: You can change the `label`, `detail`, and `products` properties as you want.
5 changes: 4 additions & 1 deletion i18n/rus/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
"qbs-tools.configuration.qbs.saveBeforeBuild.description": "Сохранять открытые файлы перед сборкой.",
"qbs-tools.configuration.qbs.settingsDirectory.description": "Каталог настроек. Пустое значение означает каталог по умолчанию.",
"qbs-tools.configuration.qbs.showDisabledProjectItems.description": "Отображать отключенные элементы проекта.",
"qbs-tools.configuration.views.qbs.project.description": "Проект"
"qbs-tools.configuration.views.qbs.project.description": "Проект",
"qbs-tools.tasks.properties.command.description": "Команда Qbs",
"qbs-tools.tasks.properties.label.description": "Имя задачи",
"qbs-tools.tasks.properties.targets.description": "Продукты сборки Qbs"
}
9 changes: 9 additions & 0 deletions i18n/rus/src/qbstaskprovider.i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"qbs.taskprovider.build.command": "Собрать",
"qbs.taskprovider.clean.command": "Очистить",
"qbs.taskprovider.command.not.recognized": "{0} не распознанная команда.",
"qbs.taskprovider.install.command": "Установить",
"qbs.taskprovider.rebuild.command": "Пересобрать",
"qbs.taskprovider.resolve.command": "Сканировать",
"qbs.taskprovider.template.task": "Задача шаблона Qbs {0}"
}
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,38 @@
"category": "Qbs"
}
],
"taskDefinitions": [
{
"type": "qbs",
"required": [
"command"
],
"properties": {
"label": {
"type": "string",
"description": "%qbs-tools.tasks.properties.label.description%"
},
"command": {
"type": "string",
"enum": [
"build",
"clean",
"install",
"rebuild",
"resolve"
],
"description": "%qbs-tools.tasks.properties.command.description%"
},
"products": {
"type": "array",
"items": {
"type": "string"
},
"description": "%qbs-tools.tasks.properties.products.description%"
}
}
}
],
"menus": {
"commandPalette": [
{
Expand Down
5 changes: 4 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
"qbs-tools.configuration.qbs.saveBeforeBuild.description": "Save open files before building.",
"qbs-tools.configuration.qbs.settingsDirectory.description": "The settings directory. An empty value means the default directory.",
"qbs-tools.configuration.qbs.showDisabledProjectItems.description": "Show disabled project items.",
"qbs-tools.configuration.views.qbs.project.description": "Project"
"qbs-tools.configuration.views.qbs.project.description": "Project",
"qbs-tools.tasks.properties.command.description": "Qbs command",
"qbs-tools.tasks.properties.label.description": "The name of the task",
"qbs-tools.tasks.properties.targets.description": "Qbs build products"
}
14 changes: 7 additions & 7 deletions src/qbsbuildsystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,47 +98,47 @@ export class QbsBuildSystem implements vscode.Disposable {
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.ResolveProjectWithForceExecution,
async () => {
// With force probes execution.
await this.resolveWithProgress(true, QbsBuildSystemTimeout.Progress);
return await this.resolveWithProgress(true, QbsBuildSystemTimeout.Progress);
}));
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.ResolveProject,
async () => {
await this.resolveWithProgress(false, QbsBuildSystemTimeout.Progress);
return await this.resolveWithProgress(false, QbsBuildSystemTimeout.Progress);
}));

// Build commands.
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.BuildProduct,
async (data) => {
const productNames = QbsBuildSystem.getCommandProductNames(data);
await this.buildWithProgress(productNames, QbsBuildSystemTimeout.Progress);
return await this.buildWithProgress(productNames, QbsBuildSystemTimeout.Progress);
}));

// Install commands.
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.InstallProduct,
async (data) => {
const productNames = QbsBuildSystem.getCommandProductNames(data);
await this.installWithProgress(productNames, QbsBuildSystemTimeout.Progress);
return await this.installWithProgress(productNames, QbsBuildSystemTimeout.Progress);
}));

// Clean commands.
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.CleanProduct,
async (data) => {
const productNames = QbsBuildSystem.getCommandProductNames(data);
await this.cleanWithProgress(productNames, QbsBuildSystemTimeout.Progress);
return await this.cleanWithProgress(productNames, QbsBuildSystemTimeout.Progress);
}));

// Rebuild commands.
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.RebuildProduct,
async (data) => {
const productNames = QbsBuildSystem.getCommandProductNames(data);
await this.rebuildWithProgress(productNames,
return await this.rebuildWithProgress(productNames,
QbsBuildSystemTimeout.Progress, QbsBuildSystemTimeout.Progress);
}));

// Compile only command.
context.subscriptions.push(vscode.commands.registerCommand(QbsCommandKey.CompileOnly,
async (sourceNode: QbsSourceArtifactNode) => {
const fsPath = sourceNode.getFsPath();
await this.compileOnlyWithProgress(fsPath, QbsBuildSystemTimeout.Progress);
return await this.compileOnlyWithProgress(fsPath, QbsBuildSystemTimeout.Progress);
}));
}

Expand Down
29 changes: 15 additions & 14 deletions src/qbsextension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ import { QbsOutputLogger } from './qbsoutputlogger';
import { QbsProjectExplorer } from './projectexplorer/qbsprojectexplorer';
import { QbsProjectManager } from './qbsprojectmanager';
import { QbsStatusBar } from './qbsstatusbar';
import { QbsTaskProvider } from './qbstaskprovider';

let extensionManager: QbsExtensionManager;

class QbsExtensionManager implements vscode.Disposable {
private readonly buildConfigurationManager: QbsBuildConfigurationManager
= new QbsBuildConfigurationManager(this.context);
private readonly buildProfileManager: QbsBuildProfileManager
= new QbsBuildProfileManager(this.context);
private readonly launchConfigurationManager: QbsLaunchConfigurationManager
= new QbsLaunchConfigurationManager(this.context);
private readonly buildSystem: QbsBuildSystem = new QbsBuildSystem(this.context);
private readonly outputLogger: QbsOutputLogger = new QbsOutputLogger();
private readonly projectManager: QbsProjectManager = new QbsProjectManager(this.context);
private readonly cppCodeModel: QbsCppCodeModel = new QbsCppCodeModel(this.context);
private readonly projectExplorer: QbsProjectExplorer = new QbsProjectExplorer(this.context);
private readonly statusBar: QbsStatusBar = new QbsStatusBar();
private readonly diagnosticManager: QbsDiagnosticManager = new QbsDiagnosticManager();
private readonly buildConfigurationManager = new QbsBuildConfigurationManager(this.context);
private readonly buildProfileManager = new QbsBuildProfileManager(this.context);
private readonly launchConfigurationManager = new QbsLaunchConfigurationManager(this.context);
private readonly buildSystem = new QbsBuildSystem(this.context);
private readonly outputLogger = new QbsOutputLogger();
private readonly projectManager = new QbsProjectManager(this.context);
private readonly cppCodeModel = new QbsCppCodeModel(this.context);
private readonly projectExplorer = new QbsProjectExplorer(this.context);
private readonly statusBar = new QbsStatusBar();
private readonly diagnosticManager = new QbsDiagnosticManager();
private readonly taskProvider = vscode.tasks.registerTaskProvider(QbsTaskProvider.scriptType, new QbsTaskProvider());

public constructor(private readonly context: vscode.ExtensionContext) { }
public constructor(private readonly context: vscode.ExtensionContext) {
}

public dispose(): void {
this.buildConfigurationManager.dispose();
Expand All @@ -42,6 +42,7 @@ class QbsExtensionManager implements vscode.Disposable {
this.projectExplorer.dispose();
this.projectManager.dispose();
this.statusBar.dispose();
this.taskProvider.dispose();
}
}

Expand Down
Loading

0 comments on commit 634ba43

Please sign in to comment.