An Easy To Use CLI Build Tool For C
Project description
CBuild
CBuild is a lightweight and straightforward command-line build tool for C projects, designed to simplify the compilation process without the bloat and complexity of CMake. It provides just enough functionality to compile and link C source code with ease, making it ideal for small to medium-sized projects.
Features
- Minimal Configuration: Specify project details in a
.cbuild
configuration file. - Compiler Support: Choose your compiler (currently supports MinGW GCC; others planned).
- Automatic Dependency Handling: Collects
.c
files from source directories and includes them in the build process. - Target Output: Supports building executables (
.exe
), shared libraries (.dll
), and static libraries (.a
). - Cross-Platform Design: Although developed with Windows in mind, future versions aim for broader compatibility.
Installation
Install via PyPI:
pip install cbuild
Getting Started
Step 1. Create a .cbuild
Configuration File
The .cbuild
file defines your project settings. Here's an example:
[CBUILD]
compiler = gcc # specify a compiler
defines = DEBUG # (comma-separated) pre-processing defines
source_dir = src # target a directory for recursive search
sources = main.c, utils.c # (comma-separated) target specific source files
output_type = exe # spcify the type of file returned
output_dir = build/ # specify the target output directory
libraries = m # (comma-separated) specify project ld flags
include_dirs = include # (comma-separated) specify paths to project include directories
library_dirs = lib # (comma-separated) specify paths to linked-libraries
project_name = MyProject # specify the target output's name
Step 2. Build Your Project
Run the following command, pointing to your .cbuild
configuration file:
cbuild myproject.cbuild
This will compile and link your project, generating the output in the specified output_dir
.
Example Usage
Given a directory structure like this, the configuration outlined in Step 1
will work just fine!:
MyProject/
├── src/
│ ├── main.c
│ ├── utils.c
├── include/
│ ├── utils.h
├── myproject.cbuild
Running cbuild myproject.cbuild
will:
- Compile
main.c
andutils.c
into object files. - Link the object files into an executable called
MyProject.exe
in thebuild/
directory.
Why CBuild?
While tools like CMake are powerful, they can be overly complex for straightforward tasks. CBuild focuses on simplicity and ease of use, letting you focus on writing code rather than managing build configurations.
CBUILD's Wishlist
-
Add Compiler Support:
- Extend support for Clang, MSVC, and other compilers.
- Auto-detect the default system compiler.
-
Cross-Platform Compatibility:
- Test and adapt for Linux and macOS environments.
- Replace calls to
os.system
withsubprocess
for better portability.
-
Custom Build Scripts:
- Allow users to define pre-build or post-build commands.
-
Improved Error Handling:
- Provide more descriptive errors when commands fail.
- Catch common misconfigurations in the
.cbuild
file.
-
Incremental Builds:
- Implement a mechanism to skip recompilation of unchanged files.
-
Verbose Mode:
- Add a CLI flag for detailed logging of compilation steps.
-
Parallel Builds:
- Utilize multiple CPU cores to speed up compilation.
Contributing
Contributions are welcome! If you encounter issues or have feature suggestions, feel free to open an issue or submit a pull request on GitHub.
License
CBuild is licensed under the MIT License. See LICENSE
for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cbuild-2024.0.7.tar.gz
.
File metadata
- Download URL: cbuild-2024.0.7.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 822c038cfa5627f0ffc8388e0e8547b730377e59fba6f900ede70fd85a7064af |
|
MD5 | c8513722d0b3d9a380cfc14bedb236b5 |
|
BLAKE2b-256 | 5308c3344cbca0f23c15b7f29b89fa588095e22860a30f790c441a3e8aa1b544 |