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

Commit 67281ae

Browse files
elektronikworkshopadiazulay
authored andcommitted
Moved arduino specifics from cocopa to vscode-arduino
1 parent 3cba412 commit 67281ae

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@
595595
"dependencies": {
596596
"body-parser": "^1.16.1",
597597
"child_process": "^1.0.2",
598-
"cocopa": "0.0.4",
598+
"cocopa": "0.0.5",
599599
"compare-versions": "^3.4.0",
600600
"eventemitter2": "^4.1.0",
601601
"express": "^4.14.1",

src/arduino/arduino.ts

+26-7
Original file line numberDiff line numberDiff line change
@@ -815,20 +815,35 @@ export class ArduinoApp {
815815
if (project !== "disable" && !globalDisable ||
816816
project === "enable") {
817817

818-
const parserEngines = this.makeCompilerParserEngines(dc);
819-
const compilerParser = new ccp.Runner(parserEngines);
818+
const engines = this.makeCompilerParserEngines(dc);
819+
const runner = new ccp.Runner(engines);
820820

821821
// set up the function to be called after parsing
822822
const _conclude = () => {
823-
const cppPropsPath = path.join(ArduinoWorkspace.rootPath, constants.CPP_CONFIG_FILE);
824-
if (compilerParser.processResult(cppPropsPath)) {
825-
arduinoChannel.info("IntelliSense configuration generated successfully.");
826-
} else {
823+
if (!runner.result) {
827824
arduinoChannel.warning("Failed to generate IntelliSense configuration.");
825+
return;
826+
}
827+
const pPath = path.join(ArduinoWorkspace.rootPath, constants.CPP_CONFIG_FILE);
828+
// TODO: check what kind of result we've got: gcc or other architecture:
829+
// and instantiate content accordingly (to be implemented within cocopa)
830+
const content = new ccp.CCppPropertiesContentResult(runner.result,
831+
"Arduino",
832+
ccp.CCppPropertiesISMode.Gcc_X64,
833+
ccp.CCppPropertiesCStandard.C11,
834+
// as of 1.8.11 arduino is on C++11
835+
ccp.CCppPropertiesCppStandard.Cpp11);
836+
const prop = new ccp.CCppProperties();
837+
prop.read(pPath);
838+
prop.merge(content);
839+
if (prop.write(pPath)) {
840+
arduinoChannel.info("IntelliSense configuration updated.");
841+
} else {
842+
arduinoChannel.info("IntelliSense configuration already up to date.");
828843
}
829844
};
830845
return {
831-
callback: compilerParser.callback(),
846+
callback: runner.callback(),
832847
conclude: _conclude,
833848
};
834849
}
@@ -849,6 +864,10 @@ export class ArduinoApp {
849864
sketch = `-o\\s+\\S*${ccp.regExEscape(sketch)}${dotcpp}\\.o`;
850865

851866
const matchPattern = [
867+
// make sure we're running g++
868+
/(?:^|-)g\+\+\s+/,
869+
// make sure we're compiling
870+
/\s+-c\s+/,
852871
// trigger parser when compiling the main sketch
853872
RegExp(sketch),
854873
];

0 commit comments

Comments
 (0)