You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1021 B

#!/bin/bash
set -e -x
DIR=$(cd "$(dirname "$0")"; pwd -P)
TOOLCHAIN_IMAGE="esp32-toolchain:latest"
: ${BUILD_DIR:="$DIR/cmake-build"}
DOCKERFILE="$DIR/Dockerfile"
DOCKER_RUN_FLAGS=(--interactive --rm)
# if stdin is a terminal, tell docker to allocate a tty
if [ -t 0 ]; then
DOCKER_RUN_FLAGS+=(--tty)
fi
build_docker_container() {
docker build -f "$DOCKERFILE" -t "$TOOLCHAIN_IMAGE" "$DIR"
}
build_docker() {
build_docker_container
docker run \
--volume="$DIR:/esp/uas-ugv" \
"${DOCKER_RUN_FLAGS[@]}" \
"$TOOLCHAIN_IMAGE" \
/esp/uas-ugv/build.sh cmake "$@"
}
build_cmake() {
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake -G Ninja "$DIR"
cmake --build "$BUILD_DIR" -- "$@"
}
build_clean() {
rm -rf "$BUILD_DIR"
}
CMD="$1"; shift
case $CMD in
docker_container) build_docker_container ;;
docker) build_docker "$@" ;;
cmake) build_cmake "$@" ;;
clean) build_clean ;;
*) echo "Usage: $0 <docker_container|docker|cmake>" ;;
esac