@@ -41,6 +41,7 @@ import type { ITask } from "../models/task.mjs";
4141import  {  getWestConfigValue ,  updateZephyrBase  }  from  "./westConfig.mjs" ; 
4242import  {  addZephyrVariant  }  from  "./westManifest.mjs" ; 
4343import  LastUsedDepsStore  from  "./lastUsedDeps.mjs" ; 
44+ import  {  geSemverPre  }  from  "./semverUtil.mjs" ; 
4445
4546interface  ZephyrSetupValue  { 
4647  cmakeMode : number ; 
@@ -574,6 +575,9 @@ async function showNoWgetError(): Promise<void> {
574575    "wget not found in Path. Please install wget and ensure "  + 
575576      "it is available in Path. "  + 
576577      "See the Zephyr notes in the pico-vscode README for guidance." , 
578+     { 
579+       modal : true , 
580+     } , 
577581    "Open README" 
578582  ) ; 
579583  if  ( response  ===  "Open README" )  { 
@@ -593,7 +597,7 @@ async function checkMacosLinuxDeps(): Promise<boolean> {
593597
594598  const  wget  =  await  which ( "wget" ,  {  nothrow : true  } ) ; 
595599  if  ( ! wget )  { 
596-     await  showNoWgetError ( ) ; 
600+     void  showNoWgetError ( ) ; 
597601
598602    return  false ; 
599603  } 
@@ -628,7 +632,7 @@ async function checkWindowsDeps(): Promise<boolean> {
628632
629633  const  wget  =  await  which ( "wget" ,  {  nothrow : true  } ) ; 
630634  if  ( ! wget )  { 
631-     await  showNoWgetError ( ) ; 
635+     void  showNoWgetError ( ) ; 
632636
633637    return  false ; 
634638  } 
@@ -1628,6 +1632,78 @@ export async function updateZephyrCompilerPath(
16281632      } 
16291633    } 
16301634
1635+     // support for v1.0.0 zephyr sdk toolchain location change 
1636+     const  launchUri  =  Uri . joinPath ( workspaceUri ,  ".vscode" ,  "launch.json" ) ; 
1637+     if  ( geSemverPre ( sdkVersion ,  "v1.0.0-beta1" ) )  { 
1638+       zephyrConfig . compilerPath . replace ( 
1639+         `${ sdkVersion }  , 
1640+         `${ sdkVersion }  
1641+       ) ; 
1642+ 
1643+       try  { 
1644+         await  workspace . fs . stat ( launchUri ) ; 
1645+ 
1646+         const  launchJson  =  JSON . parse ( 
1647+           td . decode ( await  workspace . fs . readFile ( launchUri ) ) 
1648+         )  as  { 
1649+           configurations : Array < {  name : string ;  armToolchainPath : string  } > ; 
1650+         } ; 
1651+ 
1652+         const  picoDebugConfig  =  launchJson . configurations . find ( 
1653+           c  =>  c . name  ===  "Pico Debug (Zephyr)" 
1654+         ) ; 
1655+         if  ( picoDebugConfig )  { 
1656+           picoDebugConfig . armToolchainPath  = 
1657+             picoDebugConfig . armToolchainPath . replace ( 
1658+               "}/arm-zephyr-eabi/" , 
1659+               "}/gnu/arm-zephyr-eabi/" 
1660+             ) ; 
1661+ 
1662+           const  te  =  new  TextEncoder ( ) ; 
1663+           await  workspace . fs . writeFile ( 
1664+             launchUri , 
1665+             te . encode ( JSON . stringify ( launchJson ,  null ,  2 ) ) 
1666+           ) ; 
1667+         } 
1668+       }  catch  { 
1669+         // do nothing 
1670+       } 
1671+     }  else  { 
1672+       zephyrConfig . compilerPath . replace ( 
1673+         `${ sdkVersion }  , 
1674+         `${ sdkVersion }  
1675+       ) ; 
1676+ 
1677+       try  { 
1678+         await  workspace . fs . stat ( launchUri ) ; 
1679+ 
1680+         const  launchJson  =  JSON . parse ( 
1681+           td . decode ( await  workspace . fs . readFile ( launchUri ) ) 
1682+         )  as  { 
1683+           configurations : Array < {  name : string ;  armToolchainPath : string  } > ; 
1684+         } ; 
1685+ 
1686+         const  picoDebugConfig  =  launchJson . configurations . find ( 
1687+           c  =>  c . name  ===  "Pico Debug (Zephyr)" 
1688+         ) ; 
1689+         if  ( picoDebugConfig )  { 
1690+           picoDebugConfig . armToolchainPath  = 
1691+             picoDebugConfig . armToolchainPath . replace ( 
1692+               "}/gnu/arm-zephyr-eabi/" , 
1693+               "}/arm-zephyr-eabi/" 
1694+             ) ; 
1695+ 
1696+           const  te  =  new  TextEncoder ( ) ; 
1697+           await  workspace . fs . writeFile ( 
1698+             launchUri , 
1699+             te . encode ( JSON . stringify ( launchJson ,  null ,  2 ) ) 
1700+           ) ; 
1701+         } 
1702+       }  catch  { 
1703+         // do nothing 
1704+       } 
1705+     } 
1706+ 
16311707    const  te  =  new  TextEncoder ( ) ; 
16321708    await  workspace . fs . writeFile ( 
16331709      cppPropertiesUri , 
@@ -1718,3 +1794,48 @@ export async function zephyrVerifyCMakeCache(
17181794    return ; 
17191795  } 
17201796} 
1797+ 
1798+ export  async  function  zephyrGetSelectedSnippets ( 
1799+   workspaceUri : Uri 
1800+ ) : Promise < string [ ] >  { 
1801+   const  snippetsUri  =  Uri . joinPath ( workspaceUri ,  ".vscode" ,  "tasks.json" ) ; 
1802+ 
1803+   // search for "Compile Project" get every i+1 where i is an index and args[i]=="-S" || "--snippet" 
1804+   try  { 
1805+     await  workspace . fs . stat ( snippetsUri ) ; 
1806+ 
1807+     const  td  =  new  TextDecoder ( "utf-8" ) ; 
1808+     const  tasksJson  =  JSON . parse ( 
1809+       td . decode ( await  workspace . fs . readFile ( snippetsUri ) ) 
1810+     )  as  {  tasks : ITask [ ]  } ; 
1811+ 
1812+     const  compileTask  =  tasksJson . tasks . find ( 
1813+       t  =>  t . label  ===  "Compile Project" 
1814+     ) ; 
1815+     if  ( compileTask  ===  undefined )  { 
1816+       return  [ ] ; 
1817+     } 
1818+ 
1819+     const  selectedSnippets : string [ ]  =  [ ] ; 
1820+     for  ( let  i  =  0 ;  i  <  compileTask . args . length ;  i ++ )  { 
1821+       if  ( compileTask . args [ i ]  ===  "-S"  ||  compileTask . args [ i ]  ===  "--snippet" )  { 
1822+         if  ( i  +  1  <  compileTask . args . length )  { 
1823+           selectedSnippets . push ( compileTask . args [ i  +  1 ] ) ; 
1824+         } 
1825+       } 
1826+     } 
1827+ 
1828+     return  selectedSnippets ; 
1829+   }  catch  ( error )  { 
1830+     Logger . warn ( 
1831+       LoggerSource . zephyrSetup , 
1832+       `Failed to read tasks.json file: ${ unknownErrorToString ( error ) }  
1833+     ) ; 
1834+     void  window . showWarningMessage ( 
1835+       "Failed to read tasks.json file. "  + 
1836+         "Make sure the file exists and has a Compile Project task." 
1837+     ) ; 
1838+ 
1839+     return  [ ] ; 
1840+   } 
1841+ } 
0 commit comments