Skip to content

ThatOneGin/cbone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cbone

Cbone is a one-header library to make build files.

NOTE: this is an experimental library and anything can change at any moment. Cbone is also very unstable and should not be used for large builds.

The main idea of this is that you only need a C compiler to build a project and you don't need to get track of the build system's version.

Table of contents

Installation

  • Copy cbone.h into your project.
  • Create cbone.c file with your recipe.
  • compile cbone.c into cbone executable.
    • cc -o cbone cbone.c (swap cc with the C compiler of your preference)
  • run the executable using ./cbone

Usage

Here is a minimal build file which compiles main.c.

#define CBONE_IMPL
#include "cbone.h"

int main(int argc, char **argv) {
  /*
  ** this macro checks for any difference in the last
  ** time the source file was saved, and if there's a difference,
  ** it tries to recompile itself.
  */
  REBUILD_SELF(argc, argv);

  /*
  ** CMD is like writting in a shell, it creates the process with given arguments.
  ** cc is a macro used to identify which C compiler was used to compile the source file.
  */
  CMD(cc, "-o", "main", "main.c", "-Wall", "-Wextra", "-pedantic");

  return cbone_errcode;
}

You can take a look into this for a more detailed examples.

When to not use Cbone

  • When you already use a build system like Cmake or GNU Make, it doesn't make any sense to use Cbone.
  • When your project is too big, Cbone is meant to be used in tiny projects.

Pros and cons

Pros

  • You write more C
  • Code reuse (you use the same language for building and developing your project)
  • Portability (works on Windows and most Linux systems)

Cons

  • You need to be comfortable with implementing things by yourself
  • Useless in projects that don't use C or C++
  • Verbosity, as already mentioned, you write more C

Acknowledgements

This library is heavily inspired by nob.h (available under MIT or Public Domain license) and mostly on its predecessor nobuild (licensed under MIT license).

About

Verbose build system for C

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages