4 ms·
EDIT: Not really a serious suggestion Make is not _that_ portable. If you're using high level languages and only need a task runner to kick off your compiler,
by apatheticonion 4y ago
EDIT: Not really a serious suggestion
Make is not _that_ portable. If you're using high level languages and only need a task runner to kick off your compiler, watch rules or similar and need portability, you could write an executable bash script with functions that serve as your commands;
#!/bin/bash
set -e
function build() {
echo "Your build steps"
}
function clean() {
echo "Your clean steps"
}
eval $1 $@
Which you can run with
$ ./task clean
$ ./task build
You can also write these kinds of task scripts in JavaScript or Python - which might be easier to manage compatibility with Windows
- velcrovan 4y agoAll of my makefiles have SHELL = /bin/bash as the first line. Let me know what a bash script would look like that does dependency checking for each build artifact
- apatheticonion 4y agoYeah that's fair. I only use make as a task runner for high level languages where the compilers that take care of those aspects of compilation. My makefile commands are never much more complicated than "cargo build" or adding compiler flags to my "go build" command
- remram 4y agoWhy not write two files ./clean.sh and ./build.sh instead?
- apatheticonion 4y agoNo reason why you couldn't do that too - it's to taste. I generally like to have fewer files in the top level of my repos to keep them approachable. You could also have a folder that contains scripts like: `./scripts/build`
- tomjakubowski 4y agoIt's a little more convenient to share code / variables between tasks in a single script
- tomjakubowski 4y agoI actually do exactly this in some of my personal projects. don't need the eval, store $1 in a variable and shift $@. and you might also want to check that $1 is a function defined in the script, lest the task runner execute some other arbitrary command
- apatheticonion 4y agoNice! Any chance you could share a GitHub gist or similar?