1 unstable release
0.2.4 | Apr 12, 2022 |
---|
#749 in Build Utils
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:
- 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.
- Currently, you might have to use
- It can track whether files that are modified in-place need to be rebuilt.
- While this is possible with Make, it is inconvenient.
- 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. - Rule files are written in TOML and use Rust's regex syntax to match and replace file patterns.
- It's cross-platform.
- It's very fast.
- Uses
WalkParallel
to scan directories (the same asfd
andripgrep
) - Multithreaded by default, automatically parallelizing tasks as much as possible
- Uses
- 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
~11–20MB
~258K SLoC