1 import { exec } from "child_process";
2 import { workspace, type Uri, window, ProgressLocation } from "vscode";
5 showRquirementsNotMetErrorMessage,
6 } from "./requirementsUtil.mjs";
7 import { join } from "path";
8 import { getSDKAndToolchainPath } from "./picoSDKUtil.mjs";
9 import type Settings from "../settings.mjs";
10 import { SettingsKey } from "../settings.mjs";
12 export async function configureCmakeNinja(
17 // check if CMakeLists.txt exists in the root folder
18 await workspace.fs.stat(
19 folder.with({ path: join(folder.path, "CMakeLists.txt") })
22 const rquirementsAvailable = await checkForRequirements(settings);
24 if (!rquirementsAvailable) {
25 void showRquirementsNotMetErrorMessage();
30 void window.withProgress(
32 location: ProgressLocation.Notification,
34 title: "Configuring CMake...",
36 // eslint-disable-next-line @typescript-eslint/require-await
37 async (progress, token) => {
38 const sdkPaths = await getSDKAndToolchainPath(settings);
39 const cmake = settings.getString(SettingsKey.cmakePath) || "cmake";
41 // TODO: analyze command result
42 // TODO: option for the user to choose the generator
43 const child = exec(`${cmake} -G Ninja -S . -B ./build`, {
47 // TODO: set PICO_SDK_PATH
48 // eslint-disable-next-line @typescript-eslint/naming-convention
49 PICO_SDK_PATH: sdkPaths?.[0],
50 // eslint-disable-next-line @typescript-eslint/naming-convention
51 PICO_TOOLCHAIN_PATH: sdkPaths?.[1],
55 //child.stdout?.on("data", data => {});
56 child.on("close", () => {
57 progress.report({ increment: 100 });
59 child.on("exit", () => {
60 progress.report({ increment: 100 });
63 token.onCancellationRequested(() => {