Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ async function handleSyncData(data: { repo: string; remote: string; branch: stri

const checkoutResult = await checkoutBranch(repo, remote, branch);
if (!checkoutResult) {
// Not necessarily an error; maybe the repo doesn't exist in this workspace.
// Not an error; if there was an error then an error message should have been shown
// to the user already in the checkout function. Exceptions are handled up the stack.
console.debug(`${logTag} No Git checkout happened, skipping build`);
return;
}
Expand All @@ -327,12 +328,24 @@ async function handleSyncData(data: { repo: string; remote: string; branch: stri
`${extensionName}: Checked out branch '${branch}' from '${repo}/${remote}'`,
);

const cmakeFiles = await vscode.workspace.findFiles("**/CMakeLists.txt");
if (cmakeFiles.length > 0) {
console.debug(`${logTag} Found CMake files`);
await runCmakeCommands();
} else {
// Common and normal use case; may not be a CMake project.
// TODO: Perhaps we should ask the user what kind of build system they use and error if we can't run CMake?
console.debug(`${logTag} No CMake files found`);
}
}

async function runCmakeCommands() {
console.log(`${logTag} CMake configure`);
await vscode.commands.executeCommand("cmake.configure");

// Wait a moment for CMake to finish up (or we get "already running" errors).
console.log(`${logTag} Waiting for CMake`);
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, 500));

console.log(`${logTag} CMake build`);
await vscode.commands.executeCommand("cmake.build");
Expand Down