| Crates.io | suru |
| lib.rs | suru |
| version | 2.2.3 |
| created_at | 2025-02-23 16:52:33.658848+00 |
| updated_at | 2025-02-25 21:50:09.781241+00 |
| description | A modern replacement for make |
| homepage | |
| repository | https://github.com/DolphinGui/suru |
| max_upload_size | |
| id | 1566504 |
| size | 63,242 |
Suru is designed to be a modern replacement for Make. It implements modern features such as relocatable build directories, automatic dependency scanning, and more. It is intended for small to medium sized projects where dependency management is not a concern.
This is a sample of a minimal sufile. It contains the executable as well as the link instruction. The compilation steps for c and cpp files are built-in to suru. All build commands must be done via pattern matched recipes, which are separated from dependencies.
a: main.o lib/lib.o
% < *.o
g++ -o $@ $^ -O3
make allsuru
By default suru builds all targets.
make cleanrm -rd *
suru supports using build directories, so you can just build in a seperate directory and remove the build directory to clean up files.
make installsuru does not natively support installing applications, although neither does make. make install simply runs a script that installs the software.
In suru, there are three types of statements: variable declarations, tasks, and recipes. Variable declarations declare variables.
CPPFLAGS = -D CONFIG_MACRO=1
Tasks specify a target to be build and their dependencies. Tasks with dependencies can have their dependent tasks deduced from recipes. Tasks do not specify how to build the target.
a.exe: main.o
Recipes are like makefile pattern rules, and contain steps on how to build a target. They are not shell expressions, but use their own syntax. The % is replaced with the target name, while * matches anything. For example:
%.exe: *.o
The above rule would match the a.exe example above, since main.o is matches the *.o.
%.exe: %.o
This however would not match the a.exe example above, since it would only match a.o. * Rules in general can match any number of dependencies, while % can only match one.
Expressions in suru can either be a string literal, a variable, or a function. For example:
LITERAL = foo bar
/* Same as LITERAL */
VAR = $(LITERAL)
/* equals to FOO BAR */
FUN = $(upper $(LITERAL))
Expressions can be found in variable declarations or recipe steps.
suru is not a shell invoker due to poor Rust support. This means shell expressions such as pipe or environment variables do not work. In order to invoke shell expressions, a shell script can be used instead. See the complex example for a case where a shell file is invoked as a dependency.