Introduce nnas command script (#5815)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 24 Jul 2019 04:04:11 +0000 (13:04 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 24 Jul 2019 04:04:11 +0000 (13:04 +0900)
Introduce 'nnas' command script to support unified command.
Call nnas fomart command in nnfw format-check command and remove workaround in 'nnfw'.
'nnas' is almost same with 'nncc' or 'nnfw'.
Remove deprecated NNAS_SCRIPT_PATH.
Relocate import() function.

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
infra/command/format
infra/nnfw/command/format-check [new file with mode: 0644]
nnas [new file with mode: 0755]
nnfw

index d1af047..cce295a 100644 (file)
@@ -49,7 +49,7 @@ check_newline() {
 check_permission() {
     # Check all files except script
     FILES_TO_CHECK=()
-    for NON_SCRIPT_FILE in $(git ls-files -- . ':!:nnfw' ':!:nncc' ':!:*.sh' ':!:*.py' ':!:compiler/' ':!:infra/nncc/' ':!:scripts/standalone'); do
+    for NON_SCRIPT_FILE in $(git ls-files -- . ':!:nnas' ':!:nnfw' ':!:nncc' ':!:*.sh' ':!:*.py' ':!:compiler/' ':!:infra/nncc/' ':!:scripts/standalone'); do
         FILES_TO_CHECK+=("${NON_SCRIPT_FILE}")
     done
 
diff --git a/infra/nnfw/command/format-check b/infra/nnfw/command/format-check
new file mode 100644 (file)
index 0000000..24129cb
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Workaround: Remove this file when CI infra's format checker is updated
+pushd ${NNFW_PROJECT_PATH} > /dev/null
+
+./nnas format
+
+popd > /dev/null
diff --git a/nnas b/nnas
new file mode 100755 (executable)
index 0000000..4445198
--- /dev/null
+++ b/nnas
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+NNAS_CONFIG_RPATH="infra/config"
+NNAS_COMMAND_RPATH="infra/command"
+NNAS_PROJECT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+function Usage()
+{
+  echo "Usage: $0 [COMMAND] ..."
+  echo "Command:"
+  for file in "$NNAS_COMMAND_RPATH"/*;
+  do
+    echo "  $(basename "$file")"
+  done
+}
+
+function import()
+{
+  source "${NNAS_PROJECT_PATH}/${NNAS_CONFIG_RPATH}/$1"
+}
+
+COMMAND=$1; shift
+
+if [[ -z "${COMMAND}" ]]; then
+  Usage
+  exit 255
+fi
+
+COMMAND_FILE="${NNAS_PROJECT_PATH}/${NNAS_COMMAND_RPATH}/${COMMAND}"
+
+if [[ ! -f "${COMMAND_FILE}" ]]; then
+  echo "ERROR: '${COMMAND}' is not supported"
+  exit 255
+fi
+
+export NNAS_PROJECT_PATH
+
+source "${COMMAND_FILE}" "$@"
diff --git a/nnfw b/nnfw
index 3925509..12e71e0 100755 (executable)
--- a/nnfw
+++ b/nnfw
@@ -24,11 +24,6 @@ if [[ -z "${COMMAND}" ]]; then
 fi
 
 COMMAND_FILE="${NNFW_PROJECT_PATH}/${NNFW_COMMAND_RPATH}/${COMMAND}"
-# Workraound: replace format check command
-# Remove this after make call in infra/nnfw/command/format-check to infra/command/format
-if [ "${COMMAND}" = "format-check" ]; then
-  COMMAND_FILE="${NNFW_PROJECT_PATH}/infra/command/format" "$@"
-fi
 
 if [[ ! -f "${COMMAND_FILE}" ]]; then
   echo "ERROR: '${COMMAND}' is not supported"