[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bach/build.bach/tools/cfgGen.sh b/src/bach/build.bach/tools/cfgGen.sh
new file mode 100755
index 0000000..094e610
--- /dev/null
+++ b/src/bach/build.bach/tools/cfgGen.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+
+MOLYCFG=$1
+INS_FILE="EXT_BOOTLOADER"
+GEN_FILE="$MOLYCFG.tmp"
+OPTION_TMP_PATH="$WORKDIR/bootloader_lte/out"
+TMP_FOLDER="$OUTDIR/tmp/$PRJ_FILENAME"
+LOGDIR="$OUTDIR/log"
+NOWDIR="`pwd`"
+
+#Copy again for the new *.cfg file.
+TARGETFOLDER="$WORKDIR/install/$CROSS_PREFIX/out"
+
+if [ $# -ge 2 ]; then
+ PRJ_FILENAME=$2
+else
+ PRJ_FILENAME=`cat build.sdk | grep PRJ_FILENAME | head -n 1 | sed -e 's/\$PRJ_FILENAME=\"//g' -e 's/\";//g'`
+fi
+CUSTOMDIR="$WORKDIR/custom/$PRJ_FILENAME/build"
+CUSSYS_DIR="$WORKDIR/custom/$PRJ_FILENAME/system"
+
+if [ ! -d $CUSTOMDIR ]; then
+ CUSTOMDIR="$WORKDIR/custom/DEFAULT/build"
+fi
+
+if [ "$PLATFORM_CHIP" == "MT6735" ]; then
+perl tools/cfgGen_sp.pl $CUSTOMDIR
+CFGS=`ls $CUSTOMDIR | grep .txt`
+else
+perl tools/cfgGen.pl $CUSTOMDIR
+CFGS=`ls $CUSTOMDIR | grep .cfg`
+fi
+
+cd $TARGETFOLDER
+
+if [ "$PLATFORM_CHIP" != "MT6291" ] && [ "$PLATFORM_CHIP" != "MT6292" ] && [ "$PLATFORM_CHIP" != "MT6293" ] && [ "$PLATFORM_CHIP" != "MT6295" ] && [ "$PLATFORM_CHIP" != "MT6297" ] && [ "$PLATFORM_CHIP" != "MT6298" ]; then
+ if [ "$PLATFORM_CHIP" == "MT6735" ]; then
+ perl $NOWDIR/tools/preCfgGen_sp.pl . $PROJECT_FLAVOR
+ cp $MOLYCFG $GEN_FILE
+ else
+ INS_LINE=`grep -n $INS_FILE $MOLYCFG |awk -F":" '{ print $1 }'`
+ AFTER_INS_LINE=$((`tac $MOLYCFG | grep -n $INS_FILE |awk -F":" '{ print $1 }'` - 1))
+
+ head -n $INS_LINE $MOLYCFG > $GEN_FILE
+ echo " - file: preloader_gfh.bin" >> $GEN_FILE
+ tail -n $AFTER_INS_LINE $MOLYCFG >> $GEN_FILE
+ fi
+else
+ cat "$OPTION_TMP_PATH/~customIncDef.tmp" | sed -e 's|-I\.\/|-I'"$WORKDIR"'\/bootloader_lte\/|g' -e 's|-I\.\.\/|-I'"$WORKDIR"'\/|g' > $OPTION_TMP_PATH/customIncDef.tmp
+ if [ "$PLATFORM_CHIP" == "MT6297" ] || [ "$PLATFORM_CHIP" == "MT6298" ]; then
+ perl $NOWDIR/tools/preCfgGen.pl . `cd $TARGETFOLDER && ls *_BOOTLOADER_*` $CUSTOMDIR/customer_feature_option $CUSSYS_DIR "arm-linux-gcc -mthumb" @ $OPTION_TMP_PATH/customIncDef.tmp $TMP_FOLDER lk_gfh.bin > "$LOGDIR/cfggen.log"
+ else
+ perl $NOWDIR/tools/preCfgGen.pl . `cd $TARGETFOLDER && ls TK6291_BOOTLOADER_*` $CUSTOMDIR/customer_feature_option $CUSSYS_DIR "arm-linux-gcc -mthumb" @ $OPTION_TMP_PATH/customIncDef.tmp $TMP_FOLDER preloader_gfh.bin > "$LOGDIR/cfggen.log"
+ fi
+ cp $MOLYCFG $GEN_FILE
+fi
+
+if [ ! -f $TARGETFOLDER/$MOLYCFG ]; then
+ echo "$TARGETFOLDER/$MOLYCFG not found!"
+ exit 1
+fi
+rm -f $MOLYCFG
+
+for cfgfile in $CFGS
+do
+ if [ "$PLATFORM_CHIP" != "MT6291" ] && [ "$PLATFORM_CHIP" != "MT6292" ] && [ "$PLATFORM_CHIP" != "MT6293" ] && [ "$PLATFORM_CHIP" != "MT6295" ] && [ "$PLATFORM_CHIP" != "MT6297" ] && [ "$PLATFORM_CHIP" != "MT6298" ]; then
+ if [ "$PLATFORM_CHIP" = "MT6735" ]; then
+ cp -f $GEN_FILE "$PLATFORM_CHIP"_$cfgfile
+ cat $CUSTOMDIR/$cfgfile >> "$PLATFORM_CHIP"_$cfgfile
+ else
+ cp -f $GEN_FILE MT6290_$cfgfile
+ cat $CUSTOMDIR/$cfgfile >> MT6290_$cfgfile
+ fi
+ else
+ cp -f $GEN_FILE "$PLATFORM_CHIP"_$cfgfile
+ cat $CUSTOMDIR/$cfgfile >> "$PLATFORM_CHIP"_$cfgfile
+ fi
+done
+
+rm -f $GEN_FILE
+