|
diff --git a/Makefile b/Makefile
|
| 1 |
MEX_DESCRIPTION="This provides some additional tools for makefiles." |
1 |
MEX_DESCRIPTION="This provides some additional tools for makefiles." |
| 2 |
MEX_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
2 |
MEX_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
| 3 |
MEX_ASSURE="python3 ls tree clang" |
3 |
MEX_ASSURE="python3 ls tree clang" |
|
|
4 |
MEX_ENVIRONMENT="local.env second.env" |
| 4 |
|
5 |
|
| 5 |
include makext.mk |
6 |
include makext.mk |
| 6 |
|
7 |
|
| ... |
| 8 |
|
9 |
|
| 9 |
demo-assure: .assure |
10 |
demo-assure: .assure |
| 10 |
@echo "All good, continuing..." |
11 |
@echo "All good, continuing..." |
|
|
12 |
|
|
|
13 |
demo-envars: |
|
|
14 |
@echo "Envrionment variables" |
|
|
15 |
@echo " HOME: $(HOME)" |
|
|
16 |
@echo " TERM: $(TERM)" |
|
|
17 |
@echo " ENV: $(MEX_ENVIRONMENT)" |
|
|
18 |
@echo " AUDIO_BUCKET: $(AUDIO_BUCKET)" |
|
|
19 |
@echo " DB_HOST: $(DB_HOST)" |
| 11 |
|
20 |
|
| 12 |
build-app: clean-cache # Build the application |
21 |
build-app: clean-cache # Build the application |
| 13 |
@echo "Building the application..." |
22 |
@echo "Building the application..." |
| ... |
|
diff --git a/README.md b/README.md
|
| ... |
| 11 |
> meant to really be a task runner. Keep that in mind. However, dispite |
11 |
> meant to really be a task runner. Keep that in mind. However, dispite |
| 12 |
> that, I constantly find myself using it as such. |
12 |
> that, I constantly find myself using it as such. |
| 13 |
|
13 |
|
| 14 |
| Extension | Description | |
14 |
| Extension | Description | |
| 15 |
|-----------|-----------------------------------------------------| |
15 |
|-------------|-----------------------------------------------------| |
| 16 |
| .help | Displays all targets with a comment in help format. | |
16 |
| help | Displays all targets with a comment in help format. | |
| 17 |
| .assure | Check for the existance of programs on a machine. | |
17 |
| assure | Check for the existance of programs on a machine. | |
|
|
18 |
| environment | Loads environmental variables from other files. | |
| 18 |
|
19 |
|
| 19 |
Additional features: |
20 |
Additional features: |
| 20 |
|
21 |
|
| ... |
| 146 |
## Assure extension |
147 |
## Assure extension |
| 147 |
|
148 |
|
| 148 |
Often times project uses multiple programs and to ensure that these |
149 |
Often times project uses multiple programs and to ensure that these |
| 149 |
programs are already installed before recipes are executed `assure` can |
150 |
programs are already installed before recipes are executed `.assure` can |
| 150 |
be used. If programs are missing recipes can only partially be executed |
151 |
be used. If programs are missing recipes can only partially be executed |
| 151 |
leaving project in a potentially broken state. |
152 |
leaving project in a potentially broken state. |
| 152 |
|
153 |
|
| ... |
| 163 |
`MEX_ASSURE` variable and in case one is missing will exit `make` with |
164 |
`MEX_ASSURE` variable and in case one is missing will exit `make` with |
| 164 |
status code error 1. This will stop executing the recipe and therefore |
165 |
status code error 1. This will stop executing the recipe and therefore |
| 165 |
not execute anything in target `build-app`. |
166 |
not execute anything in target `build-app`. |
|
|
167 |
|
|
|
168 |
## Environment extension |
|
|
169 |
|
|
|
170 |
This extension helps loading of additional environmental files in your |
|
|
171 |
project. The files should have environmental variables defined in the |
|
|
172 |
usual way. Seperate each file by a space and that is about it. |
|
|
173 |
|
|
|
174 |
If a file is missing this will break the execution of make and exit with |
|
|
175 |
status code 1. |
|
|
176 |
|
|
|
177 |
```env |
|
|
178 |
API_KEY=abc123 |
|
|
179 |
SECRET_KEY=def456 |
|
|
180 |
``` |
|
|
181 |
|
|
|
182 |
By defining `MEX_ENVIRONMENT` variable you can provide additional files |
|
|
183 |
and they will be loaded automatically. |
|
|
184 |
|
|
|
185 |
```make |
|
|
186 |
MEX_ENVIRONMENT="local.env second.env" |
|
|
187 |
|
|
|
188 |
include makext.mk |
|
|
189 |
|
|
|
190 |
demo-envars: |
|
|
191 |
@echo "Envrionment variables" |
|
|
192 |
@echo " HOME: $(HOME)" |
|
|
193 |
@echo " TERM: $(TERM)" |
|
|
194 |
@echo " ENV: $(MEX_ENVIRONMENT)" |
|
|
195 |
@echo " AUDIO_BUCKET: $(AUDIO_BUCKET)" |
|
|
196 |
@echo " DB_HOST: $(DB_HOST)" |
|
|
197 |
``` |
|
|
198 |
|
|
|
199 |
After that they can be used in your recipes like all the other variables |
|
|
200 |
you have. They will however override variables the shell already has |
|
|
201 |
defined. |
| 166 |
|
202 |
|
| 167 |
## Acknowledgement |
203 |
## Acknowledgement |
| 168 |
|
204 |
|
| ... |
|
diff --git a/makext.mk b/makext.mk
|
| ... |
| 15 |
$(error makext does not support Windows operating system) |
15 |
$(error makext does not support Windows operating system) |
| 16 |
endif |
16 |
endif |
| 17 |
|
17 |
|
|
|
18 |
# Load environmental files from `MEX_ENVIRONMENT`. By default GNU make |
|
|
19 |
# loads what is already in `env`. This extends it to other files. |
|
|
20 |
ifdef MEX_ENVIRONMENT |
|
|
21 |
TEMP_ENV_FILES=$(shell echo $(MEX_ENVIRONMENT) | tr ',' ' ') |
|
|
22 |
$(foreach file,$(TEMP_ENV_FILES),$(eval include $(file))) |
|
|
23 |
endif |
|
|
24 |
|
| 18 |
# Help extension that lists all the targets with descriptions |
25 |
# Help extension that lists all the targets with descriptions |
| 19 |
# and adds description and license information if data provided. |
26 |
# and adds description and license information if data provided. |
| 20 |
.PHONY: .help |
27 |
.PHONY: .help |
| ... |