@@ -50,7 +50,6 @@ import {
5050 GetPicotoolPathCommand ,
5151 GetOpenOCDRootCommand ,
5252 GetSVDPathCommand ,
53- SetupZephyrCommand ,
5453 GetWestPathCommand ,
5554 GetZephyrWorkspacePathCommand ,
5655} from "./commands/getPaths.mjs" ;
@@ -104,6 +103,7 @@ import { cmakeToolsForcePicoKit } from "./utils/cmakeToolsUtil.mjs";
104103import { NewRustProjectPanel } from "./webview/newRustProjectPanel.mjs" ;
105104import { OPENOCD_VERSION } from "./utils/sharedConstants.mjs" ;
106105import VersionBundlesLoader from "./utils/versionBundles.mjs" ;
106+ import { setupZephyr } from "./utils/setupZephyr.mjs" ;
107107
108108export async function activate ( context : ExtensionContext ) : Promise < void > {
109109 Logger . info ( LoggerSource . extension , "Extension activation triggered" ) ;
@@ -145,7 +145,6 @@ export async function activate(context: ExtensionContext): Promise<void> {
145145 new GetSVDPathCommand ( context . extensionUri ) ,
146146 new GetWestPathCommand ( ) ,
147147 new GetZephyrWorkspacePathCommand ( ) ,
148- new SetupZephyrCommand ( ) ,
149148 new NewZephyrProjectCommand ( ) ,
150149 new CompileProjectCommand ( ) ,
151150 new RunProjectCommand ( ) ,
@@ -262,63 +261,68 @@ export async function activate(context: ExtensionContext): Promise<void> {
262261 return ;
263262 }
264263
265- // Set Pico Zephyr Project false by default
266- await commands . executeCommand (
267- "setContext" ,
268- ContextKeys . isPicoZephyrProject ,
269- false
270- ) ;
271-
272- // Check for pico_zephyr in CMakeLists.txt
273- if (
274- readFileSync ( cmakeListsFilePath ) . toString ( "utf-8" ) . includes ( "pico_zephyr" )
275- ) {
276- Logger . info ( LoggerSource . extension , "Pico Zephyr Project" ) ;
264+ // Set Pico Zephyr Project false by default
277265 await commands . executeCommand (
278266 "setContext" ,
279267 ContextKeys . isPicoZephyrProject ,
280- true
268+ false
281269 ) ;
282270
283- // Update the board info if it can be found in tasks.json
284- const tasksJsonFilePath = join (
285- workspaceFolder . uri . fsPath ,
286- ".vscode" ,
287- "tasks.json"
288- ) ;
271+ // Check for pico_zephyr in CMakeLists.txt
272+ if (
273+ readFileSync ( cmakeListsFilePath ) . toString ( "utf-8" ) . includes ( "pico_zephyr" )
274+ ) {
275+ Logger . info ( LoggerSource . extension , "Project is of type: Zephyr" ) ;
276+ await commands . executeCommand (
277+ "setContext" ,
278+ ContextKeys . isPicoZephyrProject ,
279+ true
280+ ) ;
289281
290- // Update UI with board description
291- const board = findZephyrBoardInTasksJson ( tasksJsonFilePath ) ;
292-
293- if ( board !== undefined ) {
294- if ( board === "rpi_pico2/rp2350a/m33/w" ) {
295- ui . updateBoard ( "Pico 2W" ) ;
296- } else if ( board === "rpi_pico2/rp2350a/m33" ) {
297- ui . updateBoard ( "Pico 2" ) ;
298- } else if ( board === "rpi_pico/rp2040/w" ) {
299- ui . updateBoard ( "Pico W" ) ;
300- } else if ( board . includes ( "rpi_pico" ) ) {
301- ui . updateBoard ( "Pico" ) ;
302- } else {
303- ui . updateBoard ( "Other" ) ;
282+ // TODO: !!!!!!!!! IMPORTANT !!!!!!!!!
283+ // TODO: make sure zephy dependencies are installed
284+
285+ ui . showStatusBarItems ( false , true ) ;
286+
287+ // Update the board info if it can be found in tasks.json
288+ const tasksJsonFilePath = join (
289+ workspaceFolder . uri . fsPath ,
290+ ".vscode" ,
291+ "tasks.json"
292+ ) ;
293+
294+ // Update UI with board description
295+ const board = findZephyrBoardInTasksJson ( tasksJsonFilePath ) ;
296+
297+ if ( board !== undefined ) {
298+ if ( board === "rpi_pico2/rp2350a/m33/w" ) {
299+ ui . updateBoard ( "Pico 2W" ) ;
300+ } else if ( board === "rpi_pico2/rp2350a/m33" ) {
301+ ui . updateBoard ( "Pico 2" ) ;
302+ } else if ( board === "rpi_pico/rp2040/w" ) {
303+ ui . updateBoard ( "Pico W" ) ;
304+ } else if ( board . includes ( "rpi_pico" ) ) {
305+ ui . updateBoard ( "Pico" ) ;
306+ } else {
307+ ui . updateBoard ( "Other" ) ;
308+ }
304309 }
305310 }
306- }
307- // check for pico_sdk_init() in CMakeLists.txt
308- else if (
309- ! readFileSync ( cmakeListsFilePath )
310- . toString ( "utf-8" )
311- . includes ( "pico_sdk_init()" )
312- ) {
313- Logger . warn (
314- LoggerSource . extension ,
315- "No pico_sdk_init() in CMakeLists.txt found."
316- ) ;
317- await commands . executeCommand (
318- "setContext" ,
319- ContextKeys . isPicoProject ,
320- false
321- ) ;
311+ // check for pico_sdk_init() in CMakeLists.txt
312+ else if (
313+ ! readFileSync ( cmakeListsFilePath )
314+ . toString ( "utf-8" )
315+ . includes ( "pico_sdk_init()" )
316+ ) {
317+ Logger . warn (
318+ LoggerSource . extension ,
319+ "No pico_sdk_init() in CMakeLists.txt found."
320+ ) ;
321+ await commands . executeCommand (
322+ "setContext" ,
323+ ContextKeys . isPicoProject ,
324+ false
325+ ) ;
322326
323327 return ;
324328 }
@@ -870,108 +874,6 @@ export async function activate(context: ExtensionContext): Promise<void> {
870874 return ;
871875 }
872876
873- /*
874- const pythonPath = settings.getString(SettingsKey.python3Path);
875- if (pythonPath && pythonPath.includes("/.pico-sdk/python")) {
876- // check if python path exists
877- if (!existsSync(pythonPath.replace(HOME_VAR, homedir()))) {
878- Logger.warn(
879- LoggerSource.extension,
880- "Python path in settings does not exist.",
881- "Installing Python3 to default path."
882- );
883- const pythonVersion = /\/\.pico-sdk\/python\/([.0-9]+)\//.exec(
884- pythonPath
885- )?.[1];
886- if (pythonVersion === undefined) {
887- Logger.error(
888- LoggerSource.extension,
889- "Failed to get Python version from path."
890- );
891- await commands.executeCommand(
892- "setContext",
893- ContextKeys.isPicoProject,
894- false
895- );
896-
897- return;
898- }
899-
900- let result: string | undefined;
901- await window.withProgress(
902- {
903- location: ProgressLocation.Notification,
904- title:
905- "Downloading and installing Python. This may take a long while...",
906- cancellable: false,
907- },
908- async progress => {
909- if (process.platform === "win32") {
910- const versionBundle = await new VersionBundlesLoader(
911- context.extensionUri
912- ).getPythonWindowsAmd64Url(pythonVersion);
913-
914- if (versionBundle === undefined) {
915- Logger.error(
916- LoggerSource.extension,
917- "Failed to get Python download url from version bundle."
918- );
919- await commands.executeCommand(
920- "setContext",
921- ContextKeys.isPicoProject,
922- false
923- );
924-
925- return;
926- }
927-
928- // ! because data.pythonMode === 0 => versionBundle !== undefined
929- result = await downloadEmbedPython(versionBundle);
930- } else if (process.platform === "darwin") {
931- const result1 = await setupPyenv();
932- if (!result1) {
933- progress.report({
934- increment: 100,
935- });
936-
937- return;
938- }
939- const result2 = await pyenvInstallPython(pythonVersion);
940-
941- if (result2 !== null) {
942- result = result2;
943- }
944- } else {
945- Logger.info(
946- LoggerSource.extension,
947- "Automatic Python installation is only",
948- "supported on Windows and macOS."
949- );
950-
951- await window.showErrorMessage(
952- "Automatic Python installation is only " +
953- "supported on Windows and macOS."
954- );
955- }
956- progress.report({
957- increment: 100,
958- });
959- }
960- );
961-
962- if (result === undefined) {
963- Logger.error(LoggerSource.extension, "Failed to install Python3.");
964- await commands.executeCommand(
965- "setContext",
966- ContextKeys.isPicoProject,
967- false
968- );
969-
970- return;
971- }
972- }
973- }*/
974-
975877 ui . showStatusBarItems ( ) ;
976878 ui . updateSDKVersion ( selectedToolchainAndSDKVersions [ 0 ] ) ;
977879
0 commit comments