Skip to content

Latest commit

 

History

History
212 lines (146 loc) · 4.52 KB

File metadata and controls

212 lines (146 loc) · 4.52 KB

DH-C Build Tool

A lightweight, cross-platform build tool for C projects using the DH-C system.

Features

  • 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 .clangd and VSCode tasks
  • Option to build without the DH library (--no-libdh)
  • Configurable output suffix for build configurations
  • Test mode with automatic cleanup

Installation

Windows

  1. Clone or download this repository

  2. Open a PowerShell prompt as Administrator

  3. Navigate to the directory containing the dh-c.c file

  4. Run the installation script:

    .\install-dh-c.ps1
  5. Restart your terminal or PowerShell session

Linux/macOS

  1. Clone or download this repository

  2. Open a terminal

  3. Navigate to the directory containing the dh-c.c file

  4. Make the installation script executable and run it:

    chmod +x install-dh-c.sh
    ./install-dh-c.sh
  5. Follow the on-screen instructions to complete the installation

Usage

Getting Help

Display help information:

dh-c --help
# or
dh-c -h

Display version information:

dh-c --version

Project Management

Create a new workspace:

dh-c workspace my-workspace

Create a new project:

dh-c project my-project

Initialize the current directory as a workspace or project:

dh-c workspace .
dh-c project .

Building and Running

Build a single file:

dh-c build file.c

Build with a specific configuration:

dh-c build dev file.c

Build without the DH-C library:

dh-c build file.c --no-libdh

Build an entire project:

dh-c build

Build and run a file:

dh-c run file.c

Build and run tests:

dh-c test test-file.c

Run tests for an entire project:

dh-c test

Build Configurations

DH-C supports several predefined build configurations:

  • dev - Extended debug info, no optimization, assertions enabled
  • test - Standard debug info, basic optimization, assertions enabled
  • profile - Standard debug info, balanced optimization, assertions enabled
  • release - Minimal debug info, balanced optimization, assertions disabled
  • performance - No debug info, aggressive optimization, assertions disabled
  • embedded - No debug info, size optimization, assertions disabled
  • micro - No debug info, extreme size optimization, assertions disabled

Additional Options

Specify compiler:

dh-c build file.c --compiler=gcc

Use a specific C standard:

dh-c build file.c --std=c11

Pass arguments to the program:

dh-c run file.c --args="arg1 arg2"

Show commands being executed:

dh-c build file.c --show-commands

Enable output suffix for build configurations:

dh-c build dev file.c --use-output-suffix

VSCode Integration

The DH-C build tool includes a tasks.json template that provides VSCode integration with the following tasks:

  • dh>create workspace - Create a new workspace
  • dh>create project - Create a new project
  • dh>build current file - Build the current file
  • dh>build project - Build the entire project
  • dh>test current file - Run tests for the current file
  • dh>test project - Run tests for the entire project
  • dh>run current file - Build and run the current file
  • dh>run project - Build and run the entire project
  • dh>execute current file - Run the existing executable for the current file without building
  • dh>execute project - Run the existing executable for the project without building

Environment Variables

  • DH_HOME: Points to the DH library root directory. Set automatically by the installation scripts, but can be manually configured if needed.

Project Structure

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)

Test Mode

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.

Version

Current version: 0.1.0-alpha.0.1