Skip to content

evanwporter/muuk

Repository files navigation

muuk

demo

UPDATE (4/27): There is now basic module support for MSVC (Clang coming soon)

A cargo-like build system.

meme

Another relevant comic (all credit to xkcd):

xkcd comic

features

  • Big three compiler support (GCC, Clang, MSVC)
  • Big three platform support (Linux, MacOS, Windows)
  • Task runner using muuk run <script>. Works pretty much like npm run <script>
  • Clean command
  • C++ Meta builder built on top of Ninja
  • C++20 Experimental Module Support (MSVC only)
  • Able to define Platform, Compiler & Profile Specific Flags
  • All flags are automatically applied to dependencies

setup

muuk requires the following programs to be installed and available on the PATH:

  • git
  • ninja (you probably have this since I believe its bundled with most CMake distributions.)
  • wget
  • clang-scan-deps (only needed if you plan on using modules)

Thats it!

guide

A typical muuk.toml file looks like the one contained within this repo muuk.toml

Lets break it apart:

[package]

This section defines the package's metadata (name and version).

[package]
name = "muuk"
version = "1.0.0"
edition = "20"
  • name → The name of the project.
  • version → The project version.
  • edition → Doesn't do anything (yet)

[library]

The [library] section defines libraries that can be compiled separately and linked into other targets.

Example:

[library]
include = ["include"]
sources = ["src/source_file.cpp", "src/sauce_file.cpp - DSAUCE_FILE_ONLY_DEFINE -ISAUCE_FILE_ONLY_INCLUDE"]
sources = ["src/module_file.cppm"]
cflags = ["-Wall", "-Wextra"]
dependencies = { boost = { version = "1.75.0", muuk_path = "../boost" } }

Library Keys

  • include → A list of include directories.
  • sources → A list of source files for the library.
  • module → A list of module files for the library
  • cflags → Compiler flags specific to this library.
  • dependencies → Defines dependencies required by this library.

Note on the single file flags, you can define file specific compilation flags by including them after the definition.

Dependency Format:

dependencies = { dep_name = { version = "X.Y.Z", git = "https://example.com/author/repo.git", muuk_path = "path/to/dep" } }

[build]

This section defines build targets, which can be executables or other build artifacts.

Example:

[build.my_executable]
profiles = ["release", "debug"]
sources = ["src/main.cpp"]
dependencies = ["my_library"]

Build Target Keys

  • sources → Source files used to build the target.
  • dependencies → Libraries this build target depends on.

Note that this build artifact will include the compiler specific rules.

[profile]

Profiles define build configurations, such as debug and release, but they can be whatever.

Example:

[profile.base]
cflags = ["-std:20"]

[profile.debug]
inherits = ["base"]
cflags = ["-g", "-O0"]
lflags = []

[profile.release]
inherits = "base"
cflags = ["-O2"]
lflags = []

Profile Keys

  • cflags → Compiler flags for the profile.
  • lflags → Linker flags for the profile.

[platform]

The [platform] section defines platform-specific flags. Acceptable platforms are windows, linux, apple.

Example:

[platform.windows]
cflags = ["-DWIN32"]
lflags = ["-lkernel32"]

[platform.linux]
cflags = ["-DLINUX"]
lflags = ["-pthread"]

Platform Keys

  • cflags → Compiler flags for this platform.
  • lflags → Linker flags for this platform.

[compiler]

This section defines compiler-specific flags. Acceptable compilers are gcc, msvc or clang

Example:

[compiler.g++]
cflags = ["-std=c++20"]
lflags = ["-lstdc++"]

Compiler Keys

  • cflags → Compiler flags specific to this compiler.
  • lflags → Linker flags specific to this compiler.

[scripts]

This section defines build-related scripts, such as running an executable. This works like npm run <script>. Also muuk will add the name of your built executable so you can easily run it (not yet implemented though).

Example:

[scripts]
do = "something.exe"
  • run → Defines how to run the built executable.

todo

Little Extra Stuff I have Planned So I don't Forget

full compat with other meta-builders

[library.external]
type = "cmake",
path = "../some_cmake_lib",
args = ["-DBUILD_SHARED_LIBS=ON"]
outputs = ["build/cmake_some_cmake_lib/libmylib.a"]

Output will define the library to link against.

About

Yet Another Unnecessary C++ Build System

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •