Skip to content

Commit 28f1bc9

Browse files
sean-mcmanusbobbrow
authored andcommitted
Add ${VcpkgRoot} variable
1 parent aa424f1 commit 28f1bc9

File tree

5 files changed

+48
-26
lines changed

5 files changed

+48
-26
lines changed

Extension/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# C/C++ for Visual Studio Code Change Log
22

3+
## Version 0.17.7: July 16, 2018
4+
* Add `${vcpkgRoot}` variable. [#1817](https://github.com/Microsoft/vscode-cpptools/issues/1817)
5+
* Skip automatic parsing of source files in Mac system framework paths. [#2156](https://github.com/Microsoft/vscode-cpptools/issues/2156)
6+
* Fix `Edit Configuration...` not working after `c_cpp_properties.json` is deleted. [#2214](https://github.com/Microsoft/vscode-cpptools/issues/2214)
7+
* Fix indexing of the entire root drive on Windows when no is folder open. [#2216](https://github.com/Microsoft/vscode-cpptools/issues/2216)
8+
* Fix out-of-memory crash with `#include` code actions when no folder is open. [#2225](https://github.com/Microsoft/vscode-cpptools/issues/2225)
9+
310
## Version 0.17.6: July 2, 2018
411
* Fix the database icon getting stuck with recursive includes. [#2104](https://github.com/Microsoft/vscode-cpptools/issues/2104)
512
* Fix the red flame appearing late with recursive includes. [#2105](https://github.com/Microsoft/vscode-cpptools/issues/2105)

Extension/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpptools",
33
"displayName": "C/C++",
44
"description": "C/C++ IntelliSense, debugging, and code browsing.",
5-
"version": "0.17.6",
5+
"version": "0.17.7-master",
66
"publisher": "ms-vscode",
77
"preview": true,
88
"icon": "LanguageCCPP_color_128x.png",
@@ -1351,7 +1351,7 @@
13511351
"runtimeDependencies": [
13521352
{
13531353
"description": "C/C++ language components (Linux / x86_64)",
1354-
"url": "https://go.microsoft.com/fwlink/?linkid=2003936",
1354+
"url": "https://go.microsoft.com/fwlink/?linkid=2004596",
13551355
"platforms": [
13561356
"linux"
13571357
],
@@ -1365,7 +1365,7 @@
13651365
},
13661366
{
13671367
"description": "C/C++ language components (Linux / x86)",
1368-
"url": "https://go.microsoft.com/fwlink/?linkid=2003833",
1368+
"url": "https://go.microsoft.com/fwlink/?linkid=2004498",
13691369
"platforms": [
13701370
"linux"
13711371
],
@@ -1381,7 +1381,7 @@
13811381
},
13821382
{
13831383
"description": "C/C++ language components (OS X)",
1384-
"url": "https://go.microsoft.com/fwlink/?linkid=2003834",
1384+
"url": "https://go.microsoft.com/fwlink/?linkid=2004597",
13851385
"platforms": [
13861386
"darwin"
13871387
],
@@ -1392,7 +1392,7 @@
13921392
},
13931393
{
13941394
"description": "C/C++ language components (Windows)",
1395-
"url": "https://go.microsoft.com/fwlink/?linkid=2003835",
1395+
"url": "https://go.microsoft.com/fwlink/?linkid=2004598",
13961396
"platforms": [
13971397
"win32"
13981398
],

Extension/src/LanguageServer/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ class DefaultClient implements Client {
354354
preferredPathSeparator: settings.preferredPathSeparator,
355355
default: {
356356
systemIncludePath: settings.defaultSystemIncludePath
357-
}
357+
},
358+
vcpkg_root: util.getVcpkgRoot()
358359
},
359360
middleware: createProtocolFilter(this, allClients), // Only send messages directed at this client.
360361
errorHandler: {

Extension/src/LanguageServer/configurations.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class CppProperties {
8888
private vcpkgIncludes: string[] = [];
8989
private vcpkgPathReady: boolean = false;
9090
private defaultIntelliSenseMode: string = null;
91-
private readonly configurationGlobPattern: string = "**/c_cpp_properties.json"; // TODO: probably should be a single file, not all files...
91+
private readonly configurationGlobPattern: string = "c_cpp_properties.json";
9292
private disposables: vscode.Disposable[] = [];
9393
private configurationsChanged = new vscode.EventEmitter<Configuration[]>();
9494
private selectionChanged = new vscode.EventEmitter<number>();
@@ -247,27 +247,25 @@ export class CppProperties {
247247

248248
private async buildVcpkgIncludePath(): Promise<void> {
249249
try {
250-
// Check for vcpkg instance and include relevent paths if found.
251-
if (await util.checkFileExists(util.getVcpkgPathDescriptorFile())) {
252-
let vcpkgRoot: string = await util.readFileText(util.getVcpkgPathDescriptorFile());
253-
vcpkgRoot = vcpkgRoot.trim();
254-
if (await util.checkDirectoryExists(vcpkgRoot)) {
255-
let vcpkgInstalledPath: string = path.join(vcpkgRoot, "/installed");
256-
let list: string[] = await util.readDir(vcpkgInstalledPath);
257-
if (list !== undefined) {
258-
// For every *directory* in the list (non-recursive). Each directory is basically a platform.
259-
list.forEach((entry) => {
260-
if (entry !== "vcpkg") {
261-
let pathToCheck: string = path.join(vcpkgInstalledPath, entry);
262-
if (fs.existsSync(pathToCheck)) {
263-
let p: string = path.join(pathToCheck, "include");
264-
if (fs.existsSync(p)) {
265-
this.vcpkgIncludes.push(p);
266-
}
250+
// Check for vcpkgRoot and include relevent paths if found.
251+
let vcpkgRoot: string = util.getVcpkgRoot();
252+
if (vcpkgRoot) {
253+
let list: string[] = await util.readDir(vcpkgRoot);
254+
if (list !== undefined) {
255+
// For every *directory* in the list (non-recursive). Each directory is basically a platform.
256+
list.forEach((entry) => {
257+
if (entry !== "vcpkg") {
258+
let pathToCheck: string = path.join(vcpkgRoot, entry);
259+
if (fs.existsSync(pathToCheck)) {
260+
let p: string = path.join(pathToCheck, "include");
261+
if (fs.existsSync(p)) {
262+
p = p.replace(/\\/g, "/");
263+
p = p.replace(vcpkgRoot, "${vcpkgRoot}");
264+
this.vcpkgIncludes.push(p);
267265
}
268266
}
269-
});
270-
}
267+
}
268+
});
271269
}
272270
}
273271
} catch (error) {} finally {

Extension/src/common.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ export function getVcpkgPathDescriptorFile(): string {
5757
}
5858
}
5959

60+
let vcpkgRoot: string;
61+
export function getVcpkgRoot(): string {
62+
if (!vcpkgRoot && vcpkgRoot !== "") {
63+
vcpkgRoot = "";
64+
// Check for vcpkg instance.
65+
if (fs.existsSync(getVcpkgPathDescriptorFile())) {
66+
let vcpkgRootTemp: string = fs.readFileSync(getVcpkgPathDescriptorFile()).toString();
67+
vcpkgRootTemp = vcpkgRootTemp.trim();
68+
if (fs.existsSync(vcpkgRootTemp)) {
69+
vcpkgRoot = path.join(vcpkgRootTemp, "/installed").replace(/\\/g, "/");
70+
}
71+
}
72+
}
73+
return vcpkgRoot;
74+
}
75+
6076
// Extension is ready if install.lock exists and debugAdapters folder exist.
6177
export async function isExtensionReady(): Promise<boolean> {
6278
const doesInstallLockFileExist: boolean = await checkInstallLockFile();

0 commit comments

Comments
 (0)