#task #build #make

build make_ultra

A simple task-runner which tracks changes in files and runs commands based on rules in parallel

1 unstable release

0.2.4 Apr 12, 2022

#613 in Build Utils

MIT OR Apache-2.0 OR Unlicense

25KB
426 lines

Make Ultra

Make Ultra is a task runner useful for running certain commands when your files change.

Check out the following rule file (written in TOML):

# saved as makeultra.toml

folders = ["Foo", "Bar"]

[[rule]]
# rules use rusty regex: https://docs.rs/regex/*/regex/#syntax
from = '(?P<name>.*)\.js$'
to = '$name.min.js'
exclude = '\.min\.js$'
# For all commands: $i = input file; $o = output file
command = 'terser $i -o $o'

[[rule]]
from = '(?P<name>.*)\.min\.js$'
to = '$name.min.js.gz'
command = 'zopfli $i'

[[rule]]
from = '(?P<name>.*)\.min\.js$'
to = '$name.min.js.br'
command = 'brotli -f $i'

# Optimize png files in-place, only re-running when you modify them:
[[rule]]
from = '(?P<name>.*\.png)$'
to = '$name'
command = 'optipng -clobber -fix -quiet -strip all $i'

Why Another?

I needed something faster than Grunt and Gulp that had a simpler syntax than Make and tracking of files modified in-place. Make Ultra accomplishes these goals.

Features:

  1. It doesn't require you to explicitly state dependencies.
    • Currently, you might have to use exclude to ensure your rules aren't overly-zealous. Automatically determining appropriate rules is on the roadmap.
    • On a side note: It's not exactly a beta build system, but Make Ultra borrows from the ideas of a beta build system. It processes dependencies first and recursively crawls down to their dependents.
  2. It can track whether files that are modified in-place need to be rebuilt.
  3. File hashes are generated with hashbrown's hasher (and hashbrown is used for all HashMaps interally), serialized with bincode, and cached within .make_cache, allowing us to keep track of whether or not to rebuild files and their dependents without relying on filesystem metadata.
  4. Rule files are written in TOML and use Rust's regex syntax to match and replace file patterns.
  5. It's cross-platform.
  6. It's very fast.
    • Uses WalkParallel to scan directories (the same as fd and ripgrep)
    • Multithreaded by default, automatically parallelizing tasks as much as possible
  7. You can generate a DOT file with the --dot option and view the build tree.

Still a Long Way to Go

More is in the works for this project to be worthy of its name, but I don't know if anything can ever beat Make. This also serves as a project for me to learn Rust while accomplishing something that hasn't been done yet in the language (cargo-make isn't language-agnostic and just doesn't have support for wildcards).

This project is not ready for a lot of use cases (e.g. multiple dependencies for a single input file, so you can't link together your .o files yet). Right now, it actually works great if you are simply running tasks on individual files, but it lacks support for the things that are necessary for more elaborate workloads that will allow you to build larger projects.


Other Similar, Language-Agnostic Tools

Dependencies

~12MB
~203K SLoC