Skip to content

Commit

Permalink
Change format of qbs-configurations.json file
Browse files Browse the repository at this point in the history
 ... that allows to specify an additional common build properties
 for any build configuration.
  • Loading branch information
denis-shienkov committed Sep 14, 2023
1 parent f03c604 commit 5f9d7b6
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 106 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
export build profiles to a file.
- Added new **Qbs: Import Build Profiles** command to
import build profiles from a file.
- Changed format of the `qbs-configurations.json` file
that allows to specify an additional common build properties
for any build configuration.

## 2.1.4

Expand Down
137 changes: 100 additions & 37 deletions docs/qbs-build-configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,57 +44,120 @@ The default contents of this configuration file looks
like this:

```json
[
{
"name": "release",
"displayName": "Release",
"description": "Build with optimizations.",
"properties": {
"qbs.buildVariant": "release"
}
},
{
"name": "debug",
"displayName": "Debug",
"description": "Build with debug information.",
"properties": {
"qbs.buildVariant": "debug"
}
},
{
"name": "profiling",
"displayName": "Profiling",
"description": "Build with optimizations and debug information.",
"properties": {
"qbs.buildVariant": "profiling"
{
"version": "1",
"configurations": [
{
"name": "release",
"displayName": "Release",
"description": "Build with optimizations.",
"properties": {
"qbs.buildVariant": "release"
}
},
{
"name": "debug",
"displayName": "Debug",
"description": "Build with debug information.",
"properties": {
"qbs.buildVariant": "debug"
}
},
{
"name": "profiling",
"displayName": "Profiling",
"description": "Build with optimizations and debug information.",
"properties": {
"qbs.buildVariant": "profiling"
}
}
],
"properties": {
"foo": "foo-value",
"bar": "bar-value",
}
]
}
```

The user can edit, remove, or add the other configurations.

## Specify overriden properties

It is possible to specify a list of custom properties passed
It is possible to specify a list of specific properties passed
to the Qbs at resolve step for each build configuration
separatelly using the `properties` item.

For example, the possible configuration might look like this:

```json
[
{
"name": "my-cool-config",
"displayName": "My Cool Config",
"description": "Enable something and override something.",
"properties": {
"projects.someProject.projectProperty": false,
"products.someProduct.productProperty": false,
"modules.cpp.treatWarningsAsErrors": true,
"products.someProduct.cpp.treatWarningsAsErrors": true,
"projects.someProject.listProp: ["a", "b", "c"]
{
"name": "my-cool-config",
"displayName": "My Cool Config",
"description": "Enable something and override something.",
"properties": {
"projects.someProject.projectProperty": false,
"products.someProduct.productProperty": false,
"modules.cpp.treatWarningsAsErrors": true,
"products.someProduct.cpp.treatWarningsAsErrors": true,
"projects.someProject.listProp: ["a", "b", "c"]
}
}
```

## Specify common properties

It is possible to specify a list of common properties passed
to the Qbs at resolve step for each build configuration.

```json
{
"properties": {
"foo": "foo-value",
"bar": "bar-value"
}
}
```

E.g. this makes sense if some of overriden properties from
build configuration are same (e.g. have duplicates):

```json
{
"configurations": [
{
"name": "release",
"properties": {
"my-prop": "my-value"
}
},
{
"name": "debug",
"properties": {
"my-prop": "my-value"
}
}
]
}
```

then it can be re-written with:

```json
{
"configurations": [
{
"name": "release",
},
{
"name": "debug",
}
],
"properties": {
"my-prop": "my-value"
}
]
}
```

**Note**: If a common property matches with a specific property,
then the specific property value passed to the resolve step
(i.e. overrides a common property).
11 changes: 10 additions & 1 deletion src/datatypes/qbsbuildconfigurationdata.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
/** Qbs configuration data, obtained from the `qbs-configurations.json` file. */
export class QbsBuildConfigurationData {

export class QbsSpecificBuildConfigurationData {
public constructor(
public readonly name: string,
public readonly displayName?: string,
public readonly description?: string,
public readonly properties?: { [key: string]: string }) { }
}

export class QbsAllBuildConfigurationData {
public constructor(
public readonly version: string,
public readonly configurations: QbsSpecificBuildConfigurationData[],
public readonly properties?: { [key: string]: string },
) { }
}
2 changes: 2 additions & 0 deletions src/datatypes/qbsbuildconfigurationkey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/** Helper enumeration for wrapping the data keys from the `qbs-configurations.json` file. */
export enum QbsBuildConfigurationKey {
Configurations = 'configurations',
Description = 'description',
DisplayName = 'displayName',
Name = 'name',
Properties = 'properties',
Version = 'version',
}
Loading

0 comments on commit 5f9d7b6

Please sign in to comment.