Getting involved
It’s time to get involved once you have the fork and all required software. This guide covers IDE setup and debugging. While we use Visual Studio Code as an example, Martin can be developed with any editor that supports Rust.
Editor-specifc Guides (click to expand)
Visual Studio Code
Install these essential extensions:
- rust-analyzer - Rust language server
- CodeLLDB - Debugger for Rust
- Even Better TOML - TOML syntax highlighting
- GitLens - Git integration (optional)
Vim/Neovim
Use rustaceanvim
Emacs
Use either
RustRover
RustRover supports rust out of the box
Zed
Zed supports rust out of the box
Quick Development Setup
Before diving into IDE configuration, make sure your development environment is ready:
# Validate all required tools are installed
just validate-tools
# Start the development environment
just start # starts test database
just help # shows common commands
Debugging with launch.json
Generally, you need to debug martin with specific arguments or a config file to fix issues or add features.
The most convenient way is to generate a launch.json and modify it.
Generate
Press F1
on your keyboard, and input “Generate Launch Configurations from Cargo.toml”. Execute it and save it to your .vscode
directory.
Modify
Let’s say you want to debugging Martin with this command:
martin postgres://postgres:postgres@localhost:5411/db
You could find Debug executable 'martin'
in your launch.json
, like below:
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'martin'",
"cargo": {
"args": [
"build",
"--bin=martin",
"--package=martin"
],
"filter": {
"name": "martin",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
Just copy and paste after it, and modify your pasted like this:
{
"type": "lldb",
"request": "launch",
"name": "my first debug", // name it any as you like
"cargo": {
"args": [
"build",
"--bin=martin",
"--package=martin"
],
"filter": {
"name": "martin",
"kind": "bin"
}
},
"args": ["postgres://postgres:postgres@localhost:5411/db"], // add your arguments here
"env": {
"DEFAULT_SRID": 4490, // add your env here
},
"cwd": "${workspaceFolder}"
},
Add a breakpoint
Go to any part you’re interested in of martin code and add a breakpoint.
We add a breakpoint here in the start of martin.
use clap::Parser;
use log::{error, info, log_enabled};
use martin::args::{Args, OsEnv};
use martin::srv::new_server;
use martin::{read_config, Config, MartinResult};
const VERSION: &str = env!("CARGO_PKG_VERSION");
async fn start(args: Args) -> MartinResult<()> {
info!("Starting Martin v{VERSION}");
Debugging
Click Run and Debug
on the left panel of Visual Studio Code
. Choose my first debug
and press F5
on your keyboard.
Wait for the breakpoint to be hit.