Fix build script
Change-Id: I4fb9ca9594bc9622aba2f92343bb17a5fc50cb84
diff --git a/build.sh b/build.sh
index de85e78..f06ac34 100755
--- a/build.sh
+++ b/build.sh
@@ -10,28 +10,66 @@
TOOLCHAIN_DIR=$ROOT_DIR/toolchain/$BUILD_PLATFORM
echo "toolchain : $ROOT_DIR"
-if [ ! -d out/bin ];then
- mkdir -p out/bin
-fi
-if [ ! -d out/lib ];then
- mkdir -p out/lib
-fi
-cd mbtk
+function build()
+{
+ cd mbtk
-if [ -n "$1" ] ;then
- case "$1" in
- clean)
- make clean
- ;;
- *)
- exit 1;;
- esac
-else # 无参数
- make
-fi
+ if [ -n "$1" ] ;then
+ case "$1" in
+ clean)
+ make clean
+ ;;
+ *)
+ exit 1;;
+ esac
+ else # 无参数
+ make || exit 1
+ fi
-cd $ROOT_DIR
+ cd $ROOT_DIR
-echo "Build complete."
\ No newline at end of file
+ echo "Build MBTK success."
+}
+
+function file_copy()
+{
+ ROOTFS_DIR=$ROOT_DIR/../asr_code/target/linux/mmp/base-files
+
+ if [ -d $ROOTFS_DIR ];then
+ echo "Copy MBTK out files..."
+ if [ ! -d $ROOTFS_DIR/bin ];then
+ mkdir $ROOTFS_DIR/bin
+ fi
+ if [ ! -d $ROOTFS_DIR/lib ];then
+ mkdir $ROOTFS_DIR/lib
+ fi
+
+ # Copy All SO Files.
+ cp -f out/lib/* $ROOTFS_DIR/lib
+
+ # Copy All Bin Files.
+ cp -f out/bin/* $ROOTFS_DIR/bin
+
+ else
+ echo "No found rootfs : $ROOTFS_DIR"
+ fi
+}
+
+function main()
+{
+ if [ ! -d out/bin ];then
+ mkdir -p out/bin
+ fi
+
+ if [ ! -d out/lib ];then
+ mkdir -p out/lib
+ fi
+
+ build
+
+ file_copy
+}
+
+main
\ No newline at end of file