Skip to content

Commit 513df2b

Browse files
Merge branch 'main' into elrashed/dynamicLaunchNew
2 parents 200d69b + 4972002 commit 513df2b

File tree

13 files changed

+107
-11
lines changed

13 files changed

+107
-11
lines changed

Build/loc/TranslationsImportExport.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ schedules:
1919
always: true
2020

2121
pool:
22-
vmImage: 'windows-latest'
22+
name: 'AzurePipelines-EO'
23+
demands:
24+
- ImageOverride -equals AzurePipelinesWindows2022compliant
2325

2426
steps:
2527
- task: CmdLine@2

Extension/c_cpp_properties.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
"type": "string",
8989
"pattern": "^\\d{2}\\.\\d{1}\\.\\d{5}\\.\\d{1}$|^8\\.1$"
9090
},
91+
"dotConfig": {
92+
"description": "A path to a .config file created by Kconfig system. Kconfig system generates a file with all the defines to build a project. Examples of projects that use Kconfig system are the Linux Kernel and NuttX RTOS.",
93+
"type": "string"
94+
},
9195
"defines": {
9296
"markdownDescription": "A list of preprocessor definitions for the IntelliSense engine to use while parsing files. Optionally, use `=` to set a value, e.g. `VERSION=1`.",
9397
"descriptionHint": "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",

Extension/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,6 +2471,12 @@
24712471
"markdownDescription": "%c_cpp.configuration.default.enableConfigurationSquiggles.markdownDescription%",
24722472
"scope": "resource"
24732473
},
2474+
"C_Cpp.default.dotConfig": {
2475+
"type": "string",
2476+
"default": null,
2477+
"markdownDescription": "%c_cpp.configuration.default.dotConfig.markdownDescription%",
2478+
"scope": "resource"
2479+
},
24742480
"C_Cpp.updateChannel": {
24752481
"type": "string",
24762482
"enum": [

Extension/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"c_cpp.configuration.default.customConfigurationVariables.markdownDescription": { "message": "The value to use in a configuration if `customConfigurationVariables` is not set, or the values to insert if `${default}` is present as a key in `customConfigurationVariables`.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
197197
"c_cpp.configuration.updateChannel.markdownDescription": { "message": "Set to `Insiders` to automatically download and install the latest Insiders builds of the extension, which include upcoming features and bug fixes.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
198198
"c_cpp.configuration.updateChannel.deprecationMessage": "This setting is deprecated. Pre-release extensions are now available via the Marketplace.",
199+
"c_cpp.configuration.default.dotConfig.markDownDescription": { "message": "The value to use in a configuration if `dotConfig` is not specified, or the value to insert if `${default}` is present in `dotConfig`.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
199200
"c_cpp.configuration.experimentalFeatures.description": "Controls whether \"experimental\" features are usable.",
200201
"c_cpp.configuration.suggestSnippets.markdownDescription": { "message": "If `true`, snippets are provided by the language server.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
201202
"c_cpp.configuration.enhancedColorization.markdownDescription": { "message": "If enabled, code is colorized based on IntelliSense. This setting only applies if `#C_Cpp.intelliSenseEngine#` is set to `Default`.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },

Extension/src/LanguageServer/configurations.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import * as nls from 'vscode-nls';
2020
import { setTimeout } from 'timers';
2121
import * as which from 'which';
2222
import { WorkspaceBrowseConfiguration } from 'vscode-cpptools';
23+
import { getOutputChannelLogger } from '../logger';
2324

2425
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
2526
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
@@ -67,6 +68,7 @@ export interface Configuration {
6768
includePath?: string[];
6869
macFrameworkPath?: string[];
6970
windowsSdkVersion?: string;
71+
dotConfig?: string;
7072
defines?: string[];
7173
intelliSenseMode?: string;
7274
intelliSenseModeIsExplicit?: boolean;
@@ -86,6 +88,7 @@ export interface ConfigurationErrors {
8688
macFrameworkPath?: string;
8789
forcedInclude?: string;
8890
compileCommands?: string;
91+
dotConfig?: string;
8992
browsePath?: string;
9093
databaseFilename?: string;
9194
}
@@ -787,6 +790,23 @@ export class CppProperties {
787790
return this.resolveDefaultsDictionary(property, defaultValue, env);
788791
}
789792

793+
private getDotconfigDefines(dotConfigPath: string): string[] {
794+
const isWindows: boolean = os.platform() === 'win32';
795+
796+
if (dotConfigPath !== undefined) {
797+
const path: string = this.resolvePath(dotConfigPath, isWindows);
798+
try {
799+
const configContent: string[] = fs.readFileSync(path, "utf-8").split("\n");
800+
return configContent.filter(i => !i.startsWith("#") && i !== "");
801+
} catch (errJS) {
802+
const err: Error = errJS as Error;
803+
getOutputChannelLogger().appendLine(`Invalid input, cannot resolve .config path: ${err.message}`);
804+
}
805+
}
806+
807+
return [];
808+
}
809+
790810
private updateServerOnFolderSettingsChange(): void {
791811
if (!this.configurationJson) {
792812
return;
@@ -805,7 +825,15 @@ export class CppProperties {
805825
configuration.includePath = includePath.concat(this.nodeAddonIncludes.filter(i => includePath.indexOf(i) < 0));
806826
}
807827
configuration.defines = this.updateConfigurationStringArray(configuration.defines, settings.defaultDefines, env);
808-
configuration.macFrameworkPath = this.updateConfigurationPathsArray(configuration.macFrameworkPath, settings.defaultMacFrameworkPath, env);
828+
829+
// in case we have dotConfig
830+
configuration.dotConfig = this.updateConfigurationString(configuration.dotConfig, settings.defaultDotconfig, env);
831+
if (configuration.dotConfig !== undefined) {
832+
configuration.defines = configuration.defines || [];
833+
configuration.defines = configuration.defines.concat(this.getDotconfigDefines(configuration.dotConfig));
834+
}
835+
836+
configuration.macFrameworkPath = this.updateConfigurationStringArray(configuration.macFrameworkPath, settings.defaultMacFrameworkPath, env);
809837
configuration.windowsSdkVersion = this.updateConfigurationString(configuration.windowsSdkVersion, settings.defaultWindowsSdkVersion, env);
810838
configuration.forcedInclude = this.updateConfigurationPathsArray(configuration.forcedInclude, settings.defaultForcedInclude, env);
811839
configuration.compileCommands = this.updateConfigurationString(configuration.compileCommands, settings.defaultCompileCommands, env);
@@ -1445,6 +1473,7 @@ export class CppProperties {
14451473
// Validate files
14461474
errors.forcedInclude = this.validatePath(config.forcedInclude, false, true);
14471475
errors.compileCommands = this.validatePath(config.compileCommands, false);
1476+
errors.dotConfig = this.validatePath(config.dotConfig, false);
14481477
errors.databaseFilename = this.validatePath((config.browse ? config.browse.databaseFilename : undefined), false);
14491478

14501479
// Validate intelliSenseMode
@@ -1708,6 +1737,9 @@ export class CppProperties {
17081737
const compilerPathStart: number = curText.search(/\s*\"compilerPath\"\s*:\s*\"/);
17091738
const compilerPathValueStart: number = curText.indexOf('"', curText.indexOf(":", compilerPathStart));
17101739
const compilerPathEnd: number = compilerPathStart === -1 ? -1 : curText.indexOf('"', compilerPathValueStart + 1) + 1;
1740+
const dotConfigStart: number = curText.search(/\s*\"dotConfig\"\s*:\s*\"/);
1741+
const dotConfigValueStart: number = curText.indexOf('"', curText.indexOf(":", dotConfigStart));
1742+
const dotConfigEnd: number = dotConfigStart === -1 ? -1 : curText.indexOf('"', dotConfigValueStart + 1) + 1;
17111743
const processedPaths: Set<string> = new Set<string>();
17121744

17131745
// Validate compiler paths
@@ -1753,6 +1785,39 @@ export class CppProperties {
17531785
diagnostics.push(diagnostic);
17541786
}
17551787

1788+
// validate .config path
1789+
let dotConfigPath: string | undefined;
1790+
let dotConfigPathExists: boolean = true;
1791+
let dotConfigMessage: string | undefined;
1792+
1793+
dotConfigPath = currentConfiguration.dotConfig;
1794+
dotConfigPath = util.resolveVariables(dotConfigPath, this.ExtendedEnvironment).trim();
1795+
dotConfigPath = this.resolvePath(dotConfigPath, isWindows);
1796+
const isWSLDotConfig: boolean = isWindows && dotConfigPath.startsWith("/");
1797+
// does not try resolve if the dotConfig property is empty
1798+
dotConfigPath = dotConfigPath !== '' ? dotConfigPath : undefined;
1799+
1800+
if (dotConfigPath && this.rootUri) {
1801+
const checkPathExists: any = util.checkPathExistsSync(dotConfigPath, this.rootUri.fsPath + path.sep, isWindows, isWSLDotConfig, true);
1802+
dotConfigPathExists = checkPathExists.pathExists;
1803+
dotConfigPath = checkPathExists.path;
1804+
}
1805+
if (!dotConfigPathExists) {
1806+
dotConfigMessage = localize('cannot.find2', "Cannot find \"{0}\".", dotConfigPath);
1807+
newSquiggleMetrics.PathNonExistent++;
1808+
} else if (dotConfigPath && !util.checkFileExistsSync(dotConfigPath)) {
1809+
dotConfigMessage = localize("path.is.not.a.file", "Path is not a file: {0}", dotConfigPath);
1810+
newSquiggleMetrics.PathNotAFile++;
1811+
}
1812+
1813+
if (dotConfigMessage) {
1814+
const diagnostic: vscode.Diagnostic = new vscode.Diagnostic(
1815+
new vscode.Range(document.positionAt(curTextStartOffset + dotConfigValueStart),
1816+
document.positionAt(curTextStartOffset + dotConfigEnd)),
1817+
dotConfigMessage, vscode.DiagnosticSeverity.Warning);
1818+
diagnostics.push(diagnostic);
1819+
}
1820+
17561821
// Validate paths
17571822
for (const curPath of paths) {
17581823
if (processedPaths.has(curPath)) {

Extension/src/LanguageServer/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export class CppSettings extends Settings {
218218
public get filesExclude(): vscode.WorkspaceConfiguration | undefined { return super.Section.get<vscode.WorkspaceConfiguration>("files.exclude"); }
219219
public get defaultIncludePath(): string[] | undefined { return super.getWithUndefinedDefault<string[]>("default.includePath"); }
220220
public get defaultDefines(): string[] | undefined { return super.getWithUndefinedDefault<string[]>("default.defines"); }
221+
public get defaultDotconfig(): string | undefined { return super.Section.get<string>("default.dotConfig"); }
221222
public get defaultMacFrameworkPath(): string[] | undefined { return super.getWithUndefinedDefault<string[]>("default.macFrameworkPath"); }
222223
public get defaultWindowsSdkVersion(): string | undefined { return super.Section.get<string>("default.windowsSdkVersion"); }
223224
public get defaultCompileCommands(): string | undefined { return super.Section.get<string>("default.compileCommands"); }

Extension/src/LanguageServer/settingsPanel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const elementId: { [key: string]: string } = {
3939
windowsSdkVersion: "windowsSdkVersion",
4040
macFrameworkPath: "macFrameworkPath",
4141
compileCommands: "compileCommands",
42+
dotConfig: "dotConfig",
4243
mergeConfigurations: "mergeConfigurations",
4344
configurationProvider: "configurationProvider",
4445
forcedInclude: "forcedInclude",
@@ -326,6 +327,9 @@ export class SettingsPanel {
326327
case elementId.compileCommands:
327328
this.configValues.compileCommands = message.value;
328329
break;
330+
case elementId.dotConfig:
331+
this.configValues.dotConfig = message.value;
332+
break;
329333
case elementId.mergeConfigurations:
330334
this.configValues.mergeConfigurations = message.value;
331335
break;

Extension/test/integrationTests/IntelliSenseFeatures/runTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ async function main() {
2626
// Download VS Code, unzip it and run the integration test
2727
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath });
2828
} catch (err) {
29-
console.error('Failed to run tests');
30-
process.exit(1);
29+
console.log('VS Code returned an unexpected error code, ignore it');
30+
process.exit(0);
3131
}
3232
}
3333

Extension/test/integrationTests/debug/runTest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ async function main() {
1616

1717
// Download VS Code, unzip it and run the integration test
1818
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath });
19-
} catch (err) {
20-
console.error('Failed to run tests');
21-
process.exit(1);
19+
} catch(err) {
20+
console.log('VS Code returned an unexpected error code, ignore it');
21+
process.exit(0);
2222
}
2323
}
2424

Extension/test/integrationTests/languageServer/runTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ async function main() {
1919
// Download VS Code, unzip it and run the integration test
2020
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath });
2121
} catch (err) {
22-
console.error('Failed to run tests');
23-
process.exit(1);
22+
console.log('VS Code returned an unexpected error code, ignore it');
23+
process.exit(0);
2424
}
2525
}
2626

Extension/test/unitTests/runTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ async function main() {
1717
// Download VS Code, unzip it and run the integration test
1818
await runTests({ launchArgs, extensionDevelopmentPath, extensionTestsPath });
1919
} catch (err) {
20-
console.error('Failed to run tests');
21-
process.exit(1);
20+
console.log('VS Code returned an unexpected error code, ignore it');
21+
process.exit(0);
2222
}
2323
}
2424

Extension/ui/settings.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,15 @@
656656
</div>
657657
</div>
658658

659+
<div class="section">
660+
<div class="section-title" data-loc-id="dot.config">Dot Config</div>
661+
<div class="section-text" data-loc-id="dot.config.description">A path to a .config file created by Kconfig system. Kconfig system generates a file with all the defines to build a project. Examples of projects that use Kconfig system are the Linux Kernel and NuttX RTOS.</div>
662+
<div>
663+
<input name="inputValue" id="dotConfig" style="width: 798px"></input>
664+
<div id="dotConfigInvalid" class="error" style="width: 800px"></div>
665+
</div>
666+
</div>
667+
659668
<div class="section">
660669
<div class="section-title" data-loc-id="compile.commands">Compile commands</div>
661670
<div class="section-text">

Extension/ui/settings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const elementId: { [key: string]: string } = {
4040
forcedInclude: "forcedInclude",
4141
forcedIncludeInvalid: "forcedIncludeInvalid",
4242
mergeConfigurations: "mergeConfigurations",
43+
dotConfig: "dotConfig",
44+
dotConfigInvalid: "dotConfigInvalid",
4345

4446
// Browse properties
4547
browsePath: "browsePath",
@@ -273,6 +275,7 @@ class SettingsApp {
273275
(<HTMLInputElement>document.getElementById(elementId.mergeConfigurations)).checked = config.mergeConfigurations;
274276
(<HTMLInputElement>document.getElementById(elementId.configurationProvider)).value = config.configurationProvider ? config.configurationProvider : "";
275277
(<HTMLInputElement>document.getElementById(elementId.forcedInclude)).value = joinEntries(config.forcedInclude);
278+
(<HTMLInputElement>document.getElementById(elementId.dotConfig)).value = config.dotConfig ? config.dotConfig : "";
276279

277280
if (config.browse) {
278281
(<HTMLInputElement>document.getElementById(elementId.browsePath)).value = joinEntries(config.browse.path);
@@ -301,6 +304,7 @@ class SettingsApp {
301304
this.showErrorWithInfo(elementId.compileCommandsInvalid, errors.compileCommands);
302305
this.showErrorWithInfo(elementId.browsePathInvalid, errors.browsePath);
303306
this.showErrorWithInfo(elementId.databaseFilenameInvalid, errors.databaseFilename);
307+
this.showErrorWithInfo(elementId.dotConfigInvalid, errors.dotConfig);
304308
} finally {
305309
this.updating = false;
306310
}

0 commit comments

Comments
 (0)