Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix windows paths for gcovr #509

Merged
merged 4 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/coverage/coverageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,24 @@ export async function getGcovFilterPaths() {

const idfExists = await dirExistPromise(espIdfPath);
if (idfExists) {
pathsToFilter.push("--filter", join(espIdfPath, "components"));
pathsToFilter.push(
"--filter",
join(espIdfPath, "components").replace(/\\/g, "/")
);
}
const adfExists = await dirExistPromise(espAdfPath);
if (adfExists) {
pathsToFilter.push("--filter", join(espAdfPath, "components"));
pathsToFilter.push(
"--filter",
join(espAdfPath, "components").replace(/\\/g, "/")
);
}
const mdfExists = await dirExistPromise(espMdfPath);
if (mdfExists) {
pathsToFilter.push("--filter", join(espMdfPath, "components"));
pathsToFilter.push(
"--filter",
join(espMdfPath, "components").replace(/\\/g, "/")
);
}
return pathsToFilter;
}
Expand All @@ -83,13 +92,13 @@ export async function buildJson(dirPath: string) {
"gcovr",
[
"--filter",
".",
".*",
...componentsDir,
"--gcov-executable",
gcovTool,
"--json",
],
dirPath
dirPath.replace(/\\/g, "/")
);
return JSON.parse(result);
}
Expand Down Expand Up @@ -141,20 +150,26 @@ export async function generateCoverageForEditors(
if (fileParts && fileParts.length > 1) {
const fileName = fileParts.pop();
gcovObjFilePath = join(
dirPath,
"build",
"esp-idf",
fileParts[fileParts.length - 1],
"CMakeFiles",
`__idf_${fileParts[fileParts.length - 1]}.dir`,
fileName
);
).replace(/\\/g, "/");
}
}

for (const gcovFile of gcovJsonObj.files) {
const gcovFilePath = gcovFile.file as string;
if (
gcovFile.file === gcovObjFilePath ||
gcovFile.file === editor.document.fileName
gcovObjFilePath.toLowerCase().indexOf(gcovFilePath.toLowerCase()) !==
-1 ||
editor.document.fileName
.replace(/\\/g, "/")
.toLowerCase()
.indexOf(gcovFilePath.toLowerCase()) !== -1
) {
const coveredEditor: textEditorWithCoverage = {
allLines: [],
Expand Down
20 changes: 17 additions & 3 deletions src/espIdf/debugAdapter/verifyApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export async function verifyAppBinary(workspaceFolder: string) {
const modifiedEnv = appendIdfAndToolsToPath();
const serialPort = readParameter("idf.port");
const flashBaudRate = readParameter("idf.flashBaudRate");
const idfPath = readParameter("idf.espIdfPath");
const pythonBinPath = readParameter("idf.pythonBinPath") as string;
const esptoolPath = join(
idfPath,
"components",
"esptool_py",
"esptool",
"esptool.py"
);
const flasherArgsJsonPath = join(
workspaceFolder,
"build",
Expand All @@ -39,8 +48,9 @@ export async function verifyAppBinary(workspaceFolder: string) {

try {
const cmdResult = await spawn(
"esptool.py",
pythonBinPath,
[
esptoolPath,
"-p",
serialPort,
"verify_flash",
Expand All @@ -53,9 +63,13 @@ export async function verifyAppBinary(workspaceFolder: string) {
}
);
Logger.info(cmdResult.toString());
if (cmdResult.toString().indexOf("verify FAILED (digest mismatch)") !== -1) {
if (
cmdResult.toString().indexOf("verify FAILED (digest mismatch)") !== -1
) {
return false;
} else if (cmdResult.toString().indexOf("verify OK (digest matched)") !== -1) {
} else if (
cmdResult.toString().indexOf("verify OK (digest matched)") !== -1
) {
return true;
}
return false;
Expand Down
15 changes: 12 additions & 3 deletions src/espIdf/partition-table/partitionFlasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

import { basename } from "path";
import { basename, join } from "path";
import { Progress, ProgressLocation, window, workspace } from "vscode";
import { readParameter } from "../../idfConfiguration";
import { Logger } from "../../logger/logger";
Expand All @@ -36,10 +36,19 @@ export async function flashBinaryToPartition(offset: string, binPath: string) {
: "";
const modifiedEnv = appendIdfAndToolsToPath();
const serialPort = readParameter("idf.port");
const idfPath = readParameter("idf.espIdfPath");
const pythonBinPath = readParameter("idf.pythonBinPath") as string;
const esptoolPath = join(
idfPath,
"components",
"esptool_py",
"esptool",
"esptool.py"
);

await spawn(
"esptool.py",
["-p", serialPort, "write_flash", offset, binPath],
pythonBinPath,
[esptoolPath, "-p", serialPort, "write_flash", offset, binPath],
{
cwd: workspaceFolder,
env: modifiedEnv,
Expand Down
51 changes: 36 additions & 15 deletions src/espIdf/partition-table/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class PartitionTreeDataProvider
try {
const modifiedEnv = appendIdfAndToolsToPath();
const serialPort = readParameter("idf.port") as string;
const idfPath = readParameter("idf.espIdfPath");
const pythonBinPath = readParameter("idf.pythonBinPath") as string;
const partitionTableOffsetOption = await window.showQuickPick(
[
{
Expand Down Expand Up @@ -129,9 +131,25 @@ export class PartitionTreeDataProvider
"partitionTable.csv"
);

const esptoolPath = join(
idfPath,
"components",
"esptool_py",
"esptool",
"esptool.py"
);

const genEsp32PartPath = join(
idfPath,
"components",
"partition_table",
"gen_esp32part.py"
);

await spawn(
"esptool.py",
pythonBinPath,
[
esptoolPath,
"-p",
serialPort,
"read_flash",
Expand All @@ -145,10 +163,14 @@ export class PartitionTreeDataProvider
}
);

await spawn("gen_esp32part.py", [partTableBin, partTableCsv], {
cwd: workspaceFolder,
env: modifiedEnv,
});
await spawn(
pythonBinPath,
[genEsp32PartPath, partTableBin, partTableCsv],
{
cwd: workspaceFolder,
env: modifiedEnv,
}
);
const csvData = await readFile(partTableCsv);
let csvItems = this.CSV2JSON(csvData.toString());
this.partitionItems = this.createPartitionItemNode(csvItems);
Expand Down Expand Up @@ -190,24 +212,23 @@ export class PartitionTreeDataProvider
public CSV2JSON(csv: String): PartitionItem[] {
const rows = new Array<PartitionItem>();
const lines = csv.split(EOL);
const comment = lines.shift();
if (!comment.includes("# ESP-IDF Partition Table")) {
const matches = csv.match(/#\s*Name,\s*Type,\s*SubType,\s*Offset,\s*Size,\s*Flags/g);
if (!matches || !matches.length) {
console.log("Not a partition table csv, skipping...");
return rows;
}
const headers = lines.shift();
lines.forEach((line) => {
if (line === "") {
if (line === "" || line.startsWith("#")) {
return;
}
const cols = line.split(",");
rows.push({
name: cols.shift(),
type: cols.shift(),
subtype: cols.shift(),
offset: cols.shift(),
size: cols.shift(),
flag: cols.shift() === "encrypted" ? true : false,
name: cols.shift().trim(),
type: cols.shift().trim(),
subtype: cols.shift().trim(),
offset: cols.shift().trim(),
size: cols.shift().trim(),
flag: cols.shift().trim() === "encrypted" ? true : false,
error: undefined,
});
});
Expand Down
21 changes: 11 additions & 10 deletions src/views/partition-table/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,25 @@ export function JSON2CSV(rows: PartitionTable.Row[]): String {
export function CSV2JSON(csv: String): PartitionTable.Row[] {
const rows = new Array<PartitionTable.Row>();
const lines = csv.split(EOL);
const comment = lines.shift();
if (!comment.includes("# ESP-IDF Partition Table")) {
const matches = csv.match(
/#\s*Name,\s*Type,\s*SubType,\s*Offset,\s*Size,\s*Flags/g
);
if (!matches || !matches.length) {
console.log("Not a partition table csv, skipping...");
return rows;
}
const headers = lines.shift();
lines.forEach((line) => {
if (line === "") {
if (line === "" || line.startsWith("#")) {
return;
}
const cols = line.split(",");
rows.push({
name: cols.shift(),
type: cols.shift(),
subtype: cols.shift(),
offset: cols.shift(),
size: cols.shift(),
flag: cols.shift() === "encrypted" ? true : false,
name: cols.shift().trim(),
type: cols.shift().trim(),
subtype: cols.shift().trim(),
offset: cols.shift().trim(),
size: cols.shift().trim(),
flag: cols.shift().trim() === "encrypted" ? true : false,
error: undefined,
});
});
Expand Down