Skip to content
This repository was archived by the owner on Dec 22, 2024. It is now read-only.

Commit 3d3744e

Browse files
authored
fix include path issue
1 parent 40e75e8 commit 3d3744e

File tree

1 file changed

+22
-34
lines changed

1 file changed

+22
-34
lines changed

src/arduino/arduino.ts

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,13 @@ export class ArduinoApp {
301301
deviceContext.configurations.forEach((section) => {
302302
if (section.name === util.getCppConfigPlatform()) {
303303
configSection = section;
304-
configSection.browse = configSection.browse || {};
305-
configSection.browse.limitSymbolsToIncludedHeaders = false;
306304
}
307305
});
308306

309307
if (!configSection) {
310308
configSection = {
311309
name: util.getCppConfigPlatform(),
312310
includePath: [],
313-
browse: { limitSymbolsToIncludedHeaders: false },
314311
};
315312
deviceContext.configurations.push(configSection);
316313
}
@@ -329,20 +326,6 @@ export class ArduinoApp {
329326
configSection.includePath.unshift(childLibPath);
330327
});
331328

332-
libPaths.forEach((childLibPath) => {
333-
childLibPath = path.resolve(path.normalize(childLibPath));
334-
if (configSection.browse.path && configSection.browse.path.length) {
335-
for (const existingPath of configSection.browse.path) {
336-
if (childLibPath === path.resolve(path.normalize(existingPath))) {
337-
return;
338-
}
339-
}
340-
} else {
341-
configSection.browse.path = [];
342-
}
343-
configSection.browse.path.unshift(childLibPath);
344-
});
345-
346329
fs.writeFileSync(configFilePath, JSON.stringify(deviceContext, null, 4));
347330
}
348331

@@ -475,13 +458,21 @@ Please make sure the folder is not occupied by other procedures .`);
475458
return result;
476459
}
477460
const toolsPath = boardDescriptor.platform.rootBoardPath;
478-
if (util.directoryExistsSync(path.join(toolsPath, "cores"))) {
479-
const coreLibs = fs.readdirSync(path.join(toolsPath, "cores"));
480-
if (coreLibs && coreLibs.length > 0) {
481-
coreLibs.forEach((coreLib) => {
482-
result.push(path.normalize(path.join(toolsPath, "cores", coreLib)));
483-
});
484-
}
461+
result.push(path.normalize(path.join(toolsPath, "**")));
462+
// if (util.directoryExistsSync(path.join(toolsPath, "cores"))) {
463+
// const coreLibs = fs.readdirSync(path.join(toolsPath, "cores"));
464+
// if (coreLibs && coreLibs.length > 0) {
465+
// coreLibs.forEach((coreLib) => {
466+
// result.push(path.normalize(path.join(toolsPath, "cores", coreLib)));
467+
// });
468+
// }
469+
// }
470+
// return result;
471+
472+
// <package>/hardware/<platform>/<version> -> <package>/tools
473+
const toolPath = path.join(toolsPath, "..", "..", "..", "tools");
474+
if (fs.existsSync(toolPath)) {
475+
result.push(path.normalize(path.join(toolPath, "**")));
485476
}
486477
return result;
487478
}
@@ -537,26 +528,23 @@ Please make sure the folder is not occupied by other procedures .`);
537528
const cppConfigFilePath = path.join(destExample, constants.CPP_CONFIG_FILE);
538529

539530
// Current workspace
540-
const includePath = ["${workspaceRoot}"];
531+
let includePath = ["${workspaceRoot}"];
541532
// Defaut package for this board
542-
includePath.concat(this.getDefaultPackageLibPaths());
533+
const defaultPackageLibPaths = this.getDefaultPackageLibPaths();
534+
includePath = includePath.concat(defaultPackageLibPaths);
543535
// Arduino built-in package tools
544-
includePath.push(path.join(this._settings.arduinoPath, "hardware", "tools"));
536+
includePath.push(path.join(this._settings.arduinoPath, "hardware", "tools", "**"));
545537
// Arduino built-in libraries
546-
includePath.push(path.join(this._settings.arduinoPath, "libraries"));
538+
includePath.push(path.join(this._settings.arduinoPath, "libraries", "**"));
547539
// Arduino custom package tools
548-
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "hardware", "tools"));
540+
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "hardware", "tools", "**"));
549541
// Arduino custom libraries
550-
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "libraries"));
542+
includePath.push(path.join(os.homedir(), "Documents", "Arduino", "libraries", "**"));
551543

552544
const cppConfig = {
553545
configurations: [{
554546
name: util.getCppConfigPlatform(),
555547
includePath,
556-
browse: {
557-
path: includePath,
558-
limitSymbolsToIncludedHeaders: false,
559-
},
560548
intelliSenseMode: "clang-x64",
561549
cStandard: "c11",
562550
cppStandard: "c++17",

0 commit comments

Comments
 (0)