Skip to content

Commit

Permalink
Merge pull request #4 from espressif/master
Browse files Browse the repository at this point in the history
merge from GH master
  • Loading branch information
pwmb committed Mar 25, 2020
2 parents 08e1a73 + 20b8292 commit 4222336
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ These are project IDF Project specific settings
| `idf.showOnboardingOnInit` | Show ESP-IDF Configuration window on extension activation |
| `idf.adapterTargetName` | ESP-IDF target Chip (Example: esp32) |
| `idf.openOcdConfigs` | Configuration files for OpenOCD. Relative to OPENOCD_SCRIPTS folder |
| `idf.saveBeforeBuild` | Save all the edited files before building (default `true`) |

When you use the command **ESP-IDF: Set Espressif device target** it will override `idf.adapterTargetName` with selected chip and `idf.openOcdConfigs` with its default OpenOCD Configuration files. If you want to customize the `idf.openOcdConfigs` alone, you can modify your user settings.json or use **ESP-IDF: Device configuration** and select `Enter OpenOCD Configuration File Paths list` by entering each file separated by comma ",".

Expand Down
3 changes: 2 additions & 1 deletion i18n/en/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"trace.trace_size.description": "trace_size will set for the apptrace",
"trace.stop_tmo.description": "stop_tmo will be set for the apptrace",
"trace.wait4halt.description": "wait4halt will be set for the apptrace",
"trace.skip_size.description": "skip_size will be set for the apptrace"
"trace.skip_size.description": "skip_size will be set for the apptrace",
"param.saveBeforeBuildDescription": "Save all the edited files in the workspace before proceeding with the build, although if fail to save files it will build anyways"
}
3 changes: 2 additions & 1 deletion i18n/es/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"trace.trace_size.description": "trace_size will set for the apptrace",
"trace.stop_tmo.description": "stop_tmo will be set for the apptrace",
"trace.wait4halt.description": "wait4halt will be set for the apptrace",
"trace.skip_size.description": "skip_size will be set for the apptrace"
"trace.skip_size.description": "skip_size will be set for the apptrace",
"param.saveBeforeBuildDescription": "Guarde todos los archivos editados en el espacio de trabajo antes de continuar con la compilación, aunque si no guarda los archivos, se compilará de todos modos"
}
3 changes: 2 additions & 1 deletion i18n/zh-CN/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"trace.trace_size.description": "apptrace:设置 trace_size",
"trace.stop_tmo.description": "apptrace:设置 stop_tmo",
"trace.wait4halt.description": "apptrace:设置 wait4halt",
"trace.skip_size.description": "apptrace:设置 skip_size"
"trace.skip_size.description": "apptrace:设置 skip_size",
"param.saveBeforeBuildDescription": "在继续进行构建之前,将所有编辑的文件保存在工作区中,尽管如果无法保存文件,无论如何都会进行构建"
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@
"default": "0",
"scope": "resource",
"description": "%trace.skip_size.description%"
},
"idf.saveBeforeBuild": {
"type": "boolean",
"default": true,
"scope": "resource",
"description": "%param.saveBeforeBuildDescription%"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"trace.trace_size.description": "trace_size will set for the apptrace",
"trace.stop_tmo.description": "stop_tmo will be set for the apptrace",
"trace.wait4halt.description": "wait4halt will be set for the apptrace",
"trace.skip_size.description": "skip_size will be set for the apptrace"
"trace.skip_size.description": "skip_size will be set for the apptrace",
"param.saveBeforeBuildDescription": "Save all the edited files in the workspace before proceeding with the build, although if fail to save files it will build anyways"
}
3 changes: 2 additions & 1 deletion schema.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"trace.trace_size.description",
"trace.stop_tmo.description",
"trace.wait4halt.description",
"trace.skip_size.description"
"trace.skip_size.description",
"param.saveBeforeBuildDescription"
]
}
18 changes: 17 additions & 1 deletion src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import { ChildProcess, spawn } from "child_process";
import { mkdirSync } from "fs";
import { join } from "path";
import * as treeKill from "tree-kill";
import { OutputChannel } from "vscode";
import { OutputChannel, workspace } from "vscode";
import * as idfConf from "../idfConfiguration";
import { Logger } from "../logger/logger";
import { appendIdfAndToolsToPath, canAccessFile } from "../utils";

export class BuildManager {
Expand All @@ -33,6 +35,14 @@ export class BuildManager {
this.outputChannel = outputChannel;
}
public async build() {
try {
await this.saveBeforeBuild();
} catch (error) {
const errorMessage =
"Failed to save unsaved files, ignoring and continuing with the build";
Logger.error(errorMessage, error);
Logger.warnNotify(errorMessage);
}
await this._build("cmake", ["-G", "Ninja", `..`]);
await this._build("cmake", ["--build", "."]);
}
Expand Down Expand Up @@ -105,4 +115,10 @@ export class BuildManager {
private buildDone() {
BuildManager.isBuilding = false;
}
private async saveBeforeBuild() {
const shallSaveBeforeBuild = idfConf.readParameter("idf.saveBeforeBuild");
if (shallSaveBeforeBuild) {
await workspace.saveAll();
}
}
}

0 comments on commit 4222336

Please sign in to comment.