| 1 | /* |
| 2 | Tasks definitions for compiling and running |
| 3 | Castle Game Engine projects in VS Code. |
| 4 | |
| 5 | You can use this file for .vscode/tasks.json file in a workspace, |
| 6 | or as "User level tasks" (indepedent of workspace). |
| 7 | |
| 8 | This tasks file allows to compile /run / compile+run the CGE project |
| 9 | associated with the currently open file. |
| 10 | |
| 11 | Since it uses the currently open file, |
| 12 | it will work even with repositories that contain multiple CGE projects, |
| 13 | like https://github.com/castle-engine/castle-engine/ |
| 14 | (which contains many examples and tools). |
| 15 | If your VS Code workspace is just a single CGE project, |
| 16 | then you can remove the line |
| 17 | |
| 18 | "cwd": "${fileDirname}" |
| 19 | |
| 20 | This way the tasks will just use CGE project in VS code workspace, |
| 21 | regardless of the currently open file. |
| 22 | |
| 23 | See https://go.microsoft.com/fwlink/?LinkId=733558 |
| 24 | for the documentation about the tasks.json format. |
| 25 | |
| 26 | This file is distributed as public domain. |
| 27 | */ |
| 28 | { |
| 29 | "version": "2.0.0", |
| 30 | "tasks": [ |
| 31 | // Compile and then Run the CGE project of the currently open editor file. |
| 32 | // This is like F9 in CGE editor. |
| 33 | { |
| 34 | "label": "(CGE) Compile And Run", |
| 35 | /* We use VS code "dependsOn" feature to run 2 tasks in a sequence. |
| 36 | This is better than using shell command with && which |
| 37 | is not universally supported by PowerShell. */ |
| 38 | "dependsOn": [ |
| 39 | "(CGE) Compile", |
| 40 | "(CGE) Run" |
| 41 | ], |
| 42 | "dependsOrder": "sequence", |
| 43 | "group": { |
| 44 | "kind": "build", |
| 45 | "isDefault": true |
| 46 | } |
| 47 | }, |
| 48 | // Compile the CGE project of the currently open editor file. |
| 49 | // This is like Ctrl + F9 in CGE editor. |
| 50 | { |
| 51 | "label": "(CGE) Compile", |
| 52 | "type": "shell", |
| 53 | /* Compile in debug mode using CGE build tool (calls FPC under the hood). |
| 54 | We pass -vb to make filenames obvious for problem matcher. */ |
| 55 | "command": "castle-engine compile --mode=debug", |
| 56 | "options": { |
| 57 | /* Run in the directory of currently open editor file. |
| 58 | CGE build tool will automatically detect the CGE project, |
| 59 | looking for CastleEngineManifest.xml file in parents. |
| 60 | |
| 61 | Alternatively: you can comment it out, then it will build assuming that |
| 62 | VS Code workspace corresponds to a CGE project (so CastleEngineManifest.xml |
| 63 | should be present in top-level of VS Code workspace). */ |
| 64 | "cwd": "${fileDirname}" |
| 65 | }, |
| 66 | "group": { |
| 67 | "kind": "build" |
| 68 | }, |
| 69 | "problemMatcher": { |
| 70 | "fileLocation": "autoDetect", |
| 71 | //["autoDetect", "${workspaceFolder}"], |
| 72 | "pattern": [ |
| 73 | { |
| 74 | /* |
| 75 | Match lines like |
| 76 | xxx.pas(123,456) Fatal: some message |
| 77 | Deliberately avoid matching summary line like |
| 78 | xxx.pas(2201) Fatal: There were 26 errors compiling module, stopping |
| 79 | Deliberately avoid |
| 80 | xxx.pas(648,15) Error: Found declaration: ... |
| 81 | because they only make sense when connected to previous error message, and VS Code reorders them. |
| 82 | Test: https://regex101.com/ (ECMAScript flavor) |
| 83 | */ |
| 84 | "regexp": "^([^\\(]+)\\(([\\d+,]+)\\)\\s+(Fatal|Warning|Error|Note|Hint):\\s+((?!\\(10026\\) There were)(?!There were)(?!Found declaration: )(?!\\(5088\\)Found declaration: ).*)$", |
| 85 | "file": 1, |
| 86 | // location may be line or line+column. |
| 87 | "location": 2, |
| 88 | "severity": 3, |
| 89 | "message": 4 |
| 90 | } |
| 91 | /* , |
| 92 | { |
| 93 | // Match lines like |
| 94 | // Compiling xxx.pas |
| 95 | "regexp": "^(Compiling) ([^\\s]+)$", |
| 96 | "file": 2, |
| 97 | "message": 1, |
| 98 | "kind": "file" |
| 99 | } |
| 100 | */ |
| 101 | ], |
| 102 | /* We need non-empty owner to hide older problems on recompilation. |
| 103 | See https://github.com/Microsoft/vscode/issues/50448, |
| 104 | https://github.com/microsoft/vscode/issues/66982 |
| 105 | */ |
| 106 | "owner": "cge" |
| 107 | } |
| 108 | }, |
| 109 | // Run the CGE project of the currently open editor file. |
| 110 | // This is like Shift + F9 in CGE editor. |
| 111 | { |
| 112 | "label": "(CGE) Run", |
| 113 | "type": "shell", |
| 114 | "command": "castle-engine run --windows-robust-pipes --mode=debug", |
| 115 | "options": { |
| 116 | "cwd": "${fileDirname}" |
| 117 | }, |
| 118 | "group": { |
| 119 | "kind": "build" |
| 120 | } |
| 121 | }, |
| 122 | { |
| 123 | "label": "(CGE) Run (no sound)", |
| 124 | "type": "shell", |
| 125 | "command": "castle-engine run --windows-robust-pipes --mode=debug -- --no-sound", |
| 126 | "options": { |
| 127 | "cwd": "${fileDirname}" |
| 128 | }, |
| 129 | "group": { |
| 130 | "kind": "build" |
| 131 | } |
| 132 | } |
| 133 | ] |
| 134 | } |