Skip to content

Commit 6923783

Browse files
committed
use customextravars first
1 parent 116af31 commit 6923783

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ testFiles/blink
1010
!testFiles/dist
1111
testFiles/tools
1212
testFiles/testWorkspace/build
13-
testFiles/testWorkspace/sdkconfig.*
13+
testFiles/testWorkspace/sdkconfig*
1414
*.log
1515
.DS_Store
1616
bandit_output.txt

src/eim/migrationTool.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ import { pathExists } from "fs-extra";
2727
import { ESP } from "../config";
2828
import { getIdfMd5sum } from "./checkCurrentSettings";
2929

30+
export async function useCustomExtraVarsAsIdfSetup(customExtraVars: { [key: string]: string }, workspaceFolder) {
31+
if (customExtraVars["IDF_PATH"] && customExtraVars["IDF_TOOLS_PATH"] && customExtraVars["IDF_PYTHON_ENV_PATH"]) {
32+
const pythonBinPath = await getVirtualEnvPythonPath(workspaceFolder);
33+
const idfPathVersion = await getEspIdfFromCMake(customExtraVars["IDF_PATH"]);
34+
const gitPath = readParameter("idf.gitPath", workspaceFolder);
35+
const idfSetupId = getIdfMd5sum(customExtraVars["IDF_PATH"]);
36+
const currentIdfSetup: IdfSetup = {
37+
activationScript: "",
38+
id: idfSetupId,
39+
idfPath: customExtraVars["IDF_PATH"],
40+
isValid: false,
41+
gitPath: gitPath,
42+
version: idfPathVersion,
43+
toolsPath: customExtraVars["IDF_TOOLS_PATH"],
44+
sysPythonPath: "",
45+
python: pythonBinPath,
46+
};
47+
return currentIdfSetup;
48+
} else {
49+
return;
50+
}
51+
}
52+
3053
export async function useExistingSettingsToMakeNewConfig(workspaceFolder: Uri) {
3154
const espIdfPath = readParameter("idf.espIdfPath", workspaceFolder);
3255
const idfPathVersion = await getEspIdfFromCMake(espIdfPath);

src/versionSwitcher/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import { ConfigurationTarget, StatusBarItem, Uri, window } from "vscode";
2020
import { readParameter } from "../idfConfiguration";
2121
import { getIdfSetups } from "../eim/getExistingSetups";
2222
import { checkIdfSetup, saveSettings } from "../eim/verifySetup";
23-
import { useExistingSettingsToMakeNewConfig } from "../eim/migrationTool";
23+
import {
24+
useCustomExtraVarsAsIdfSetup,
25+
useExistingSettingsToMakeNewConfig,
26+
} from "../eim/migrationTool";
2427

2528
export async function selectIdfSetup(
2629
workspaceFolder: Uri,
@@ -62,21 +65,24 @@ export async function getCurrentIdfSetup(
6265
"idf.customExtraVars",
6366
workspaceFolder
6467
) as { [key: string]: string };
65-
const idfSetups = await getIdfSetups();
68+
const idfSetups = await getIdfSetups(logToChannel, false);
6669
let currentIdfSetup = idfSetups.find((idfSetup) => {
6770
idfSetup.idfPath === customExtraVars["IDF_PATH"] &&
6871
idfSetup.toolsPath === customExtraVars["IDF_TOOLS_PATH"];
6972
});
73+
if (!currentIdfSetup) {
74+
currentIdfSetup = await useCustomExtraVarsAsIdfSetup(
75+
customExtraVars,
76+
workspaceFolder
77+
);
78+
}
7079
if (!currentIdfSetup) {
7180
// Using implementation before EIM
7281
let currentIdfSetup = await useExistingSettingsToMakeNewConfig(
7382
workspaceFolder
7483
);
7584
return currentIdfSetup;
7685
}
77-
currentIdfSetup.isValid = await checkIdfSetup(
78-
currentIdfSetup,
79-
logToChannel
80-
);
86+
currentIdfSetup.isValid = await checkIdfSetup(currentIdfSetup, logToChannel);
8187
return currentIdfSetup;
8288
}

testFiles/testWorkspace/main/hello_world_main.c

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,14 @@
55
CONDITIONS OF ANY KIND, either express or implied.
66
*/
77
#include <stdio.h>
8-
#include "sdkconfig.h"
98
#include "freertos/FreeRTOS.h"
109
#include "freertos/task.h"
11-
#include "esp_system.h"
12-
#include "esp_spi_flash.h"
1310

1411
void app_main(void)
1512
{
16-
printf("Hello world!\n");
17-
18-
/* Print chip information */
19-
esp_chip_info_t chip_info;
20-
esp_chip_info(&chip_info);
21-
printf("This is %s chip with %d CPU core(s), WiFi%s%s, ",
22-
CONFIG_IDF_TARGET,
23-
chip_info.cores,
24-
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
25-
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
26-
27-
printf("silicon revision %d, ", chip_info.revision);
28-
29-
printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
30-
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
31-
32-
printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());
33-
34-
for (int i = 10; i >= 0; i--) {
35-
printf("Restarting in %d seconds...\n", i);
36-
vTaskDelay(1000 / portTICK_PERIOD_MS);
13+
int i = 0;
14+
while(1) {
15+
printf("Hello world!\n", i);
16+
vTaskDelay(5000 / portTICK_PERIOD_MS);
3717
}
38-
printf("Restarting now.\n");
39-
fflush(stdout);
40-
esp_restart();
4118
}

0 commit comments

Comments
 (0)