A bunch of helper files to improve workflows for developing Odin programs in VS Code:
- Tasks
- Building and cleaning
- Checking
- Memory profiling
- Show compiler errors and warnings as VS Code Problems on the correct file and line
- Launch tasks for debug and release
In case you haven't done already.
- Get and build the compiler
- Add Odin root to path, and as
ODIN_ROOT
- Add Odin root to path, and as
- Get and build the language server
- Install the OLS extension
- set the
ols.server.path
to the ols binary
- set the
- In your project root
- Create
ols.json
either from OLS github, or use the one included in this repo - Create
odinfmt.json
either from OLS github, or use the one included in this repo
- Create
- Open the folder in VS code, ideally using the workspace file. This is important, as opening files individually won’t work.
To add debug and release build targets and get errors work with VS Code’s Problems, use this as the .vscode\tasks.json
included in the repo.
There are 5 tasks in it:
- Build - Debug: builds the package corresponding to the currently open file, in debug mode
- Build - Release: builds the package corresponding to the currently open file, in release mode
- Check: Runs Odin’s check command. It doesn’t produce any artifacts
- Clean: Deletes the output folder
- Profile Memory: Builds and memory profiles the binary using MTuner
Output folder is [workspace-root]/out/[build-mode]
.
I also suggest using the Error Lens extension to show the errors inline.
If you have Visual Studio installed, you can use its cpp debugger on windows to debug Odin programs in VS Code. Use the .vscode/launch.json
to add the corresponding launch tasks.
After that, use the Launch - Debug preset (mapped to F5) to debug the currently open package.
Alternatively, you can use the RAD Debugger to debug Odin programs.
- Get and build the debugger
- Build odin project with
-debug
. This generates the.pdb
file. You can do it by using the Build - Debug task from this repo. - In RAD debugger, set
[package-name].main
as the Custom Entry Point
- Get the latest MTuner
- Add the unpacked folder to the
PATH
environment variable - Either
- Open MTuner and drop the binary on it, or
- Inside VS Code, use the Profile Memory task to build and profile