5.3 KiB
dcr gen
Generates IDE and build tool integration files for C/C++ development environments.
Usage
dcr gen project-info
dcr gen project-info --release
dcr gen compile-commands
dcr gen compile-commands --debug
dcr gen vscode
dcr gen vscode --release
dcr gen clion
dcr gen clion --debug
Subcommands
dcr gen project-info
Outputs project metadata as JSON array.
dcr gen project-info [--debug | --release]
Outputs structured information about the project (root project + all workspace members if present):
[
{
"name": "my-project",
"version": "1.0.0",
"root": "/path/to/root",
"profile": "debug",
"language": "c++",
"standard": "c++17",
"compiler": "g++",
"kind": "bin",
"sources": ["/path/to/root/src/main.cpp", ...],
"include_dirs": ["/path/to/dep/include", ...],
"lib_dirs": ["/path/to/dep/lib", ...],
"libs": ["somelib", ...],
"cflags": ["-Wall", ...],
"ldflags": ["-lm", ...]
}
]
This is useful for integrating DCR projects with custom build tools or scripts.
dcr gen compile-commands
Generates compile_commands.json for use by clangd, clang-tidy, and other tools.
dcr gen compile-commands [--debug | --release]
Writes ./compile_commands.json containing compilation database entries for all source files. This file is recognized by:
- LSP servers (
clangd,clang-tools-extra) - Linters (
clang-tidy) - Format tools (
clang-format)
The entries include:
- Full compiler command with flags
- Source file path
- Object file output path
- Project root as working directory
dcr gen vscode
Generates Visual Studio Code integration files.
dcr gen vscode [--debug | --release]
Creates .vscode/ directory with:
launch.json: Debug configurations (one per binary target, debug + release variants)tasks.json: Build/run/clean tasks usingdcrcommandssettings.json: Clangd configuration pointing tocompile_commands.jsonextensions.json: Recommendsclangd, disablescpptoolscompile_commands.json: Compilation database (same asdcr gen compile-commands)
Usage in VSCode:
- Open the Command Palette (
Ctrl+Shift+P) and select "Debug: Start Debugging" to run debugger - Press
Ctrl+Shift+Bto run the build task - Clangd will provide IntelliSense and diagnostics based on
compile_commands.json - Generated
launch.jsonuses CodeLLDB (type: "lldb"), so installvadimcn.vscode-lldb
dcr gen clion
Generates JetBrains CLion integration files.
dcr gen clion [--debug | --release]
Creates .idea/ directory with:
externalTools.xml: Registers DCR build/clean/gen commands as external toolscustomTargets.xml: Defines build targets for debug and releasemisc.xml: Points CLion tocompile_commands.jsonfor compilation database.idea/.gitignore: Ignores auto-generated filesrunConfigurations/*.xml: Debug run configs (one per binary target)compile_commands.json: Compilation database (same asdcr gen compile-commands)
Usage in CLion:
- Build/clean via Tools → DCR → Build Debug/Release/Clean
- Run/debug via Run → Run Configurations (dropdown) → select generated config
- Code completion and diagnostics come from the compilation database
Config values used
package.namebuild.compilerbuild.languagebuild.standardbuild.kindbuild.targetbuild.platformbuild.cflagsbuild.ldflagsbuild.debug/build.releasebuild.excludebuild.includebuild.pkg_configbuild.rootsbuild.src_disable- Workspace members (if
[workspace]is present)
Workspace support
When running dcr gen in a workspace root, all commands process both the root project and all workspace members:
project-inforeturns an array with entries for each member + rootcompile-commandsincludes entries from all membersvscodeandcliongenerate unified configurations that work across all members
Troubleshooting
Clangd not picking up includes
- Ensure
compile_commands.jsonexists in the workspace root - In VSCode settings, verify
clangd.argumentsincludes--compile-commands-dir=<workspace-root> - Rebuild via
dcr gen compile-commandsif sources or dependencies changed
Debug configuration not working
- Verify binary paths in
launch.jsonmatch actual build output (target/<profile>/binary-name) - For workspace projects, each member's debug config uses its own
target/directory - Ensure GDB/LLDB is installed:
gdb --versionorlldb --version - If VSCode reports unsupported debugger type, install the extension that matches
launch.jsontype (vadimcn.vscode-lldbforlldb)
CLion not recognizing includes
- Regenerate via
dcr gen clion --debug - File → Invalidate Caches → Invalidate and Restart
- Verify
.idea/misc.xmlpoints to correctcompile_commands.jsonpath
Notes
- Profiles default to
debugif not specified - Generation does not require the project to be built first
- Generated files are safe to commit; they are generated from
dcr.tomland thus repeatable - IDE configurations may be customized after generation, but changes will be overwritten on next
dcr genrun - For multi-binary projects,
vscodeandcliongenerate debug configs for all binaries (both debug + release variants)