58 lines
1.8 KiB
Markdown
58 lines
1.8 KiB
Markdown
|
---
|
|||
|
title: >
|
|||
|
just vs make
|
|||
|
pubDate: 2023-04-11
|
|||
|
permalink: >-
|
|||
|
archive/2023/04/11/just-vs-make
|
|||
|
tags:
|
|||
|
- devops
|
|||
|
- just
|
|||
|
- make
|
|||
|
- linux
|
|||
|
---
|
|||
|
|
|||
|
`just` compared to `make` is something that was asked during my PHP London talk, and whilst they are similar, `just` has differences for me that explains why I use it:
|
|||
|
|
|||
|
## Tabs or spaces
|
|||
|
|
|||
|
A Makefile needs to use tabs. Justfiles are more flexible and work with tabs or any number of spaces.
|
|||
|
|
|||
|
## .PHONY
|
|||
|
|
|||
|
With a Makefile, you need to declare some targets as "phony". I believe that this is for targets that don't generate artifact files with that name, so as I'm not compiling and building files with `make`, this is redundant and adds visual noise.
|
|||
|
|
|||
|
## Passing arguments
|
|||
|
|
|||
|
This is how a `composer` target looks like in a Makefile:
|
|||
|
|
|||
|
```make
|
|||
|
composer:
|
|||
|
docker compose exec php composer
|
|||
|
```
|
|||
|
|
|||
|
With this, I'd expect to be able to pass arguments to it - e.g. `make composer info drupal/core`.
|
|||
|
|
|||
|
But, instead of seeing the expected output, I get an error: `make: *** No rule to make target 'info'. Stop.`.
|
|||
|
|
|||
|
This is what I'd need to do to pass arguments to the `composer` target:
|
|||
|
|
|||
|
```make
|
|||
|
composer:
|
|||
|
docker compose exec php composer $(COMPOSER_ARGS)
|
|||
|
```
|
|||
|
|
|||
|
Now I can run `make composer COMPOSER_ARGS="info drupal/core"` and see what I was expecting but the syntax isn't what I'd want.
|
|||
|
|
|||
|
`just`, on the other hand, allows for defining parameters to its recipes:
|
|||
|
|
|||
|
```yaml
|
|||
|
composer *args:
|
|||
|
docker compose exec php composer {{ args }}
|
|||
|
```
|
|||
|
|
|||
|
Here, I can create as many named parameters as needed and use them in the recipe with the syntax that I wanted - `just composer info drupal/core`.
|
|||
|
|
|||
|
I can think of a few others but this is is the main reason why I moved from `make` and later adopted `just`.
|
|||
|
|
|||
|
`just`, for me, gives the flexibilty that I need whilst using a simple and familiar syntax but without some of the confusing and complicated behaviours of `make`.
|