f42251baaa7b82881370a45fee96d5739d70f09b
[platform/core/ml/nnfw.git] / infra / scripts / docker_build_cross_coverage.sh
1 #!/bin/bash
2
3 [[ "${BASH_SOURCE[0]}" != "${0}" ]] && echo "Please don't source ${BASH_SOURCE[0]}, execute it" && return
4
5 CURRENT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6 ROOT_PATH="$CURRENT_PATH/../../"
7
8 # prepare rootfs
9 if [ -z "$ROOTFS_DIR" ] || [ ! -d $ROOTFS_DIR ]; then
10   echo "It will use default rootfs path"
11 else
12   DOCKER_VOLUMES+=" -v $ROOTFS_DIR:/opt/rootfs"
13   DOCKER_ENV_VARS+=" -e ROOTFS_DIR=/opt/rootfs"
14 fi
15
16 # mount volume (or directory) for externals
17 if [ -n "$EXTERNAL_VOLUME" ]; then
18   DOCKER_VOLUMES+=" -v $EXTERNAL_VOLUME:/externals"
19   DOCKER_ENV_VARS+=" -e EXTERNAL_VOLUME=/externals"
20 else
21   echo "It will use default external path"
22 fi
23
24 # docker image name
25 if [[ -z $DOCKER_IMAGE_NAME ]]; then
26   echo "It will use default docker image name"
27 fi
28
29 # Mirror server setting
30 if [[ -z $EXTERNAL_DOWNLOAD_SERVER ]]; then
31   echo "It will not use mirror server"
32 fi
33
34 NNAS_WORKSPACE=${NNAS_WORKSPACE:-build}
35 if [[ -z "${ARCHIVE_PATH}" ]]; then
36   ARCHIVE_PATH=${NNAS_WORKSPACE}/archive
37 fi
38
39 DOCKER_ENV_VARS+=" -e TARGET_ARCH=armv7l"
40 DOCKER_ENV_VARS+=" -e CROSS_BUILD=1"
41 DOCKER_ENV_VARS+=" -e COVERAGE_BUILD=1"
42
43 set -e
44
45 pushd $ROOT_PATH > /dev/null
46
47 # TODO use command instead of makefile
48 export DOCKER_ENV_VARS
49 export DOCKER_VOLUMES
50 CMD="cp -nv Makefile.template Makefile && \
51      make all install build_coverage_suite"
52 ./nnfw docker-run bash -c "$CMD"
53
54 mkdir -p ${ARCHIVE_PATH}
55 # TODO change workspace usage in makefile
56 mv Product/out/coverage-suite.tar.gz ${ARCHIVE_PATH}/
57
58 popd > /dev/null