Revise build script and introduce build-acl script (#3214)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 19 Oct 2018 00:54:42 +0000 (09:54 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 19 Oct 2018 00:54:42 +0000 (09:54 +0900)
* Revise build script and introduce build-acl script

Revise build script
Introduce build-acl script

Howto : On project root, "./run build-acl" or "./run build" with environment variable setting

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
* Change all tab to space

* Change all tab to space and remove unnecessary line: build-acl

scripts/command/build
scripts/command/build-acl [new file with mode: 0644]

index 5219001..e2fcb87 100644 (file)
@@ -1,7 +1,25 @@
 #!/bin/bash
 
-# NOTE 'run' sets NNFW_PROJECT_PATH and invokes this script
+# NOTE 'run' sets NNFW_SCRIPT_PATH and invokes this script
+source "${NNFW_SCRIPT_PATH}/build.configuration"
 
-# TODO Support command-line options
-# TODO Implement build steps inside this script
-make -C "${NNFW_PROJECT_PATH}"
+if [[ ! -d "${BUILD_ALIAS}" ]]; then
+  echo "'${BUILD_ALIAS}' does not exist. Please run 'configure' first"
+  exit 255
+fi
+
+# Set parallel build
+# TODO Use argument instead of environment variable
+HOST_OS=${HOST_OS:-linux}
+NPROCS=${NPROCS:-1}
+PARALLEL_BUILD=${PARALLEL_BUILD:-1}
+
+if [ "${PARALLEL_BUILD}" == "1" ]; then
+  # Get number of processors (linux only for now)
+  if [ "${HOST_OS}" == "linux" ]; then
+    NPROCS="$(grep -c ^processor /proc/cpuinfo)"
+  fi
+fi
+
+cd ${BUILD_ALIAS}
+make -j ${NPROCS} "$@"
diff --git a/scripts/command/build-acl b/scripts/command/build-acl
new file mode 100644 (file)
index 0000000..440ad2a
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+# NOTE 'run' sets NNFW_SCRIPT_PATH and invokes this script
+source "${NNFW_SCRIPT_PATH}/build.configuration"
+
+# Set parallel build
+# TODO: use argument instead of environment variable and merge with build command
+TARGET_ARCH=${TARGET_ARCH:-armv7l}
+BUILD_TYPE=${BUILD_TYPE:-Debug}
+NPROCS=${NPROCS:-1}
+PARALLEL_BUILD=${PARALLEL_BUILD:-1}
+HOST_OS=${HOST_OS:-linux}
+TARGET_OS=${TARGET_OS:-linux}
+
+# make TARGET and TYPE to lowercase
+TARGET_ARCH_LC="$(echo ${TARGET_ARCH} | tr A-Z a-z)"
+BUILD_TYPE_LC="$(echo ${BUILD_TYPE} | tr A-Z a-z)"
+# we need base name 'arm` for all arm arch
+TARGET_ARCH_BASE="${TARGET_ARCH_LC}"
+
+if [ "${TARGET_ARCH_BASE}" == *"arm64"* ]; then
+  # For now Android is the only option for arm64
+  TARGET_ARCH_BASE=arm64
+  TARGET_OS=android
+fi
+
+if [ "${PARALLEL_BUILD}" == "1" ]; then
+  # Get number of processors (linux only for now)
+  if [ "${HOST_OS}" == "linux" ]; then
+    NPROCS="$(grep -c ^processor /proc/cpuinfo)"
+  fi
+fi
+
+ACL_FOLDER="externals/acl"
+ACL_COMMAND="scons -j${NPROCS} neon=1 opencl=1 examples=0 embed_kernels=1 os=${TARGET_OS}"
+if [ "${TARGET_ARCH_LC}" == "armv7l" ]; then
+  ACL_COMMAND+=" arch=armv7a"
+  ACL_BUILD_OUT="armv7a-${TARGET_OS}"
+elif [ "${TARGET_ARCH_LC}" == "aarch64" ]; then
+  ACL_COMMAND+=" arch=arm64-v8a"
+  ACL_BUILD_OUT="arm64-v8a-${TARGET_OS}"
+elif [ "${TARGET_ARCH_BASE}" == "arm64" ]; then
+  ACL_COMMAND+=" arch=arm64-v8a"
+  ACL_BUILD_OUT="arm64-v8a-${TARGET_OS}"
+fi
+
+if [ "${TARGET_OS}" == "android" ]; then
+  ACL_COMMAND+=" Werror=0"
+  ANDROID_GNUSTL_PATH="${ROOTFS_ARM64}/bin:${ROOTFS_ARM64}/aarch64-linux-android/bin:$$PATH"
+else
+  ACL_COMMAND+=" Werror=1"
+fi
+
+if [ "${BUILD_TYPE_LC}" == "debug" ]; then
+  ACL_COMMAND+=" debug=1 asserts=1"
+fi
+
+ACL_FOLDER_NAME="${ACL_BUILD_OUT}.${BUILD_TYPE_LC}"
+ACL_COMMAND+=" build_dir=${ACL_FOLDER_NAME}"
+ACL_FOLDER_BUILD="${ACL_FOLDER}/build/${ACL_FOLDER_NAME}"
+
+pushd ${ACL_FOLDER}
+if [ "${TARGET_OS}" == "android" ]; then
+  CXX=clang++ CC=clang PATH=${ANDROID_GNUSTL_PATH} ${ACL_COMMAND}
+else
+  ${ACL_COMMAND}
+fi
+popd
+
+mkdir -vp ${INSTALL_ALIAS}/lib
+cp -v ${ACL_FOLDER_BUILD}/libarm_compute_core.so ${INSTALL_ALIAS}/lib/.
+cp -v ${ACL_FOLDER_BUILD}/libarm_compute_graph.so ${INSTALL_ALIAS}/lib/.
+cp -v ${ACL_FOLDER_BUILD}/libarm_compute.so ${INSTALL_ALIAS}/lib/.