#!/bin/bash
+NNFW_SCRIPT_RPATH="scripts"
+NNFW_COMMAND_RPATH="${NNCC_SCRIPT_RPATH}/command"
+
+NNFW_PROJECT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+NNFW_SCRIPT_PATH="${NNCC_PROJECT_PATH}/${NNCC_SCRIPT_RPATH}"
+
+function Usage()
+{
+ echo "Usage: $0 [COMMAND] ..."
+ echo "Command:"
+ for file in "$NNFW_COMMAND_RPATH"/*;
+ do
+ echo " $(basename "$file")"
+ done
+}
+
COMMAND=$1; shift
if [[ -z "${COMMAND}" ]]; then
- echo "USAGE: $0 [COMMAND] ..."
+ Usage()
exit 255
fi
-NNFW_PROJECT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-NNFW_COMMAND_RPATH="scripts/command"
-
-NNFW_COMMAND_FILE="${NNFW_PROJECT_PATH}/${NNFW_COMMAND_RPATH}/${COMMAND}"
+COMMAND_FILE="${NNFW_PROJECT_PATH}/${NNFW_COMMAND_RPATH}/${COMMAND}"
-if [[ ! -f "${NNFW_COMMAND_FILE}" ]]; then
+if [[ ! -f "${COMMAND_FILE}" ]]; then
echo "ERROR: '${COMMAND}' is not supported"
exit 255
fi
export NNFW_PROJECT_PATH
+export NNFW_SCRIPT_PATH
-source "${NNFW_COMMAND_FILE}" "$@"
+source "${COMMAND_FILE}" "$@"
#!/bin/bash
-SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-source $SCRIPT_ROOT/common.sh
-
-HOST_HOME=$SCRIPT_ROOT/../..
-DOCKER_HOME=/home
-
-GIT_SSL_NO_VERIFY=1
-
-DOCKER_VOLUMES+=" -v $HOST_HOME:$DOCKER_HOME"
-
-DOCKER_ENV_VARS+=" -e http_proxy"
-DOCKER_ENV_VARS+=" -e no_proxy"
-DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY"
-
-DOCKER_RUN_OPTS="--rm"
-DOCKER_RUN_OPTS+=" -w $DOCKER_HOME"
+source "${NNFW_SCRIPT_PATH}/docker.configuration"
docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME "$@"
EXITCODE=$?
--- /dev/null
+DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnfw}
+echo "Using docker image $DOCKER_IMAGE_NAME"
+
+if [ -z "`docker images | grep $DOCKER_IMAGE_NAME`" ]; then
+ echo "Need docker image!"
+ exit 1
+fi
+
+HOST_PATH="$NNFW_PROJECT_PATH"
+DOCKER_PATH="$NNFW_PROJECT_PATH"
+
+export GIT_SSL_NO_VERIFY=1
+
+DOCKER_VOLUMES=" -v $HOST_PATH:$DOCKER_PATH"
+
+DOCKER_ENV_VARS+=" -e http_proxy"
+DOCKER_ENV_VARS+=" -e no_proxy"
+DOCKER_ENV_VARS+=" -e GIT_SSL_NO_VERIFY"
+DOCKER_ENV_VARS+=" -e ARMCOMPUTE_URL"
+DOCKER_ENV_VARS+=" -e EIGEN_URL"
+DOCKER_ENV_VARS+=" -e FARMHASH_URL"
+DOCKER_ENV_VARS+=" -e FLATBUFFERS_URL"
+DOCKER_ENV_VARS+=" -e GEMMLOWP_URL"
+DOCKER_ENV_VARS+=" -e GTEST_URL"
+DOCKER_ENV_VARS+=" -e NEON2SSE_URL"
+DOCKER_ENV_VARS+=" -e TENSORFLOW_URL"
+
+DOCKER_RUN_OPTS="${DOCKER_OPTS}"
+DOCKER_RUN_OPTS+=" --rm"
+DOCKER_RUN_OPTS+=" -w $DOCKER_PATH"
+
+function docker_cleanup()
+{
+ # Newly created files during during docker run can have different ownership.
+ # This may cause some problems, for example, some jenkins slaves or developers
+ # can't remove built files due to lack of permission.
+ # To address this issue, let's change owner of all files
+ # in nncc to owner of nncc.
+ NNFW_OWNER_UID=$(stat -c "%u" $HOST_PATH)
+ NNFW_OWNER_GID=$(stat -c "%g" $HOST_PATH)
+
+ CMD="chown -R $NNFW_OWNER_UID:$NNFW_OWNER_GID $DOCKER_PATH"
+ docker run $DOCKER_RUN_OPTS $DOCKER_ENV_VARS $DOCKER_VOLUMES $DOCKER_IMAGE_NAME $CMD
+}