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

[VSC-1430] Fix duplicate output; Add notification for success #1290

Merged
merged 2 commits into from
Oct 25, 2024
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
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,7 @@
"Open ESP-IDF Terminal": "Abrir terminal ESP-IDF",
"Doctor Command": "Comando médico",
"Execute Custom Task": "Ejecutar tarea personalizada",
"Wait for ESP-IDF build or flash to finish": "Espere a que finalice la compilación o la actualización de ESP-IDF"
"Wait for ESP-IDF build or flash to finish": "Espere a que finalice la compilación o la actualización de ESP-IDF",
"Target {0} Set Successfully.": "Objetivo {0} configurado con éxito.",
"Unknown error occurred while setting IDF target.": "Ocurrió un error desconocido al configurar el objetivo IDF."
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,7 @@
"Open ESP-IDF Terminal": "Abra o terminal ESP-IDF",
"Doctor Command": "Comando Médico",
"Execute Custom Task": "Executar tarefa personalizada",
"Wait for ESP-IDF build or flash to finish": "Aguarde a conclusão da compilação ou flash do ESP-IDF"
"Wait for ESP-IDF build or flash to finish": "Aguarde a conclusão da compilação ou flash do ESP-IDF",
"Target {0} Set Successfully.": "Alvo {0} definido com sucesso.",
"Unknown error occurred while setting IDF target.": "Ocorreu um erro desconhecido ao definir o alvo IDF."
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,7 @@
"Open ESP-IDF Terminal": "Открыть терминал ESP-IDF",
"Doctor Command": "Доктор Команда",
"Execute Custom Task": "Выполнить пользовательскую задачу",
"Wait for ESP-IDF build or flash to finish": "Подождите завершения сборки или прошивки ESP-IDF."
"Wait for ESP-IDF build or flash to finish": "Подождите завершения сборки или прошивки ESP-IDF.",
"Target {0} Set Successfully.": "Цель {0} успешно установлена.",
"Unknown error occurred while setting IDF target.": "Произошла неизвестная ошибка при установке цели IDF."
}
4 changes: 3 additions & 1 deletion l10n/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,7 @@
"Open ESP-IDF Terminal": "打开 ESP-IDF 终端",
"Doctor Command": "医生指挥",
"Execute Custom Task": "执行自定义任务",
"Wait for ESP-IDF build or flash to finish": "等待 ESP-IDF 构建或刷新完成"
"Wait for ESP-IDF build or flash to finish": "等待 ESP-IDF 构建或刷新完成",
"Target {0} Set Successfully.": "目标 {0} 设置成功",
"Unknown error occurred while setting IDF target.": "设置 IDF 目标时发生未知错误"
}
22 changes: 14 additions & 8 deletions src/espIdf/setTarget/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ProgressLocation,
WorkspaceFolder,
window,
l10n,
} from "vscode";
import {
NotificationMode,
Expand All @@ -34,7 +35,10 @@ import { getBoards, getOpenOcdScripts } from "../openOcd/boardConfiguration";
import { getTargetsFromEspIdf } from "./getTargets";
import { setTargetInIDF } from "./setTargetInIdf";

export async function setIdfTarget(placeHolderMsg: string, workspaceFolder: WorkspaceFolder) {
export async function setIdfTarget(
placeHolderMsg: string,
workspaceFolder: WorkspaceFolder
) {
const configurationTarget = ConfigurationTarget.WorkspaceFolder;
if (!workspaceFolder) {
return;
Expand Down Expand Up @@ -98,17 +102,19 @@ export async function setIdfTarget(placeHolderMsg: string, workspaceFolder: Work
workspaceFolder.uri
);
}

await setTargetInIDF(workspaceFolder, selectedTarget);
} catch (err) {
const errMsg =
err && err.message ? err.message : "Error running idf.py set-target";
if (errMsg.indexOf("are satisfied") > -1) {
Logger.info(err.message.toString());
OutputChannel.append(err.message.toString());
err instanceof Error
? err.message
: l10n.t("Unknown error occurred while setting IDF target.");

if (errMsg.includes("are satisfied")) {
Logger.info(errMsg);
OutputChannel.appendLine(errMsg);
} else {
Logger.errorNotify(err, err, "setIdfTarget");
OutputChannel.append(err);
Logger.errorNotify(errMsg, err, "setIdfTarget");
OutputChannel.appendLine(errMsg);
}
}
}
Expand Down
26 changes: 19 additions & 7 deletions src/espIdf/setTarget/setTargetInIdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import { ConfserverProcess } from "../menuconfig/confServerProcess";
import { IdfTarget } from "./getTargets";
import { getVirtualEnvPythonPath } from "../../pythonManager";
import * as vscode from "vscode";

export async function setTargetInIDF(
workspaceFolder: WorkspaceFolder,
Expand Down Expand Up @@ -71,11 +72,22 @@ export async function setTargetInIDF(

setTargetArgs.push("set-target", selectedTarget.target);
const pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder.uri);
const setTargetResult = await spawn(pythonBinPath, setTargetArgs, {
cwd: workspaceFolder.uri.fsPath,
env: modifiedEnv,
});
Logger.info(setTargetResult.toString());
OutputChannel.append(setTargetResult.toString());
setCCppPropertiesJsonCompilerPath(workspaceFolder.uri);
try {
const setTargetResult = await spawn(pythonBinPath, setTargetArgs, {
cwd: workspaceFolder.uri.fsPath,
env: modifiedEnv,
});
Logger.info(setTargetResult.toString());
const msg = vscode.l10n.t(
"Target {0} Set Successfully.",
selectedTarget.target.toLocaleUpperCase()
);
OutputChannel.appendLineAndShow(msg, "Set Target");
Logger.infoNotify(msg);
setCCppPropertiesJsonCompilerPath(workspaceFolder.uri);
} catch (error) {
throw new Error(
`Failed to set target ${selectedTarget.target}: ${error.message}.`
);
}
}