portapack-mayhem/firmware/tools/docker-entrypoint.sh
E.T 75ece38725
Dockerfile overhaul (#1726)
Create entrypoint to orchestrate the build steps
Supported commands: make, ninja
Passes additional arguments to the make / ninja command at the end (like -jNN)
There is a shortcut to make -jNN by just specifying -jNN
Anything else will be directly executed (like getting a shell into the container with bash -li is still possible)
2024-01-06 00:42:36 +01:00

35 lines
834 B
Bash
Executable File

#!/bin/bash
set -e # exit immediatelly on any failure
build_make() {
cd ..
mkdir -p build
cd build
cmake ..
make "$@"
exit 0 # Report success :)
}
build_ninja() {
cd ..
mkdir -p build
cd build
cmake -G Ninja ..
ninja "$@"
exit 0 # Report success :)
}
if [ "$1" = 'make' ]; then # build the default (or specified) target with make
shift # remove the first item from $@ as we consumed it, we can then pass the rest on to make
build_make "$@"
elif [[ $1 == -j* ]]; then # allow passing -j without typing make_default
# dont shift here as we wanna pass the -j
build_make "$@"
elif [ "$1" = 'ninja' ]; then # build the default (or specified) target with ninja
shift # remove the first item from $@ as we consumed it, we can then pass the rest on to make
build_ninja "$@"
fi
exec "$@"