/* Tasks definitions for compiling and running Castle Game Engine projects in VS Code. You can use this file for .vscode/tasks.json file in a workspace, or as "User level tasks" (indepedent of workspace). This tasks file allows to compile /run / compile+run the CGE project associated with the currently open file. Since it uses the currently open file, it will work even with repositories that contain multiple CGE projects, like https://github.com/castle-engine/castle-engine/ (which contains many examples and tools). If your VS Code workspace is just a single CGE project, then you can remove the line "cwd": "${fileDirname}" This way the tasks will just use CGE project in VS code workspace, regardless of the currently open file. See https://go.microsoft.com/fwlink/?LinkId=733558 for the documentation about the tasks.json format. This file is distributed as public domain. */ { "version": "2.0.0", "tasks": [ // Compile and then Run the CGE project of the currently open editor file. // This is like F9 in CGE editor. { "label": "(CGE) Compile And Run", /* We use VS code "dependsOn" feature to run 2 tasks in a sequence. This is better than using shell command with && which is not universally supported by PowerShell. */ "dependsOn": [ "(CGE) Compile", "(CGE) Run" ], "dependsOrder": "sequence", "group": { "kind": "build", "isDefault": true } }, // Compile the CGE project of the currently open editor file. // This is like Ctrl + F9 in CGE editor. { "label": "(CGE) Compile", "type": "shell", /* Compile in debug mode using CGE build tool (calls FPC under the hood). We pass -vb to make filenames obvious for problem matcher. */ "command": "castle-engine compile --mode=debug", "options": { /* Run in the directory of currently open editor file. CGE build tool will automatically detect the CGE project, looking for CastleEngineManifest.xml file in parents. Alternatively: you can comment it out, then it will build assuming that VS Code workspace corresponds to a CGE project (so CastleEngineManifest.xml should be present in top-level of VS Code workspace). */ "cwd": "${fileDirname}" }, "group": { "kind": "build" }, "problemMatcher": { "fileLocation": "autoDetect", //["autoDetect", "${workspaceFolder}"], "pattern": [ { /* Match lines like xxx.pas(123,456) Fatal: some message Deliberately avoid matching summary line like xxx.pas(2201) Fatal: There were 26 errors compiling module, stopping Deliberately avoid xxx.pas(648,15) Error: Found declaration: ... because they only make sense when connected to previous error message, and VS Code reorders them. Test: https://regex101.com/ (ECMAScript flavor) */ "regexp": "^([^\\(]+)\\(([\\d+,]+)\\)\\s+(Fatal|Warning|Error|Note|Hint):\\s+((?!\\(10026\\) There were)(?!There were)(?!Found declaration: )(?!\\(5088\\)Found declaration: ).*)$", "file": 1, // location may be line or line+column. "location": 2, "severity": 3, "message": 4 } /* , { // Match lines like // Compiling xxx.pas "regexp": "^(Compiling) ([^\\s]+)$", "file": 2, "message": 1, "kind": "file" } */ ], /* We need non-empty owner to hide older problems on recompilation. See https://github.com/Microsoft/vscode/issues/50448, https://github.com/microsoft/vscode/issues/66982 */ "owner": "cge" } }, // Run the CGE project of the currently open editor file. // This is like Shift + F9 in CGE editor. { "label": "(CGE) Run", "type": "shell", "command": "castle-engine run --windows-robust-pipes --mode=debug", "options": { "cwd": "${fileDirname}" }, "group": { "kind": "build" } }, { "label": "(CGE) Run (no sound)", "type": "shell", "command": "castle-engine run --windows-robust-pipes --mode=debug -- --no-sound", "options": { "cwd": "${fileDirname}" }, "group": { "kind": "build" } } ] }