aboutsummaryrefslogtreecommitdiff

CBuild

A build system fully made in C, with configuration in C as well.

It's pretty simple to use, just put the .c and .h files in your include path, and then include the header file. You can then write a small C program, I personally call it build.c which contains something like this:

#if 0
tcc -run build.c $@
exit
#endif

#define CBUILD_IMPLEMENTATION
#include <cbuild.h>

int main(int argc, char **argv) {
  project_t proj = create_project("Sample project", "v1.0", LANG_C);
  char *sources;
  if (find_sources_in_directory(".*\\.c", "src", &sources) == false) {
    fprintf(stderr, "No sources found\n");
    exit(1);
  }
  executable_t exe = create_executable("hello", sources);
  add_target(&proj, &exe);
  if (argc > 1) {
    if (strcmp(argv[1], "clean") == 0) {
      clean(proj);
      return 0;
    }
  }
  build(proj);
  return 0;
}

As you can see, you can either use this as a header-only library, or you can compile the .c file and have it as a shared library somewhere.

After that, you can either run the compiler manually in the CLI, or, if you're on Linux, just make the file executable and run it with ./build.c or whatever you named your file.