RedditPP Mascot

RedditPP

r/teenagersbutcode • … • u/SirPigari

I made my own build system

Hiiii i was tired of having to write ifeq statements for everything in Makefile so i made my own build system Its called [Mewo](https://github.com/SirPigari/mewo) and its more of an Aliasing system than build system because i needed to just have a label to do run some commands with some variables on some platforms

Im aware i couldve just make a custom build script like build.rs or build.bat but i wanted to do it this way

Its very similar to Make, just put this into Mewofile:

```mewo build: echo Hello world ```

And then you just run `mewo build` and it runs it

To invoke a label you just put it as an argument without any - at the start.

The platform specific thingy works by using so called "attributes" like:

```mewo #windows echo "Hello from windows" #linux echo "Hello from linux" #macos echo "Hello from macos" ```

This will echo different thing depending on the platform (Anything in global scope runs on just `mewo`, there is no all target like in make)

It also supports functions:

```mewo echo "File mewo is ${#sizeof(file, "mewo", KiB)} KiB in size" ```

The first argument is `file` because it can be also `var` where it would rreturn the size of the variable

And a function that returns boolean can be used as an attribute too:

```mewo #changed(main.c) gcc main.c -c -o main.o #exists(config.txt) echo "Config found" #env(DEBUG) echo "Debug mode enabled" ```

Changed checks if a file was changed (stores the timestamp in a cache) Exists checks if a file exists Env returns the value of the environment variable, if its used as an attribute it runs the command if the env var exists

It also supports features thru +F and -F cli args

`mewo +F feature -F default_feature`

```mewo #features("default_feature")

#feature("feature") echo "This is a feature" #feature("default_feature") echo "This is the default feature" ```

The attribute can be also put on a label instead of a command to turn on/off a whole label:

```mewo #windows build: echo Windows build echo second command

#unix build: echo Unix build echo second command ```

Also labels can be just aliases like this:

```mewo build-lib: echo Building library...

lib: build-lib ```

There are variables too:

```mewo A = 10 B ?= 20

echo A is ${A} and B is ${B} ```

The `?=` means only if its not already defined, kinda like in Make.

`mewo -DB=10 -DA=20` and now B is 10 instead of 20 but A is still 10

`${var}` is used to interpolate values, and can be used anywhere:

```mewo echo Running on: ${#arch()} ; x86_64, arm64, x86, arm, riscv, or unknown echo Is Windows? ${#windows} ; true or false echo File exists? ${#exists(main.c)} echo File changed? ${#changed(main.c)} echo Has env? ${#env(DEBUG)} echo Has feature? ${#feature(async)} ```

You can also do arithmatics but thats kinda obvious.

Its meant to be really small (~150KiB)

If you think anything should be added/changed let me know!

— 0