Sprinter: добавить отладку C-исходников и интеграцию VS Code

This commit is contained in:
2026-09-15 17:58:41 +03:00
parent 50c6e56b7b
commit e4695b8281
62 changed files with 7147 additions and 27 deletions
+53
View File
@@ -0,0 +1,53 @@
const fs = require('fs');
const path = require('path');
function absolutePath(value, workspace) {
if (!value || !workspace) return null;
const expanded = value.replace(/\$\{workspaceFolder\}/g, workspace);
return path.resolve(workspace, expanded);
}
function projectForLaunch(configuration, workspace) {
const explicit = absolutePath(configuration.project, workspace);
if (explicit) {
if (!fs.existsSync(path.join(explicit, 'Makefile'))) {
throw new Error(`Нет Makefile в каталоге проекта: ${explicit}`);
}
return explicit;
}
const build = absolutePath(configuration.build, workspace);
if (!build) return null;
let directory = path.dirname(build);
while (directory !== path.dirname(directory)) {
if (fs.existsSync(path.join(directory, 'Makefile'))) {
return directory;
}
if (directory === workspace) break;
directory = path.dirname(directory);
}
return null;
}
function isSprinterMakefile(filename) {
try {
return /include\s+\$\(PROJ_ROOT\)\/app\.mk/.test(
fs.readFileSync(filename, 'utf8'));
} catch (_) {
return false;
}
}
function taskLabel(project, workspace) {
const relative = path.relative(workspace, project);
return `Sprinter: Build ${relative || '.'}`;
}
function makeCommand() {
if (process.platform === 'win32') {
throw new Error('Native Windows build/debug пока не поддерживается');
}
return fs.existsSync('/usr/bin/make') ? '/usr/bin/make' : 'make';
}
module.exports = {absolutePath, projectForLaunch, isSprinterMakefile,
taskLabel, makeCommand};