A lightweight, cross-platform build tool for C projects using the DH-C system.
- Cargo-like project management (workspace and project commands)
- Cross-platform support (Windows, macOS, Linux)
- Auto-detection of the DH-C system
- Support for multiple build configurations (dev, test, profile, release, performance, embedded, micro)
- Automatic include/source file discovery
- IDE integration through
.clangdand VSCode tasks - Option to build without the DH library (
--no-libdh) - Configurable output suffix for build configurations
- Test mode with automatic cleanup
-
Clone or download this repository
-
Open a PowerShell prompt as Administrator
-
Navigate to the directory containing the
dh-c.cfile -
Run the installation script:
.\install-dh-c.ps1
-
Restart your terminal or PowerShell session
-
Clone or download this repository
-
Open a terminal
-
Navigate to the directory containing the
dh-c.cfile -
Make the installation script executable and run it:
chmod +x install-dh-c.sh ./install-dh-c.sh
-
Follow the on-screen instructions to complete the installation
Display help information:
dh-c --help
# or
dh-c -hDisplay version information:
dh-c --versionCreate a new workspace:
dh-c workspace my-workspaceCreate a new project:
dh-c project my-projectInitialize the current directory as a workspace or project:
dh-c workspace .
dh-c project .Build a single file:
dh-c build file.cBuild with a specific configuration:
dh-c build dev file.cBuild without the DH-C library:
dh-c build file.c --no-libdhBuild an entire project:
dh-c buildBuild and run a file:
dh-c run file.cBuild and run tests:
dh-c test test-file.cRun tests for an entire project:
dh-c testDH-C supports several predefined build configurations:
dev- Extended debug info, no optimization, assertions enabledtest- Standard debug info, basic optimization, assertions enabledprofile- Standard debug info, balanced optimization, assertions enabledrelease- Minimal debug info, balanced optimization, assertions disabledperformance- No debug info, aggressive optimization, assertions disabledembedded- No debug info, size optimization, assertions disabledmicro- No debug info, extreme size optimization, assertions disabled
Specify compiler:
dh-c build file.c --compiler=gccUse a specific C standard:
dh-c build file.c --std=c11Pass arguments to the program:
dh-c run file.c --args="arg1 arg2"Show commands being executed:
dh-c build file.c --show-commandsEnable output suffix for build configurations:
dh-c build dev file.c --use-output-suffixThe DH-C build tool includes a tasks.json template that provides VSCode integration with the following tasks:
dh>create workspace- Create a new workspacedh>create project- Create a new projectdh>build current file- Build the current filedh>build project- Build the entire projectdh>test current file- Run tests for the current filedh>test project- Run tests for the entire projectdh>run current file- Build and run the current filedh>run project- Build and run the entire projectdh>execute current file- Run the existing executable for the current file without buildingdh>execute project- Run the existing executable for the project without building
DH_HOME: Points to the DH library root directory. Set automatically by the installation scripts, but can be manually configured if needed.
A typical DH-C project follows this structure:
my-project/
├── include/my-project (public headers)
├── src/my-project (implementation files)
├── lib/ (third-party libraries)
├── .clangd (language server config)
├── .clang-format (code formatter config)
└── .vscode/ (IDE config)When running in test mode with dh-c test, a special executable with the -TEST suffix is created. This test executable is automatically removed after the test is completed, keeping your build directory clean.
Current version: 0.1.0-alpha.0.1