@@ -35,44 +35,46 @@ export async function setTargetInIDF(
3535 workspaceFolder : WorkspaceFolder ,
3636 selectedTarget : IdfTarget
3737) {
38- if ( ConfserverProcess . exists ( ) ) {
39- ConfserverProcess . dispose ( ) ;
40- }
41- const idfPathDir = readParameter ( "idf.espIdfPath" , workspaceFolder . uri ) ;
42- const buildDirPath = readParameter (
43- "idf.buildPath" ,
44- workspaceFolder . uri
45- ) as string ;
46- const idfPy = join ( idfPathDir , "tools" , "idf.py" ) ;
47- const modifiedEnv = await appendIdfAndToolsToPath ( workspaceFolder . uri ) ;
48- modifiedEnv . IDF_TARGET = undefined ;
49- const enableCCache = readParameter (
50- "idf.enableCCache" ,
51- workspaceFolder . uri
52- ) as boolean ;
53- const setTargetArgs : string [ ] = [ idfPy ] ;
54- if ( selectedTarget . isPreview ) {
55- setTargetArgs . push ( "--preview" ) ;
56- }
57- setTargetArgs . push ( "-B" , buildDirPath ) ;
58- if ( enableCCache ) {
59- modifiedEnv . IDF_CCACHE_ENABLE = "1" ;
60- } else {
61- modifiedEnv . IDF_CCACHE_ENABLE = undefined ;
62- }
63- if ( modifiedEnv . SDKCONFIG ) {
64- setTargetArgs . push ( `-DSDKCONFIG='${ modifiedEnv . SDKCONFIG } '` ) ;
65- }
66- const sdkconfigDefaults =
67- ( readParameter ( "idf.sdkconfigDefaults" ) as string [ ] ) || [ ] ;
38+ try {
39+ if ( ConfserverProcess . exists ( ) ) {
40+ ConfserverProcess . dispose ( ) ;
41+ }
42+ const idfPathDir = readParameter ( "idf.espIdfPath" , workspaceFolder . uri ) ;
43+ const buildDirPath = readParameter (
44+ "idf.buildPath" ,
45+ workspaceFolder . uri
46+ ) as string ;
47+ const idfPy = join ( idfPathDir , "tools" , "idf.py" ) ;
48+ const modifiedEnv = await appendIdfAndToolsToPath ( workspaceFolder . uri ) ;
49+ modifiedEnv . IDF_TARGET = undefined ;
50+ const enableCCache = readParameter (
51+ "idf.enableCCache" ,
52+ workspaceFolder . uri
53+ ) as boolean ;
54+ const setTargetArgs : string [ ] = [ idfPy ] ;
55+ if ( selectedTarget . isPreview ) {
56+ setTargetArgs . push ( "--preview" ) ;
57+ }
58+ setTargetArgs . push ( "-B" , buildDirPath ) ;
59+ if ( enableCCache ) {
60+ modifiedEnv . IDF_CCACHE_ENABLE = "1" ;
61+ } else {
62+ modifiedEnv . IDF_CCACHE_ENABLE = undefined ;
63+ }
64+ if ( modifiedEnv . SDKCONFIG ) {
65+ setTargetArgs . push ( `-DSDKCONFIG='${ modifiedEnv . SDKCONFIG } '` ) ;
66+ }
67+ const sdkconfigDefaults =
68+ ( readParameter ( "idf.sdkconfigDefaults" ) as string [ ] ) || [ ] ;
6869
69- if ( sdkconfigDefaults && sdkconfigDefaults . length ) {
70- setTargetArgs . push ( `-DSDKCONFIG_DEFAULTS='${ sdkconfigDefaults . join ( ";" ) } '` ) ;
71- }
70+ if ( sdkconfigDefaults && sdkconfigDefaults . length ) {
71+ setTargetArgs . push (
72+ `-DSDKCONFIG_DEFAULTS='${ sdkconfigDefaults . join ( ";" ) } '`
73+ ) ;
74+ }
7275
73- setTargetArgs . push ( "set-target" , selectedTarget . target ) ;
74- const pythonBinPath = await getVirtualEnvPythonPath ( workspaceFolder . uri ) ;
75- try {
76+ setTargetArgs . push ( "set-target" , selectedTarget . target ) ;
77+ const pythonBinPath = await getVirtualEnvPythonPath ( workspaceFolder . uri ) ;
7678 const setTargetResult = await spawn ( pythonBinPath , setTargetArgs , {
7779 cwd : workspaceFolder . uri . fsPath ,
7880 env : modifiedEnv ,
0 commit comments