[Web] Add vscode launch json to cpp template

This commit is contained in:
orosmatthew 2024-03-13 20:44:47 -04:00
parent ba5fa18000
commit 1e849c8686
2 changed files with 69 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import {
templateCppCMakeLists,
templateCppGitIgnore,
templateCppProblem,
templateCppVscodeLaunch,
templateCppVscodeTasks,
templateJavaProblem
} from './templates';
@ -52,6 +54,10 @@ async function addProblemsCPP(opts: OptsAddProblems) {
});
opts.fs.writeFileSync(join(opts.dir, 'CMakeLists.txt'), cmakeLists);
opts.fs.mkdirSync(join(opts.dir, '.vscode'));
opts.fs.writeFileSync(join(opts.dir, '.vscode', 'launch.json'), templateCppVscodeLaunch);
opts.fs.writeFileSync(join(opts.dir, '.vscode', 'tasks.json'), templateCppVscodeTasks);
opts.contest.problems.forEach((problem) => {
opts.fs.mkdirSync(join(opts.dir, problem.pascalName));
const filledTemplate = templateCppProblem.replaceAll('%%pascalName%%', problem.pascalName);

View File

@ -41,5 +41,67 @@ int main()
return 0;
}`;
export const templateCppGitIgnore = `/build
export const templateCppGitIgnore = `/**/build
`;
export const templateCppVscodeLaunch = `{
"configurations": [
{
"name": "C/C++: g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "\${fileDirname}/build/\${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "\${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
],
"version": "2.0.0"
}
`;
export const templateCppVscodeTasks = `{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"\${file}",
"-o",
"\${fileDirname}/build/\${fileBasenameNoExtension}.out"
],
"options": {
"cwd": "\${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
`;