bricks

build system and package manager for C/C++

why bricks

bricks is a simple solution to the dreaded build system.

Yes, I know that there are already enough build systems, meta build systems, and all that (insert obligatory xkcd comic here).

Here are the "killer features" in my opinion:

  • Super quick and easy project setup
  • Easy to integrate in existing projects
  • Package management, without a central repository

(by the way, it's called bricks because i imagined every package being the brick of a building.)

is this for me?

bricks is for you if:

  • you don't want to be bothered with build systems
  • you use an editor that supports clangd (neovim/vim, vscode)

bricks is not for you if:

  • you need to generate multiple build scripts like cmake does, for IDEs and such

Installation

Requirements

  • pkg-config
  • a c compiler
  • an archiver such as ar
  • rust toolchain if building from source or installing through cargo

Prebuilt binary

Through cargo

cargo install tesohh-bricks

From source

git clone https://github.com/Tesohh/bricks.git
cd bricks
cargo install --path .

Setup

In order to setup a project (a "brick"), first of all run:

bricks init <project_name>

This will create a binary project with basic configuration using C99.

Flags

  • If you need C++, add the --cpp flag.
  • If this project is a library, add the --lib flag.

The brick.toml file

This is where you configure your project, kind of like Cargo.toml or package.json.

Yours will look something like this:

[brick]
name = "<project_name>"
kind = "binary"
lang = "c"
edition = "c99"

See the next section so learn how to add libraries.

Adding libraries

System libraries

If you want to link a system-wide installed library (such as one you installed through your system's package manager), use the kind = "system" property.

Here's an example of linking raylib:

[brick]
name = "<project_name>"
kind = "binary"
lang = "c"
edition = "c99"

[libs.raylib]
kind = "system"
this requires `pkg-config` to be installed.

Through git

If you want to download a specific version of a library from a git repository:

[libs.<brickname>]
kind = "git"
repo = "<repo_uri>"
version = "v2"

Note: the <brickname> should be exactly the same as the one in the repo's brick.toml.

Other note: The version must be a commit id such as 801e950 or a tag name such as v2

This will clone the full repository under ~/.bricks/libs/<repo_uri>/full, checkout to that commit, and then copy the library into <repo_uri>/<version>.

If this library already has a brick.toml, you're done.

If it doesn't, you need to add overrides to your config.

you might need to run bricks build before you see headers working in your editor.

Overrides

In order to use libraries that don't support bricks, you will need to add overrides to your config.

You can override the following (optional) properties:

  • build: the ; separated commands used to build the project
  • run: the ; separated commands used to run the project after building
  • include_dir: the relative path to where to look for header files instead of <lib>/build/include
  • lib_dir: the relative path to where to look for lib files instead of <lib>/build/lib

Here's an example for using raylib through git:

[libs.raylib]
kind = "git"
repo = "https://github.com/raysan5/raylib.git"
version = "5.5"
overrides.build = "cd src; make"
overrides.include_dir = "src"
overrides.lib_dir = "src"
# yes, raylib builds into src for some reason

Brick level overrides

If you want to add bricks support to your project, you can use overrides there too if you need.

[brick]
name = "game"
kind = "binary"
lang = "c"
edition = "c99"
overrides.build = "make"
overrides.include_dir = "src"
overrides.run = "./game"

Of course, this can also be someone else's library!

If you want to use an external library that doesn't support bricks, it is recommended to fork the repo, adding a brick.toml (with overrides if needed)

Platforms

Platforms allow you to have certain configs only for certain platforms.

Here is an example config that uses

[brick]
name = "project"
kind = "binary"
lang = "c"
edition = "c99"
macos.ldflags = "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo"
macos.cflags = "-Wall"
windows.ldflags = "-lgdi32 -lwinmm -lopengl32"