Giter Club home page Giter Club logo

mace's Introduction

About

Single-header build system for C. Uses C to exclusively build C.

Specificity, reduced scope, everything in service of simplicity.

Features

  • C syntax build file.
  • Simple API.
  • Single header: mace.h.
  • make-like usage and flags with mace convenience executable.
  • Tab completion (zsh only), see _mace.zsh
  • Compatible with gcc, clang, tcc toolchains.

How to: Single-header build

  1. Get mace.h
  2. Write your own macefile e.g. macefile.c
  3. Bootstrapping: gcc macefile.c -o builder
  4. Building: ./builder
    1. Reserved targets: ./builder clean, ./builder all
    2. Configs: ./builder -g release

Use the MACEFLAGS environment variable to set default flags.

How to: Make-like convenience executable build

  1. Install mace convenience executable
    1. Bootstrapping: gcc installer.c -o installer
    2. Run installer: sudo ./installer.
  2. Write your own macefile e.g. macefile.c
  3. Bootstrapping & building: mace

Use these macro definitions when compiling installer to customize mace:

  • -DPREFIX=<path> to change install path. Defaults to /usr/local.
  • -DDEFAULT_MACEFILE=<file> to change default macefile name. Defaults to macefile.c.
  • -DBUILDER=<file> to change builder executable path.
  • -DCC=<compiler> to change compiler used by mace. Defaults to gcc.
  • -DAR=<archiver> to change archiver used by mace. Defaults to ar.
  • -DZSH_COMPLETION=<path> to set path for mace zsh tab completion. Defaults to /usr/share/zsh/site-functions.

Why?

  • Too many build complex, slow build systems.
  • Using C to build C gets you free lunches.
    • Learning C is learning mace.
    • Full C functionality in your macefile.
  • Using C to build C gets me free lunches.
    • No weird syntax to create.
    • No bespoke parser to implement.

Limitations

  • POSIX glob.h required.
    • On Windows, Cygwin or MSYS2 shells might work. Untested.
  • Circular dependencies unsupported.

Under the hood

  • User inputs target dependencies with target.links and target.dependencies
    • Build order determined by depth first search through all target dependencies.
  • Mace saves file checksums to .sha1 files in <obj_dir>/src, <obj_dir>/include
    • Uses checksum to check if sources, headers change for recompilation.
  • Compiler computes object file dependencies, saved to .d files in <obj_dir>
    • Parsed into binary .ho file for faster reading.

Running tests

  1. cd into test folder
  2. Compile test: gcc test.c -o test -I..
  3. Run tests ./test

Running benchmarks

  1. cd into benchmarks folder
  2. Compile test: gcc benchmarks.c -o bench
  3. Run benchmarks ./benchmarks

Known issues

  • Can't compile targets if there are no headers?
    • Cannot reproduce in tests

Credits

mace's People

Contributors

gabinou avatar gabrieltaillon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.