A build tool for c projects, with a small testing framework.
This CLI tool is intended to give a Cargo-like experience for simple c projects. It's primary goals are to reduce the tedium of writing a makefile, adding and running tests, and adding additional source files with proper include guards.
The framework currently relies on [Just] for most of its functionality. The basis of this application is the [justfile].
As the project is inspired by Cargo and other modern development tools, it seems natural to use Rust and its plethora of CLI libraries.
crame projects currently use [Just] as their main build tool and test runner. The [justfile] is also dependent on fd and requires watchexec for file watching.
A c compiler linked to the cc executable is also required.
If you're a Rust programmer, crame can be installed with cargo.
sh
cargo install crame
crame is written in Rust, so you'll need to grab a Rust installation in order to compile it.
To build crame:
sh
git clone https://github.com/sonro/crame
cd crame
cargo build --release
./target/release/crame
Using crame new creates a project in the specified directory. Automatically
intializes a git repository, unless the directory is already within one, or the
--vcs option is set to none.
sh
crame new my-project
Resulting directory structure:
tree
my-project
├── Crame.toml
├── justfile
├── lib
├── src
│   └── main.c
└── tests
    ├── run.c
    ├── test_all.c
    └── unit
        └── it_works.c
Build the program as an executable in the target/ directory.
sh
just build
Build the program and then run it.
sh
just run
The justfile will add all the .c files in src/ and lib/ as arguments for
the c compiler. It doesn't need to be kept up to date as with a makefile.
Use just add-module to create .c and .h files in the src directory.
sh
just add-module my_module
Resulting files:
```c // src/my_module.h
```
```c // src/my_module.c
```
Test files must have the follwing layout:
```c
// include all headers in this section
// create tests in this section
```
Add a unit test in tests/unit/. Use the TEST macro to specify a test name
and function and the ASSERT macro to test a Boolean value.
```c // tests/unit/my_test.c
TEST("test name") { ASSERT(1 + 1 == 2); }
```
Include your test files in tests/test_all.c.
```c // tests/test_all.c
... ```
Build and run all tests with
ini
just test
This builds all .c files in the src/, lib/ and tests/ directories.
crame is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.