aboutsummaryrefslogtreecommitdiffstats
path: root/dist/linux/docker-buildtest.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dist/linux/docker-buildtest.sh')
-rwxr-xr-x[-rw-r--r--]dist/linux/docker-buildtest.sh64
1 files changed, 53 insertions, 11 deletions
diff --git a/dist/linux/docker-buildtest.sh b/dist/linux/docker-buildtest.sh
index 5c921b18e..919a314d6 100644..100755
--- a/dist/linux/docker-buildtest.sh
+++ b/dist/linux/docker-buildtest.sh
@@ -1,22 +1,64 @@
-set -ev
+#! /bin/sh
-docker pull "$DOCKER_IMG"
+. dist/ansi_color.sh
+disable_color
-if [ -z "$DONTGRAB_SRCS" ]; then
+# Stop in case of error
+set -e
+# Transform long options to short ones
+for arg in "$@"; do
+ shift
+ case "$arg" in
+ "--color"|"-color") set -- "$@" "-c";;
+ "--grab"|"-grab") set -- "$@" "-g";;
+ "--image"|"-image") set -- "$@" "-i";;
+ "--build"|"-build") set -- "$@" "-b";;
+ "--file"|"-file") set -- "$@" "-f";;
+ "--taskid"|"-taskid") set -- "$@" "-t";;
+ *) set -- "$@" "$arg"
+ esac
+done
+# Parse args
+while getopts ":i:b:f:t:cg" opt; do
+ case $opt in
+ c) enable_color;;
+ g) GRAB_SRCS=1;;
+ i) DOCKER_IMG=$OPTARG;;
+ b) BLD=$OPTARG ;;
+ f) PKG_FILE=$OPTARG;;
+ t) TASK=$OPTARG;;
+ \?) printf "$ANSI_RED[BUILD] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2; exit 1 ;;
+ :) printf "$ANSI_RED[BUILD] Option -$OPTARG requires an argument $ANSI_NOCOLOR\n" >&2; exit 1 ;;
+ esac
+done
+
+#---
+
+printf "$ANSI_YELLOW[$TASK| BUILD] Docker pull $DOCKER_IMG $ANSI_NOCOLOR\n"
+docker pull "$DOCKER_IMG" > /dev/null 2>&1
+
+#---
+
+printf "$ANSI_YELLOW[$TASK| BUILD] Docker run $DOCKER_IMG $BLD $PKG_FILE $ANSI_NOCOLOR\n"
+
+if [ -n "$GRAB_SRCS" ]; then
+
+ printf "$ANSI_YELLOW[$TASK| BUILD] Grab sources$ANSI_NOCOLOR\n"
+
p="mkdir /work && cd /work"
p="$p && curl -L https://github.com/tgingold/ghdl/archive/master.tar.gz | tar xz"
p="$p && mv ghdl-master/* ./ && rm -rf ghdl-master"
-
- docker run --name ghdl_cmp -it "$DOCKER_IMG" sh -c "$p && sh ./dist/linux/buildtest.sh -b $DBLD -f $PKG_FILE"
+
+ set +e
+ docker run --name ghdl_cmp -t "$DOCKER_IMG" sh -c "$p &&./dist/linux/buildtest.sh $ENABLECOLOR-t $TASK -b $BLD -f $PKG_FILE"
+ docker cp "ghdl_cmp:/work/log.log" "./log.log"
+ set -e
docker cp "ghdl_cmp:/work/$PKG_FILE" ./
+ docker rm ghdl_cmp
else
- docker run --name ghdl_cmp -itv $(pwd):/work:Z "$DOCKER_IMG" sh -c "cd /work && sh ./dist/linux/buildtest.sh -b $DBLD -f $PKG_FILE"
-
-fi
-
-docker rm ghdl_cmp
-
+ docker run --rm -tv $(pwd):/work:Z -w="/work" "$DOCKER_IMG" sh -c "./dist/linux/buildtest.sh $ENABLECOLOR-t $TASK -b $BLD -f $PKG_FILE"
+fi \ No newline at end of file